instruction
stringlengths
71
71.9k
I've two table (t1 and t2) with 3 identical integer columns: c1, c2 and c3. I want to count how many value in t1 are in t2. SELECT count(t1.value) FROM t1 INNER JOIN t2 ON ( t1.c1 = t2.c1 OR t1.c1 = t2.c2 OR t1.c1 = t2.c3 OR t1.c2 = t2.c1 OR t1.c2 = t2.c2 OR t1.c2 = t2.c3 OR t1.c3 = t2.c1 OR t1.c3 = t2.c2 ...
I have some function like: void foo() { ... } int main() { ... try { ... foo(); ... } catch (const std::exception &e) { std::cout << "Fatal error: e.what() << std::endl(); return; } ... } If an exception is thrown from foo, I'd like to know it. Also I want to know the reason of the orig...
Is there any way to make that code shorter? I still want to use jQuery. I don't want to use any validation script. $("#form").submit(function (e) { var tmp = $('#select-1').val(); var tmp1 = $('#select-2').val(); var tmp2 = $('#select-3').val(); var error = $('#error-1'); var error2 = $('#error-2'); ...
I am a beginner in PHP-OOP and design patterns. I have got this basic piece of code in Singleton Pattern and I changed it in order to understand its behavior. I can see that it works as expected. However, it is not clear for me exactly how it works. Can anyone explain me? So it is working! My doubt is "Whis $inst is no...
The Setup This kata is a spin on the old backpack problem. Please give feedback on both the kata itself as well as my solution. I'm not sure if the kata needs to lead the student more or if this is a good open-ended problem. My original intent with this kata was to practice using Hashes. This is why the output is requi...
SELECT TOP 1 l.ID FROM Leads l WHERE l.ID NOT IN (SELECT LeadID FROM LeadFollowups) AND l.ID NOT IN (SELECT LeadID FROM LeadsWorking) AND l.ID NOT IN (SELECT LeadID FROM LeadsDead) AND l.ID NOT IN (SELECT LeadID FROM LeadHolds) AND l.ID >= (RAND() * (SELECT MAX(ID) FROM Leads)) ORDER BY l.Qu...
I'm working on this method in Java, which is giving me the factors of a number. I'll be using this method a lot, and I was wondering if there isn't a better way of doing it. Like, with just one loop. Although this code works great and it returns what I expect, I just want to know if there's a better workaround. The met...
I made a program in Python and wanted it to be faster, so I wrote it on C# because it's compiled. To my surprise, the Python program is much faster. I guess there is something wrong with my C# code, but it is pretty simple and straightforward, so I don't know. They are structured about the same way. C#: using System; u...
I have a need to read properties from soapUI using groovy and writing them to Excel. I initially had a problem with writing to Excel, but I was able to solve that. Now I want to know if my solution is correct from a best practice perspective and can it be optimized to work faster. I use Groovy and scriptom to write and...
I needed to impose on a Python method the following locking semantics: the method can only be run by one thread at a time. If thread B tries to run the method while it is already being run by thread A, then thread B immediately receives a return value of None. I wrote the following decorator to apply these semantics: f...
As request of Simon's comment: Direction.java package net.woopa.dungeon.datatypes; import java.util.Random; public enum Direction { NORTH, EAST, SOUTH, WEST; private static Random rnd = new Random(); static public Direction randomDirection() { return Direction.values()[rnd.nextInt(4)]; } ...
I've just finished writing my first game: a clone of the classic Pong game for Linux and Mac only. You will need SDL 2.0, SDL_ttf 2.0 and SDL_Mixer 2.0 to compile it. The complete project can be found here. My experience with C++ and game development in general is fairly limited and I would like to know what could be i...
So I've got a jquery project where I'm using an external class that has callback style events. Meaning, it has an "onSave" property that takes one function. However, I need to more than one other component to hook into it. What I've settled on for now, goes like this: var saveCallbacks = $.Callbacks(); saveCallbacks.fi...
#include <stdio.h> #include <stdlib.h> struct Stack { int value; int is_empty; struct Stack *next; }; int pop(struct Stack **stack) { if ((*stack)->is_empty == 1) { printf("Stack is empty!\n"); abort(); // not sure what this does } else { int value = (*stack)->value; // outer pointer (static...
Single app which listen to multiple RabbitMQ queue and process the message. This is working fine but not sure this implementation is right one or I am missing something. Implementation is inspired from this answer https://stackoverflow.com/a/21847234/37571 //Message subscriber implementation public class AuditSubscrib...
If this is my class: class Something { UUID id; // Other members } Given a List<Something> things and I want to get a List<UUID> ids, this is what I usually do: List<UUID> ids = new ArrayList<UUID> for(Something thing : things) { ids.add(thing.getId()); } return ids; Is there a more elegant way of doing ...
I wrote a simple cython script to optimize the collections.Counter of a dictionary counter and the python zip implementation (the main input is a list of tuples). Is there a way to speed it up? %%cython --annotate cimport cython import numpy as np cimport numpy as np from collections import defaultdict @cython.boundsc...
Level traverse binary tree question: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20 / \ 15 7 return its level order traversal as: [ [3], [9,20], [15,7] ] Th...
I have this portion of code and I would like to know if I did it right, what changes could be done to optimize and make it better, and if I used the all the tags the right way. For the moment, the CSS part is not really done since I have few bugs on the height of each column. <div class="shop-grid"> <div class="cont...
In my code I have a base type which is OnlinePaymentTransaction: public abstract class OnlinePaymentTransaction { public abstract void Complete( PaymentGatewayCallbackArgs args ); } The problem I am having is that each class that inherits from this base class require different dependency's in the complete method....
I am trying to cache the entirety of streams from Twitch.TV public API with the following code. It is successful but takes almost a full minute to execute so I am wondering if it's my code or just the speed of the API delivery. In any case, because it is my first PHP script (and really, I'm new in general), I am certai...
I have about 11 singleton-esque classes divided over a dozen files: the first file is one that gathers all singleton definitions and makes them callable on a request scope: public sealed partial class ExpertiseverslagEngine { readonly IOrganizationService _oService; readonly XrmServiceContext _oServiceContext; ...
After reading a lot of documents, I wrote this object pooling code. Can anyone help me to improve this code? I am lagging in validating the object, confirming whether I can reuse it or not. /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package iaccount.ui; import j...
I have implemented a customized UTF-8 encoding mechanism. The code works fine, but I have a lot of concerns regarding the code. public class Utf8Encoding { public static void main(String[] args) { byte [] arr = new byte[1000]; int iStr = 95000; // or > 65535, as till 65535 all chars are unic...
I am working on a project in which I have three box (as of now) and each box will have some color of balls, so I am storing the input in a Map of String and List of String as shown below: Map<String, List<String>> boxBallMap = new LinkedHashMap<String, List<String>>(); Data in the above map can be like this. Below is ...
In the below code I should highlight countries on the map based on the category of the country in which there are 2 different type of countries (issuing office and selected countries). Based on the country type I have to highlight that country on the map. Let us not worry about map code. There is a checkbox which con...
I need to improve the performance of a function that calculates the integral of a two-dimensional kernel density estimate (obtained using the function stats.gaussian_kde) where the domain of integration is all points that evaluate below a given value. I've found that a single line takes up pretty much 100% of the time ...
When an API has a 'next' feature, I use the following pattern to obtain all the results: /** Obtains a list of channels followed by a user */ function get_follows(username, callback) { var channels = []; function handler(data) { if (!data || data.follows.length == 0) { callback(channels); ...
I got a piece of Java code using Hadoop to calculate min, max, average and variance on a large dataset made of (index value) couples separated by a newline: 0 11839923.64831265 1 5710431.90800272 It's compiled locally and run on a remote distributed HDFS instance by a sh script. My main concerns are: if the output ...
I have a Queue that needs to try to process when anything updates in it (add, remove or update). However, I don't want any of the callers to wait while the processing is happening (either for the processing to happen or while the processing is happening). This is what I came up with: private static readonly SemaphoreSl...
I have implemented a simulation program that runs LRU and another web caching algorithm called Sliding Window LFU. I want to compare them both in terms of the hit rate and their run time. SW-LFU works fine, but it takes FOREVER to run! I really can't figure why, since I used many tricks and ideas to keep the effort low...
The task (from this site) is to create a program that will solve a problem where a matrix (size n * n), which contains integers, is to be divided into four parts, the sums of which are as close to each other as possible. They have to be divided left to right all the way and those parts (top/bottom), can be divided with...
I recieve a number n and then recieve n*n integers, representing a matrix, or an array of [n][n]. I want to create an array [n][n], where every cell contains the sum of all cells "left and above" from the original array, while not creating the array, just using the values. For example, the cell [5][7], will contain the...
I have written this class that will write a JTable to a tab delimited file so that it can be opened in Excel. It works great, but is there any way to make it better or have it directly open in Excel without having to go through the import screens all of the time? How can I tidy up this code to work or operate more effi...
Given a number, this program would find "all permutations of the pairs that add to squares" from 1 to number. E.g: Given an input number of 16, one of the possible answers would be: 8:1:15:10:6:3:13:12:4:5:11:14:2:7:9:16 and its reverse. Note that the function called hasIntegerRoot has been commented out for a purpo...
I'm looking for a design pattern or suggestions that can help refactor my code into something a bit less repetitive. I have a method that has several sequential steps (10-15) that if any of them fail must record detail about the failure to a log and rollback all previous portions of the transaction. The example is belo...
I have written the following Google Spreadsheet script that attempts to loop through all selected cells and then update the value so that it adds an indent, by adding =CONCAT(REPT( CHAR( 160 ), 5),"' + value[row] + '") around the value. Is there a better way to achieve this? var ss = SpreadsheetApp.getActiveSpreadshee...
#include <stdio.h> #include <stdlib.h> #include <assert.h> typedef struct Node NODE; struct Node { int value; int is_leaf; struct Node *right; struct Node *left; }; NODE *new_leaf(void) { NODE *leaf = malloc(sizeof(NODE)); assert(leaf); leaf->is_leaf = 1; leaf->value = 0; leaf->right = NULL; leaf...
Write a program in Java that takes a positive integer and prints out all ways to multiply smaller integers that equal the original number, without repeating sets of factors. In other words, if your output contains 4 * 3, you should not print out 3 * 4 again as that would be a repeating set. Note that this is not ask...
Are all these steps correct and necessary? <?php if (isset($_SESSION['userID'])) { $userID = $_SESSION['userID']; $stmt = $mysqli->prepare( "SELECT usergroup, firstname FROM tbl_users WHERE userID = ? "); $stmt->bind_param('i', $userID); $stmt->execute(); $stmt->store_result(); $stmt->bi...
How secure is this encryption? Secondly, is there something I could do to "turn it up a notch" and make it 'more' secure? Imports System.Security.Cryptography Public Class clsCrypt Private TripleDES As New TripleDESCryptoServiceProvider 'create and return the key and initialization vector hash Private Function Trunc...
I am developing a UI Application for a very simple phone app, the UI is based entirely on the state of Call in a container provided to me by a third party library. Below is a sample Call object that I am working with; public class Call { private boolean isTannoyCall; private long callStart; private int cal...
Below is my implementation of templated Node and LinkedList classes. I would really appreciate it if someone would give me pointers on what I can improve. //LinkedList with SumLists() #include <iostream> #include <set> using namespace std; template<class T> class Node { public: T data; Node<T> * next; No...
Basically I have taken over a project and found a table that has the following video and video title fields in it (why they didn't create a separate linked table is beyond me): [VIDEOURL] [VIDEOTITLE] [COUKVIDEO1URL] [COUKVIDEO2URL] [COUKVIDEO3URL] [COUKVIDEO4URL] [COUKVIDEO1TITLE] [COUKVIDEO2TITLE] [COUKVIDEO3TITLE] [...
The problem was pretty straightforward and used two simple algorithms from our examples; the one for computing the sum, and the one for counting matches. The array for the problem wasn't provided, but you can easily write a method around it without actually having it, since she gave us the name and type of the array. T...
I have some code which works fine. First, it checks that dates format are valid and then, checks that first date is lower than second date. I had to use free input text and custom validator because multiple date formats are supported such as quarter number (2014 Q1) etc. But I find my code too long for what it's doing....
I am working through Kernighan and Ritchie to brush up on my C skills, so I thought I would invite critiques of my code. Here is my Hex-to-int function: int htoi(char *str, unsigned long long *result) { int c; int i; int msnibble; int digits; const int nibbles[] = {'\x0','\x1','\x2','\x3', \ ...
I have been working on a project and I'm actually refactoring some code. I have encountered myself with lots of foreach and if statements, which could be easily replace with LINQ. But I have this code snippet, that I wonder how I could make it more functional style. foreach (var notification in notifications) { if ...
Here is the code for the CString class that I created. public class CString { public String reverse(String s) { char[] array = new char[s.length()]; array = s.toCharArray(); for(int i=0; i<array.length/2; i++) { char tmp = array[i]; array[i] = array[array.length-1-i]...
I have \$k\$ sorted Lists, each of size \$n\$. Currently I have hard-coded 5 sorted Lists each of size 3, but in general that is configurable. I would like to search for single element in each of the \$k\$ Lists (or its predecessor, if it doesn't exist). Obviously I can binary search each List individually, resulting ...
In this assignment, I'm supposed to split a string using strtok. (The assignment consists of the comment and the function definition; I fill in the function body.) It works as far as I've tested. But it seems a little ugly to me. Perhaps it's my Java background, but somehow this just doesn't feel right. Specific concer...
I am now writing a small bash script that updates an Intel NIC driver to the latest version from the official website. Is there any way to improve\simplify the script? I want to avoid a lot of "if...else" stuff. Helpful tips will be appreciated! #! /bin/bash DRV_PKG_NAME="e1000e-3.0.4.tar.gz" DRV_PKG_URL="http://downl...
I have an ASP.NET MVC 5 web application using the repository pattern, and I have several controllers that need to call my _loggingService (queries audit logs) to get the last updated information for certain pages, not all pages. I want to abstract this method into a common place, so that I don't have duplicated code in...
The below code is for printing level-by-level in a binary tree: //level order printing public static void levelOrderPrint(Node root){ Queue<Node> que = new LinkedList<Node>(); Node mark = new Node(0); if(root != null){ que.add(root); que.add(mark); } while(!que.isEmpty()){ No...
Things I can think of include integer overflow, if the input type is int, etc. But other than that, what do you think is wrong with this code, design-wise, style-wise, and also in terms of other edge/corner cases? binaryheap.h #ifndef INCLUDE_BINARYHEAP_H_ #define INCLUDE_BINARYHEAP_H_ #include <vector> #include <iter...
The following is an TaskScheduler that always run tasks in a thread it maintains. When created, a name of the thread was specified. Once you schedule the first task, until it is been Disposeed, a thread will be created and wait for tasks to execute. The reason of this class is that sometimes there is a need to guarante...
I build phone apps and I use JSON a lot in my APIs. The problem is sometimes I don't know how to format the JSON data. For example, an iOS UITableView takes NSArray as datasource. { "contact_id": [ "455", "464" ], "contact_name": [ "Administrator", "Main contact" ] } For...
I was asked this interview question recently. I was able to come up with this which runs in \$O(k \log n)\$. Given k <= n sorted arrays each of size n, there exists a data structure requiring \$O(kn)\$ preprocessing time and memory that answers iterated search queries in \$O(k + \log n)\$ time. I have k sorted Lists,...
I'm working on extending the functionality of a photo gallery by adding a thumbnail display, I have multiple if statements set up to adjust the position of the thumbnails. Obviously this is not ideal, I'm trying to put my head around how to use a for loop to iterate the width multiplier and curSlide position. Ideally I...
I've written a function that works fine, but being new to jQuery, I'd like some reviews on writing this more cleanly. Anything advice would help; just trying to learn! function displayContent() { var $link1 = $('.row.nav li a.bio'); var $link2 = $('.row.nav li a.stylist'); var $link3 = $('.row.nav li a.contact');...
I am using Netty embedded within Grails to process and display incoming SNMP messages. Since Netty 4 doesn't come with a built-in ChannelExecutionHandler I had to make my own and would like some feedback on it. package org.ciscotalk.common.netty; import io.netty.buffer.ByteBuf; import io.netty.channel.*; import io.net...
The following Java code reads lines from an input text file and will output the entry that has the highest number in field-2 to an output file: INPUT: William J. Clinton 6 Q1124 42nd President of the United States 6 Q1124 Bill Clinton,6,Q1124 Bill Clinton,14,Q9890 Bill Clinton,5,Q9880 William Jefferson ...
Header file: #include <stdio.h> #include <stdlib.h> #include <assert.h> typedef struct linked_list linked_list; typedef struct cons cons; void append(cons *cons, int value); void linked_list_append(linked_list *ll, int value); int size(linked_list *ll); void insert_after(cons *c, int value, int index, int current); v...
I have the following code for the Rock, Paper, Scissor game. The code works fine in Python 2.7. Are there other more concise, more readable, or more pythonic ways of solving this problem in Python? player1 = raw_input ("?") player2 = raw_input ("?") if (player1 == 'rock' and player2 == 'scissors'): print "Player ...
Review this code. mode = "PARALLE" try: if mode == "PARALLEL": # some code - this will not raise ValueError elif mode == "SERIES": # some code else: raise ValueError("Error: Invalid mode") except ValueError, Argument: print Argument phase = "inverte" try: if phase == "inverted": ...
Call from my index.php to function get_data($curr_date) goes from here case "events" : $curr_date = $_POST['current_date']; if ( $eid = get_data($curr_date) ) { $result = array( "success"=>true, "e...
I have a Ruby code segment which I need to DRY up. Can it be done without meta programming? def disable_attribute statement1 @response = Client::Service.disable_attribute( param1: param1value, param2: param2value ) statement2 end def enable_attribute statement1 @response = Client::Service.enable...
I wrote this function as part of interview practice. This method removes a character from a given string. I was wondering how I could make this code more efficient when it comes to runtime/space. I think my code is O(n) and I'm not sure if I can increase the efficiency. However, perhaps using things such as StringBuffe...
This is an algorithm I'm trying to optimize. I was trying to use openMP without any success. I know the code is long but most of it is params init. Please try to explain why I need to change any line of code. I want to learn. I also wish to understand if using openMP is the best way for matrix based algorithms. void ...
I made a PHP mailer script does the basic validation of fields, return errors, else submit if all is good. But it also has a honeypot field that is not required to be filled in (I'm assuming by hiding it using CSS a spambot will fill in the field anyway). If the field is not empty, it opens a text file and writes/appe...
import java.util.*; import java.io.*; public class Player { Scanner read; PrintWriter write; private String playerid; private int playerscore; int x = 0; ArrayList<String> n = new ArrayList<String>(); ArrayList<Integer> s = new ArrayList<Integer>(); Lis...
I've refactored the string calculator kata as much as I could and tried to maintain single responsibility. Is there anything I could factor differently? The specs can be reviewed here. module StringCalculator def self.add(string) string.end_with?("\n") ? fail('ends in newline') : solve(string) end def self.s...
I'm trying to reduce the complexity of some methods, and I'm not exactly sure what approach to take. I'm currently building a PHP wrapper for a REST API, and the main problematic class is here: https://github.com/petrepatrasc/blizzard-starcraft-api/blob/master/Service/ApiService.php In short, since data retrieved from ...
I have some PHP code I'm working on which contains 2 queries and I need to set extra conditions for 2 out of 3 view options and one less query for 1 out of 3 view options. Basically, I'm rendering a history list of shows with three options ALL | PRO | UPCOMING. The ALL option should include both queries and have no ext...
Things that I'm not sure about: Whether this works in all use cases - alongside routing and within templates etc Am I polluting the scope with all these variables? This seems to be the easiest way to do unit tests - or should I be passing the vars into the function? Some ( documentHeight, USerScrolledTop, userScrolled...
For several months I'm working with JavaScript and THREE.JS library. Firstly I dislike the prototype-based programming because I have to work a lot of with class-oriented languages, where any class is represented as the type and there is a strict separation between declaration and behavior of program design. But, I und...
Is there a better way to do this kind of array combination with a PHP native function like array_combine? I'm trying to improve my skills, and at certain points I note that I am using too many nested foreach for almost everything. Using PHP 5.4 $array = Array( 'GroupName' => 'Emilio', 'Moduleid' => Arr...
In reviewing code in our application, I see a tension between what makes a convenient design for methods accessing database data versus coding to ensure that the JDBC resource objects are closed properly. An example problem: // Application.java: Singleton class for objects which want to execute SQL queries /** * Exec...
I have the following key value pair in an array, and am trying to extract and load them into a collection. The below code is working but it can be optimized using Linq: string _data = "Website=url:www.site1.com,isdefault:true,url:www.site2.com,isdefault:true"; List<WebSiteAddress> _websiteList = new List<WebSiteAddres...
I wrote a program for one of my Object Oriented Programming in Java classes(Program 2) and I got docked off because my method was too long, which I'm not complaining about. I got the note: "Modularize more, method too long." I was wondering what any of you more experienced programmers would do to simplify/shorten my co...
I validate this program for Non numeric inputs x/0 type fractions 0/0 and 0/y type fractions x/1 and x/x type fractions -x/-y and x/-y type fractions I'd appreciate it if someone can look at this code and tell where I can improve this coding. I'd also like to know about other validations best practices I can use or ...
This is the requirement I have (from the book: Cracking the Coding Interview) Imagine you have a call center with three levels of employees: fresher, technical lead (TL), and product manager (PM). There can be multiple employees, but only one TL or PM. An incoming telephone call must be allocated to a fresher who is...
Some time ago I made my simple game loop, so here's the code: public class Game { private final int TARGET_FPS = 60; /** optimal waiting time in milliseconds */ private final long OPTIMAL_TIME = 1000 / TARGET_FPS; /** last Frame time */ private long lastFrame; private int fps; /** last FPS...
I've been considering the pro's and con's between implementing my page objects with privately backed properties and lazily instantiating them or just returning new instances every time and am curious what other people think is the best practice. For example, I could have something like; private IWebElement title = ...
I'm using jQuery's .get() method to load content from external HTML files into my main index file. I created 25 different functions, function videoLoad1(), function videoLoad2() etc, for the 25 videos that I'm loading separately when its corresponding link is clicked. The content that is being swapped out in my HTML in...
Currently I have a binary tree template setup where my main is using it with strings to make a question/answer game. I'm using a knowledge base that works as an interface to the binary tree that main uses. My code seems to work fine inserting/rearranging nodes as necessary but I think my design is pretty bad. Is it usu...
I'm trying to implement a bunch of sorting algorithms in JavaScript, and I can't figure out why my shell sort is so slow. It's 6x slower than my merge sort, and only slightly faster than my insertion sort. I've seen another implementation online, but I'm more focused on making it clear and readable (as I have a blog fo...
I got really tired of having this code in all of my classes and methods: public class SomeClass { private static final Logger LOGGER = Logger.getLogger(SomeClass.class); //... public int someMethod() { final String methodName = "someMethod()"; LOGGER.debug("Entering " + methodName); ...
I have a few if, else-if, else clauses. The only different thing in the context of these clauses is my LINQ query, one clause has StartsWith, one clause has Contains, and the other does a simple match. Is there a way to have all of this in one clause and somehow create a variable that can change between StartsWith, C...
I want to have a caching class to cache different types. I want each type to be cached in a different MemoryCache but in a generic way. Am I doing it right? internal static class RecordsCache { private static Dictionary<string, ObjectCache> cacheStore; static private CacheItemPolicy policy = null; static...
I have a signup form in which the user has to enter the email address and after some quick asynchronous processing at the backend I have to tell the user that whether the email address is already registered or not. Below is a sample example of the JSP page that I have created, <input type="email" id="inputEmail" placeh...
I wanted to play around with the following idea: Give a paragraph, I wanted to find out the relative frequency of usage of each of the five vowels. I wanted to plot a pie chart depicting this. Here is my code: from sys import stdin from re import sub import pylab DataToRead = stdin.read() VowelData = sub(r"[^aeio...
Earlier I posted a question about model simulation, now I have code for model 'spatial' representation. My model consists of moving parts that can perform actions and each part occupies space within the model. I would like to use a graph to to represent relationships between model parts. ISpace defines methods for work...
I previously attempted to make a C++ vector here, yet it was not very successful. Now I have made a basic reimplementation of it, so I'm checking that it is fine, and that I will not have to re make it again. Note: I also implemented an allocator class, but it works the same as the std:: equivalent. template < typename...
Do you see any inefficient parts with the following code? On internet I see 30 ms for 100.000 integers but I can sort 100.000 integers in 300ms. The data is random. I am using late 2013 macbook pro so I don't expect a 10x slowdown from CPU, but who knows. void mergesort2(int* list, int begin, int end,int *tmplist=0){ ...
Write the program tail, which prints the last n lines of its input. By default, n is 10, let us say, but it can be changed by an optional argument, si that tail -n prints the last n lines. The program should behave rationally no matter how unresonable the input or the value n. Write the program so it makes the...
This is the situation : the table order has a column with ID AUTO INCREMENT but (there is always a but) i can't use it because i don't want number order 1234567 after 5 years but i want 1/2014 , 1/2015 etc etc. For doing this i have created this columns into the table : ID AUTO INCREMENT <--- unique ID used for manage ...
I am writing a wrapper to Eigen QR for my personal use and I am wondering if there are any memory leaks or undocumented behavior in my implementation, especially in the function get_QR(). The answer is as expected. This is related to my previous question here. using std::cout; using std::endl; using namespace Eigen; /...
I have recently adapted the popular leanmodal plugin (with permission). Being "intermediate" with JS (need to learn more), I was wondering if anyone would like to review my code for efficiency. jQuery & JS - bad practice? Functions - structured correctly? Repetition - When using logic, I repeat nearly exact code - ba...
I have code that works perfectly, but it uses too much memory. Essentially this code takes an input file (lets call it an index, that is 2 column tab-separated) that searches in a second input file (lets call it data, that is 4-column tab separated) for a corresponding term in the 1st column which it then replaces with...