instruction stringlengths 71 39k |
|---|
I have a representation for each initial shape as an Enum with points and another for each rotated shape in the same Enum.
Here is an example of the latter Enum:
//
// * *
// *
// *
J_SHAPE_SOUTH(new Point[] {
new Point(2, 0),
new Point(2, 1),
new Point(2, 2),
new Point(3, ... |
Over on StackOverflow, I was asked if I could come up with an example where private inheritance would be preferred to composition (in C++). The following is the situation I described, and I was wondering which implementation you would prefer. Most of the references I've found to private inheritance are poor uses, and... |
I've got a method that parses a file. I take all the words and add them to a SortedSet. Every word contains a list of Lines that contain said word. Words are not strings but a class I created:
class Word : IComparable<Word>
{
public Word()
{
Lines = new List<Line>();
}
public string WordStr {... |
I have written a simple web-scraper in Common Lisp, & would greatly appreciate any feedback:
(defpackage :myfitnessdata
(:use :common-lisp)
(:export #:main))
(in-package :myfitnessdata)
(require :sb-posix)
(load (merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname)))
(ql:quickload '("drakma"
"c... |
As a Python newbie, I have coded this binary tree as best as I could to follow Python
idioms. However, I know it is still very verbose and not up to standard. I would like Python experts to tear this apart and identify its weaknesses.
class TreeNode(object):
""" applicable to all tree nodes including root node """
... |
I've got a list with about 120 items in IE and I have some items I want to activate. I compare, build and randomize some Arrays on the fly. The for loop in the run() function is really slow, and i tried to add a setTimeout(), like i've read somewhere on stackoverflow.
It does not seem to improve the performance, and if... |
I noticed a pattern in some elisp modes I was putting together:
(let ((map (make-sparse-keymap)))
(define-key map KEY 'FN)
...
(setq FOO map))
so I wrote up the following macro
(defmacro def-sparse-map (name &rest key/fn-list)
`(let ((map (make-sparse-keymap)))
,@(loop for (key fn) on key/fn-list by #'cdd... |
I'm a hacker, not a trained engineer. I ask/answer specific questions on StackOverflow and am pretty confident in my ability to get the browser to do what I want, I thought I could benefit a great deal from a code review- hopefully I'm in the right place.
Please tear down my bright-eyed naivetie with cutting comments ... |
Could someone review the following code?
class PigLatin
attr_accessor :phrase
ending = "ay"
def initialize the_phrase
@phrase = the_phrase
end
def translate
translated_phrase = String.new
words = @phrase.split
words.each do |word|
puts word
if vowel_is_first word
transla... |
I am trying to update my server to let it know that the user had some activity in the past 15 minutes. In order to do that, I made this implementation:
var page = {
updated: false,
change_state: function(e) {
var self = this;
if(!this.updated){
debugConsole.log('Moved mouse');
... |
import random
import rlereader
class Board:
"""Handles the status of all cells."""
def __init__(self, size):
self.size = size
self.grid = self.make_blank_grid()
self.furthest_col = 0
self.furthest_row = 0
def run_turns(self, num_turns):
"""Run a the simulator for ... |
I need to extend the default TextWriterTraceListener class to include timestamps with each message on same line and file rotation. I can't seem to find any way of doing it with TraceListener configuration.
Can you please review it and let me know any flaws to be used in a multi-threaded application?
using System;
using... |
I'm posting my PHP code for sessions using MySQL. Please tell me if there are any errors, if it can be optimized, or if security can be enhanced.
Host: localhost
User: root
Password: ""
Database: pro
Table structure:
SessionID [pk] - Data - DateTouched
<?php
function open($sess_id, $sess_name) {
return true;
}
... |
I'm a beginner-intermediate C++ programmer, and I never used or understood C input & validation. I just always used C++ streams.
Anyway, I just want code critique, as I have never used the C input functions (I admit, I have used and like printf()! I even made my own sprintf(), compatible with the C++ string class.)
I ... |
I've just written this Twisted resource base class for serving files. It's part of a larger application, this is just for serving its images, JavaScript files, etc.
Is it okay? I wonder if checking for .. in the path is enough -- all the files that exist in self.directory are intended to be served, to anyone, so this s... |
I am new to the world of coding, PHP as well as XHTML. As my first stab at object oriented coding, I put together a basic registration form that is meant to serve as a means to collect user details.
What this form does not do is the following;
Capture information is a file or database as I have not yet gained enough e... |
At my work, I need to create a script that third-party webmasters could include in their pages without need to include something else. But this script had dependencies on jQuery and some amount of their plug-ins.
On the Internet, I have found libraries that have same functionality except for an important one: they don'... |
I am trying to learn OOP using PHP5 and I wrote a simple MySQL connection class. Please take a look and give me some feedback on better practices, critical errors, and any other feedback you can provide.
Note: in the verifyDatabaseConnection method, I used an @ symbol to curb the error I was receiving.
<?php
class Mysq... |
I have designed the code but the problem is it timeouts as the range is 1000000000 but works fine with 1000. Any idea to optimize this or a mathematic logic for it? I just need to find the no of pairs(a,b) such that a < b and a*b % a+b == 0 if a range is given,
eg: 15 - o/p 4 as (3,6)(4,12)(6,12)(10,15).
php code:
$co... |
I tried putting a script i saw together, plus used an existing script to make something run as a service. Now I have the following pl script and the init.d / start/stop scripts.
They work, but I am wondering if I did it right, because when I start the service and i would start it again, it would just start again and gi... |
Anyone want to comment on this plugin I'm making? (improvements, etc)
(function($) {
var methods = {
init: function(data) {
var options = {
function: null,
timeout: 1000,
option: undefined
}
return this.each(function() {
... |
As a personal challenge, I am trying to make a very basic calculator without using any CLR's integer and arithmetic operations, but to only use memory.
The idea was to do what CLR/OS does. i came up with a basic counter, Addition and multiplication, which works fine but multiplication takes long time to compute (if i ... |
Please help me improve this function that compares the jQuery version currently available (or not) with the one required.
function(need) {
if (typeof(jQuery) != 'undefined') {
if (!need) return true;
var re = /(\d+)\.(\d+)\.(\d+)/,
cur = re.exec(jQuery.fn.jquery),
need = re.e... |
I want the fastest way in Mathematica 7 to generate a list of the factors (not prime factors) of an integer into a specified number of terms, with each factor greater than one.
For example, 240 into three terms:
{{2,2,60}, {2,3,40}, {2,4,30}, {2,5,24}, {2,6,20}, {2,8,15}, {2,10,12},
{3,4,20}, {3,5,16}, {3,8,10}, {4,4,... |
Requirement: Parse a String into chunks of numeric characters and alpha characters. Alpha characters should be separated from the numeric, other characters should be ignored.
Example Data:
Input Desired Output
1A [1, A]
12 [12]
12G [12, G]
12ABC-SFS513 [12, ABC, SF... |
Beeing on .NET 3.5 i don't have access to the TPL. Yet i have become fed up of having to manage manually the logic behind delegate.BeginInvoke type of scenarios each time and i set up to implement my own Task class.
Functionality it should support:
starting a parallel execution (using
a thread pool thread)
capable of... |
About a week ago, I put up this code and got some really good help. I've modified it a bit and was seeking if someone would review my second iteration. Original can be found here.
Here's the new stuff. Basically, I stuck it all in a module, added support for the option of a dash or no dash. And gave it the ability t... |
I am wondering if this code will work in 10.1.
This video at 1:02 says not to create mxd based services. I think that just means not using IMapServerObjects3, but seems like IMapDocument should be OK.
#region IServerObjectExtension Members
private IPageLayout m_Layout = null;
public void Init(IServerObjectHelper pSOH)... |
I found a SERP checker written in PHP and I decided, in order to better learn to program, I would re-write it in Ruby.
All I have written so far takes a list of keywords that a user inputs and cleans the list and turns each keyword into a url for Google search.
Here is the code:
require 'sinatra'
require 'rspec'
get '/... |
With some advice from SO, I developed this system, which I think is quite strong for bots to automatically post comments.
index.php
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script>
function main()
{
var str=$("#key").load("getToken.php",function (responseText) {
... |
I want to perform a search in several columns of a table. I use the following query:
select *
from Tabela t
inner join "TabelaPai" tp on tp."ID" = t."RefTabelaPai" and tp."RefProject" = 'projectid'
where not t."Deleted"
and (t.Col1 ~ '.*__param1__.*' or t.Col2 ~ '.*__param1__.*' or t.Col3 ~ '.*__param1__.*'
or t.C... |
I am 100% self-taught, and so I try to read as much as I can about best practices, conventions, etc. However I freelance, and have been in a long-term contract position for the past little while with almost no peers to review my code. So I get nervous about developing bad habits.
Looking closely at this function I wrot... |
This function computes and returns the number of divisors an integer has. But it is very slow and I believe it can be optimized for speed.
unsigned long long int find_no_of_divisors(unsigned long long int myno,FILE *ifp)
{
unsigned long long int divsrs = 2;
unsigned long long int k = 2;
if(myno == 1)... |
I think that the slice() is a bit hacky, and prone to breaking if I change my mind about the id names, but I wanted this to be generic so I could add types easily.
Is there maybe another / better way to do this just using CSS nesting the 'panels' inside the li elements?
Markup:
<ul id="type-select">
<li><a id="t... |
I am looking to optimize the following computation. First, some explanations:
Explanation
I have a directed graph whose adjacency matrix may only contain 1s and 0s. The similarity of nodes i and j is defined as follows:
count how many nodes have an edge pointing to both i and j, and count how many nodes do both i an... |
I use the following code to put all of my error messages for the application in one javascript variable. Is this efficient way to store my error messages?
var cosmoBase = {
messages: {
empty: "Please enter ",
numeric: "Please enter a valid number for ",
date: "Please enter a valid date for "... |
How do I handle multi-tenancy with routes in ASP.NET MVC?
The application is a multitenant ASP.NET MVC 3 application. Tenants are identified based on hostname so this does not interfere with routing.
Other important information:
The application has a number of features (or plugins). These are essentially other web pro... |
I have posted an earlier version of this and here is the improved version from the feedback I recieved. Some of the feedback I received was;
Don't chain method (tried my best to limit this)
Do not use print() or die() and an error response (still a little lost, but I did attempt to use a redirect to a custom error pag... |
Here's some explanation for accuracy and neg_accuracy:
It's meant to keep all the values in terms of what the user specified he wanted (how many decimal digits deep they want to go). accuracy is meant to cut the huge number returned by GetTickCount() to size, and neg_accuracy actually turns it into a decimal by dividin... |
I'm building a navigation that has a breadcrumb with drop down menus. I want the menus to open up when I click the open link, then there are many instances when the menu should close:
The link is clicked a second time, with the intention of closing the menu
When another menu is open, the first menu should close
When a... |
I have been working through the exercises in a Write Yourself a Scheme in 48 Hours/Parsing and hacked together something to get parseString to comprehend escaped characters. Also had some inspiration from Real World Haskell chapter 16 minus the applicative parts.
parseString :: Parser LispVal
parseString = do char '"'
... |
Suppose you have a list of the diameters of some circular holes, and a list of the diameters of some cylindrical pegs. Now the problem is finding all the ways you can fit the pegs in the holes, where the order in which you put them in doesn't matter, and it's OK to put a peg in a hole that's too large.
I've written the... |
I have \$ N^2 \$ matrices. Each one is a \$ 3 \times 3 \$ matrix. I want to concatenation them to a \$ 3N \times 3N \$ matrix. I know that the big matrix is symmetric. Evaluation of whole \$ 3 \times 3 \$ matrices are time consuming so I want to speed up my program.
Do you have any suggestion to speed it up?
clc
loa... |
Here's my function but it sometimes has unpredicted results with entering different numbers but with the same number of digits getting different results. I figure it has something to do with a computers inaccurate decimal saving tecnique but i would like to know how to make it more accurate.
/////////////////////// ... |
This is a quick script I whipped up to collapse some folder trees down to individual folders. The specific situation that arose was my formerly-itunes collection (it's currently organized Music\artist\album\songs.(mp3|m4a) and I'd really prefer it to be Music\artist\song.(mp3|m4a)).
#!/usr/bin/ruby
require 'optparse'
... |
Traverse a binary search tree in iterative inorder.
Note that the iterative methods below contain the meat of the code; the remaining code is included for completeness.
// tree node
struct node
{
int elem;
node *left, *right;
// Statically create a node, given an element
static node* create(int el... |
I am writing a simple raytracer just for fun. I want to iterate over rows, and each row must be an iterator over columns. A strategy I produced is the following:
class ViewPlane(object):
def __init__(self, resolution, pixel_size, gamma):
self.resolution = resolution
self.pixel_size = pixel_size
... |
How can I improve this PHP MySql Rank generation function?
(Mostly looking to improve speed, but any feedback is very welcome)
Right now I keep stats and ranks in 2 separate tables. The only problem with this is I don't know how combine the select and update queries to possibly increase speed by cutting the PHP proces... |
private string FormatComments(string comments)
{
//If comments has no space and inserted as a single line then following code will break
//the comments into multiple lines.
StringBuilder sb = new StringBuilder();
int c = 65;
int l = comments.Length;
if (l < c)
... |
I had to find the corresponding process for a windows service the other day, and I kept on getting this one exception. I've spent some time researching the exception only to find that this exception will occur if the process is terminating, Hence my question, is it really that bad to catch expected exceptions ?
Sample ... |
This is an emulator I am currently re-writing for my Operating Systems course. It is a simple emulator that is supposed to represent hardware, OS, etc. It is strictly for learning purposes and I want to propose my solution to the teacher as a method of modern C++ (since his solution is more "C with classes").
However,... |
Before I tried to avoid using cursor because of performance issues. But now I have to do some calculations to reach some goals. I have a stored procedure that has a code like this:
DECLARE Outer_Cursor CURSOR FOR...
OPEN Outer_Cursor
FETCH NEXT FROM Outer_Cursor INTO ...
WHILE @@FETCH_STATUS = 0
BEGIN
... |
I need to implement a TCP client application. The client and the server send messages to each other. I want to make this program scalable enough to handle connections to multiple servers at the same time. It seems like asynchronous sockets is the way to go for this. I'm new to C# so I'm pretty sure I don't know what I'... |
I need some thoughts about an approach a colleague and I am are taking with Entity Framework. Basically, the entities are represented by contracts. These contracts hold a collection of business rules so when they are finally persisted we know they are valid. We can also check the validity from Entity Framework, but tha... |
After solving the error in SO (like suggested) I return now for codereview. :-)
The task is to parse a huge file dblp.xml (~800 MB) presented by DBLP. The records in this huge file do look for example like this or this. In particular:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE dblp SYSTEM "dblp.dtd">
<dblp>
... |
Can i refactor these code ?
The diffrent between these block of code are.
They are using different casting type.
They call different property
var objBillOfMaterialRow = (MISheetDataSet.BillOfMaterialRow)pObjDataset.Tables["BillOfMaterial"].Rows[0];
if (objBillOfMaterialRow.mi1_BillOfMaterial == ShowReport.Fa... |
I often use C API's in C++ that force me to use C-style arrays. I got sick of constantly using a dynamic vector with &vec[0], so I wrote this C-style array container. Please review and give suggestions.
I also have one question: is my implementation of swap correct? My biggest worry is swapping two C-style arrays with ... |
This program converts Brainfuck source code to C and compiles it with gcc.
It runs very well (that was my first time I played Lost Kingdom), however, the code is quite long because some parts are repeated.
Is there a way to reduce the code? What about the "optimization" method? Can this simple optimization be improved?... |
I have written the following code that tests if the current time is within a time window. It seems to work ok with my test cases, but I would be interested if anyone can see any possible problems or has any ideas for improvements?
Public Function IsCurrentTimeBetween(ByRef dteStartTime As DateTime, ByRef dteEndTime As ... |
This works:
$('#ShowAll').click(function() {
if ($(this).prop('checked')) {
$('tr.hidden').show(); // todo: There's probably some clever toggle that could be used here.
} else {
$('tr.hidden').hide();
}
});
Is there a one-liner I can be doing instead?
When the user clicks on the ShowAll che... |
I'm still pretty new to Ruby, and am really enjoying the language. I came across this method in my code base and realized that it could be cleaned up:
def friend_all_followers(friends)
client.followers.each do |follower|
if not friends.include?(follower.screen_name)
friend = Friend.new(:screen_name => follo... |
From SICP:
Exercise 3.8
When we defined the
evaluation model in section 1.1.3, we
said that the first step in evaluating
an expression is to evaluate its
subexpressions. But we never specified
the order in which the subexpressions
should be evaluated (e.g., left to
right or right to left). When we
intr... |
I have a function that is suppose to store variables based on their datatype, and this is table I have come up with to store those variables into.
Is it smarter to have everything broken down like this or would be wiser to only have columns for the largest for the largest datatype of a group (such as string datatypes o... |
I've got a couple of utility functions to support memoization for functions with anywhere between 0 to 8 arguments:
Public Shared Function Mize(Of TResult)(ByVal input_f As System.Func(Of TResult)) As System.Func(Of TResult)
Dim is_new = True
Dim result As TResult
Return Function()
If is_new ... |
I have this set of legacy C++ projects with a large number of public functions. At the start, none of those publicly exposed functions had try..catch insulation inside them. When a C++ exception fired across that boundary, if the caller wasn't compiled with the same C++ compiler and the same project settings, then it... |
This is exercise 5-4 from K&R. I spent hours tweaking it but now it seems to work. I'm new to pointers and I'd welcome any comments about how to do it better.
/* Function strend(s, t), which returns 1 if the string t
* occurs at the end of string s and zero otherwise */
int strend(const char *s, const char *t)
{ ... |
I would like to efficiently import real numbers stored in CSV format into an array. Is there a way to modify my code to make it faster? Also, is there a way to scan the file and compute the number of rows and columns rather than having to provide these directly?
double * getcsv(string fname, int m, int n){
double... |
Today, I came across a code example like the following:
Option Explicit
Sub MySub()
Dim iCount As Integer
For iCount = 0 To 100
Debug.Print "Arbitrary Code Here"
If iCount Mod 2 = 0 Then
Dim myString As String 'This is the line I'm curious about
myString = iCount
... |
From SICP:
Exercise 3.18. Write a procedure that
examines a list and determines whether
it contains a cycle, that is, whether
a program that tried to find the end
of the list by taking successive cdrs
would go into an infinite loop.
Exercise 3.13 constructed such lists.
I wrote the following (revised) so... |
From SICP:
Exercise 3.22. Instead of
representing a queue as a pair of
pointers, we can build a queue as a
procedure with local state. The local
state will consist of pointers to the
beginning and the end of an ordinary
list. Thus, the make-queue procedure
will have the form
(define (make-queue)
(let... |
I'm trying to solve an old GCJ. It's a very simple puzzle, but I'm trying to sharpen my Scala-fu.
Basically, you're getting a list of triple number srcLanguage dstLanguage, where number is an integer given in the numeral system of srcLanguage. You should translate it to the numeral system of dstLanguage.
A numeral syst... |
I have written a recursive function that I believe will return the 'maximum' row of the 4x4 matrix it is fed. By 'maximum' I mean that the maximum row of the matrix.
1 2 3 4
2 3 4 1
3 4 1 2
4 1 2 3
is row 4 (on account of the first column's values); the maximum row of the matrix
1 2 3 4
2 3 4 1
4 4 1 2
4 1 2 3
is row... |
I just want to see if any part of one "rectangle" overlaps the other.
Is this the correct code?
bool checkCollide(int x, int y, int oWidth, int oHeight, int x2, int y2, int o2Width, int o2Height){
bool collide;
collide = false;
if(x >= x2 && x <= x2+o2Width && y >= y2 && y <= y2+o2Height){
collide... |
This is a plug-in which tracks your online activity aka a lifestream. You're currently able to use feeds like:
Delicious
Flickr
Github
Google Reader
Last.fm
Stackoverflow
Twitter
Youtube
At first I decided to load all the feeds at the end of all the asynchronous requests. This only required one DOM request at the end... |
I am a Java dev and trying to prepare for interviews in C++. Can someone please review the below solution for me?
Assume that you are given the head and tail pointers of a doubly linked list where each node can also have a single child pointer to another similar doubly linked list. There are no cycles in this structur... |
Please suggest improvements in the following java program I've written for producer-consumer scenario. The program seems to be working fine. Does it suffer from possible deadlock scenarios? How better I could have done this? Since I am using Stack read/write (push/pop) already been synchronized? What if they do not?
im... |
Consider the following two code examples:
1.
void foo(boolean cake) {
if (!cake)
return;
// TODO some work.
}
2.
void bar(boolean cake) {
if (cake)
//TODO some work.
}
Which one is the most readable/ semantic correct? With the first example you avoid additional indentation on the below c... |
I'm making a simple text game using the pdCurses library and a few other minor things like a vertical scroller in which you avoid the randomly-generated walls.
There are two walls on left and right made out of 'X' characters and blank, black space in which you can move around and avoid the 'X's your character is an '8'... |
I need automatic dependency generation to be done in my makefile. So, I have tried to write one, after googling for similar ones. I have found some ways to do that, but the problem is that they are usually too complicated for me (because of usage of sed command etc. and I want a way for me to create a makefile without ... |
This is a revisit to a question already asked here about a year and a half ago.
Project Euler's Problem 40 involves generating the sequence of digits that appear in the natural numbers, all concatenated together (123456789101112131415161718192021…). As part of the solution, I wrote this:
def counting_digits():
fo... |
I'm fetching a string that is JSONP, and looking to convert it to JSON.
I'm using the following regular expression for matching (for removal) the padding on the JSON.
([a-zA-Z_0-9\.]*\()|(\);?$)
In python, here's the line I'm using for converting the JSONP to JSON:
apijson = re.sub(r'([a-zA-Z_0-9\.]*\()|(\);?$)','',... |
I'm pretty new to C so I decided to implement SRFI-1 (linked-list library) to help me learn.
What I have so far is working, but only handles integers.
typedef struct pair {
int car;
struct pair *cdr;
} pair;
From what I've read I can use a void * for the car:
typedef struct pair {
void *car;
struct pair *cdr;
... |
I hate this code. What is the slickest way to write the following:
MyFile = f;
SaveFolder = Server.MapPath("\\") + "returns\\";
if(!System.IO.Directory.Exists(SaveFolder) )
{
System.IO.Directory.CreateDirectory(SaveFolder);
}
MyFile.SaveAs(SaveFolder + "2011" + "000-00-0000" + ".xlsx");
|
I'd really appreciate some harsh/constructive criticism of what I would consider as my first program in Haskell. The program should download all of the xkcd comics into a folder in the current directory.
I basically just threw the kitchen sink at it, using anything I found remotely interesting in RWH and on the Haskel... |
I'm looking for any comments or feedback on my database access class. Security and speed are two things I'm most concerned about.
One thing to note is this class has to work in a C# .NET 2 environment, so anything that's more modern would be interesting to me, but please note in the title of your answer if the comments... |
I am new to the world of coding as well as CSS. This is my first attempt to put together what I would consider a fully-pledged page less the content. I would appreciate if you could poke holes at it and let me know what I could have done better as well as what I should consider doing in the future.
NOTE
The file does... |
I've made a simple wrapper for MySQLi_STMT, allowing the usage of placeholders and spares you the need to manually bind variables. The full code is at the bottom of this question (it's quite large, with comments). Please give me feedback/criticisms on anything you want (readability and API design for starters).
Usage:
... |
I am trying to create a web app (CMS) as part of my research project, and I use the code below to load modules into a page. Please review this code.
public function LoadModule($module,$position){
if(file_exists('modules/'.$module.'.tpl'))
{
//todo: might have to get a better thing for this !
$... |
I've been learning to program in Java and I decided to implement a doubly linked list as practice and as a bridge project before going on to learn C++. I know Java includes a LinkedList implementation, but I wrote this for practice. I have finished the code and it works correctly. However, I'd appreciate some feedback ... |
Wondering if I could do this a little bit better. Currently, my DAL has a blank constructor that sets the connection string from the web.config.
private string cnnString;
public DAL()
{
cnnString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
}
Then each method in here is mapped... |
Overview
I've written a class that will create C# code. The output is a single .cs file for each table in the default database (the database is defined inside a web.config file). I'm looking for a code review on this class alone, not on the generated code. This DatabaseClassCreator class uses the DatabaseAccess class f... |
I have two tables, one for jobs, and one for the names of industries (e.g. automotive, IT, etc).
In SQL I would just do:
SELECT industryName, count(*)
FROM jobs
JOIN industry
ON jobs.industryId = industry.id
GROUP BY industryName
In LINQ I have the following, but it's three separate statements and I'm pretty sure this... |
I am trying to create some (I believe these are Integration not Unit) tests for code that interacts with a database and I am not sure this is the right approach.
I would appreciate any reviews and possible improvements.
Using: VS2010 Unit Testing Framework
This is the function I want to test:
public IDbConnection OpenT... |
I have a database that I need to query over and over as fast as possible. My queries execute pretty quickly, but there seems to be some additional lag. I have a feeling that this lag is due to the fact that I am initiating and de-initiating a connection the connection each time. Is there a way to avoid this?
I am not u... |
long long combine(unsigned int high, unsigned int low) {
return ((unsigned long long) high) << 32 || low;
}
Is there a better name for the operation?
Is the implicit cast from unsigned long long to long long a reinterpret_cast, or what happens if the unsigned number is too large for the signed data type?
|
I have a JSON object which holds some json_array like this: (with org.codehaus.jettison.json.*)
json array:[{"C1":["S1","S2"]},{"C2":["S1","S2"]},{"C3":["S1","S2"]},{"C4":["S1","S2"]}]
I have to get two list,one for keys,another for the elements of each key.I have done like this:
//sample: clusterIdList:[C1, C2, C3, C... |
I'm writing a file I/O DLL in C++ which is going to be used from VB6. The interface is already fixed, and uses INT64/Currency as the general integer data type.
Now I have this function:
extern "C" LPWIN32_FIND_DATAW ZFILEIO_API GetFileInfoByIndex(INT64 index) {
return total_size >= 0
&& index <= file_vec->... |
I'm trying to optimize a simple Euclidian distance function in C. It's for a DLL, and calculates distances from one point to many. I have:
Version 1:
int CalcDistance (int y1, int x1, int *y2, int *x2, int nb , int *distances)
{
double dx,dy = 0;
for (int i = 0;i<nb;i++)
{
dx = x2[i] - x1;
... |
I have 3 questions, all of them are concerned with binary coded decimal (BCD) conversion. My coding snippets are listed as follows. But I don't like my algorithm because it takes too long when dealing with tons of data.
Any suggestions to improve the performance? Would you please show me an efficient and fast way to do... |
I'm new to coding, and especially to OOP PHP. I'll highly appreciate if you expert programmers could review following code and give me your opinion to make it better. Also, how you see this code, is it too horrible and ugly?
<?php
include_once("config.inc.php");
class user{
var $mysqli;
var $username;
var... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.