instruction stringlengths 71 71.9k |
|---|
I have a fairly simple app set up with couchrest_model to capture data pulled in from vendors to couchdb for later searching and archiving. Each document has a show (the name of the vendor), a datatype (which is limited to seven or eight unique strings), and a pulled_at timestamp field.
The core method on this model ne... |
I'm working on an implementation of MergeSort which sorts a List given as an argument. As follows
public class MergeSort implements Sort {
@Override
public <E extends Comparable<E>> void sort(List<E> list) {
final int length = list.size();
List<E> left = null;
List<E> right = null;
... |
Answer to Exporting PDF's from SQL Server DB and writing a Map to a Text File
this was a Question that I asked in StackOverflow and then answered it when I was finished with the project.
I would like it reviewed so the next time that I get to write something like this I will have better executing code.
here is the po... |
If you input the number 3 from the keyboard, the program will show this:
0
0 1 0
0 1 2 1 0
0 1 2 3 2 1 0
0 1 2 1 0
0 1 0
0
Here is my code:
#include <iostream>
using namespace std;
int main()
{
unsigned i,k=0,n;
cout<<"n= "; cin>>n;
while(k<=n)
{
for (i=0;i<... |
I am pushing an Excel file to the server and then reading it's contents. XLS and XLSX files need to be read differently, but the DLL that I'm using has the EXACT same function calls for both types. If I use a 'dynamic' type, I can save a lot of lines of code and avoid redundancy. However, I've been told many times befo... |
I've created an Ajax login for my website but I feel like I can optimize it, but I'm not sure how and where.
Questions:
How can I optimize my code?
Is the code secure? Any ways to break it (injection, etc)?
Also, when I attempt to log in, it currently takes about 1 second to process the login (on localhost). Is this ... |
I've made a carousel, which uses a function that is passed a target element, and from this element it adds next, prev, next next, and prev prev classes to its siblings (causing the rotation) - what do they call this, pyramid code?
Looking at this code - it works, but can't stand know that there is probably a better way... |
New to Go, trying to solve Tour of Go, Exercise 56, which is about error handling.
Can the following error handling method can be further improved?
package main
import (
"fmt"
"math"
)
type ErrNegativeSqrt float64
func (e ErrNegativeSqrt) Error() string {
return fmt.Sprintf("cannot Sqrt negative number: ... |
I have a working bloc of code that is a fairly ugly set of for, if and else's. I'm looking to clean it up, but I'm seeking advice on how to do so.
public String getContents() {
if (Blanks.size() > madLibsContent.size()) {
for(int i = 0; i <= Blanks.size() - 1; i++) {
if (i == 0)
... |
I use the Repository/Service design pattern in my projects and I have found something that might be a bit redundant. Am I writing any unnecessary code?
With that in mind, here is my structure:
public class Competition
{
public int Id { get; set; }
[Required] public string UserId { get; set; }
public string... |
I've been doing bits and bobs with Python for a few years, but I've never took the time to get feedback on what's pythonic and what's not. In the interest of collaborating more with Python programmers, I'd like to make sure my code follows conventions and idioms that the majority of Pythonistas will recognize.
Please r... |
I have to deploy this code that will list all the directories, sub directories and files in it starting from the root. The code works but I am not sure if this is the correct way to list. It should not fail, though.
Also, in despite not allowing directories with the name . and .., they get printed. Why is that?
<?php
... |
After fumbling around with Ruby for a few weeks I've fallen into a coding pattern that I'm comfortable with. When I create a new class and that class has dependencies, I add a method initialize_dependencies that does the job of creating them. That function is then executed from the constructor.
When I write a test for ... |
Can please someone review and give me suggestions for improving this code? I am very new to JavaScript.
I need to create a method in JavaScript which will take parameters as
DateRange (possible values as Today/This Week/This Month
BooleanFullDate (possible values as true/false)
Now, when the parameter value is Toda... |
I am unsure if the list could store a large number of messages.
There are 50,000 queue messages which I am receiving and assigning to the messages list:
var msgEnumerator = msgQueue.GetMessageEnumerator2();
var messages = new List<System.Messaging.Message>();
while(msgEnumerator.MoveNext(new TimeSpan(0, 0, ... |
I'm rewriting a god object with long methods into something much more viewable and pretty.
However, I think there is something missing and can be done better. I'm sending examples of one controller and two models in order to get an idea.
Controller: Account.php
<?php
if ( ! defined('BASEPATH')) exit('No direct s... |
I am wondering if I can make these classes a bit more efficient.
Test Results
Single Run
Method 1: 5 Columns - Text Query - 81178 Records = 00:00:00.6390366
secs
Method 2: 5 Columns - Text Query - 81178 Records = 00:00:00.5360307
secs
10 Run Loop
Method 1: 5 Columns - Text Query - 81178 Records = 00:00:05.3253045
se... |
This is my first attempt at JavaScript, so I am looking to learn.
I have a website that has jQuery built in and I wanted to leverage that in the following way:
I want to get a number variable that precedes a certain text string (*n*/portal.css)
Get the name of the current webpage
Use this number and pageName to help... |
I am calling a JS file from a bundle directory like so:
<script src="{{ asset('bundles/macppages/js/main.js') }}"></script>
which loads the JS file into the base.index.twig
In that JS file I want to add some custom css via jQuery like this:
function loadBkrndImg(){
var img = new Image();
img.src = "/bundl... |
I've just wrote a program in C# for counting sort.
space complexity is O(N+K)
time complexity is O(N+K)
I want reviews on my code and any better ways to implement this.
namespace SortingSelfCoded
{
public static class CountingSorter
{
public static int[] CountingSort(int [] input)
{
... |
A few things:
I tried to do it with smart pointers because I wanted to learn about them. I'm not sure I made the right choice of type, however (and started to regret it half-way through).
This is for school, so some operations were required. I can't change main.cpp or the general layout.
insert() works. However, I'm ... |
Usually, AsyncTasks are meant to be one-shot, i.e. you start it, it fetches some data, displays the result and dies. However, I'm now using a long-running AsyncTask to load images as the need arises. So far it's working great, but I'd just like to know if this is good practice & if there's any threading detail that I m... |
Is this code an adequate implementation of the producer/consumer pattern?
In computer science, the producer/consumer pattern is a classic example of multithreaded synchronisation. The problem describes some threads called consumers and some threads called producers sharing a common fixed-size queue.
In the above code, ... |
I have this Book program that contains 2 classes: Book and Library. I have the Book class done, but need some help on the Library class. Please help me check my code. I can provide the Book class if you need it.
Instruction here:
Fields: A single private ArrayList of Book field is all that is
necessary. This will h... |
I've written a method in c# that allows me to do create a dictionary from a passed in object and N lambda expressions that reference that objects properties and methods. It's working the way I want it and seems to perform well, but I'm looking for criticism and seeking to improve the code.
Here's an example usage:
clas... |
Maze puzzle
A 1 in input matrix means "allowed"; 0 means "blocked". Given such a matrix, find the route from the 1st quadrant to the last (n-1, n-1).
I would like to get some feedback to optimize and make this code cleaner. Also let me know if O(n!) is the complexity, where n is the dimension of the maze.
final class... |
try {
var isSupported = !! new Blob();
} catch (e) {
document.body.innerHTML = "<h1>Sorry your browser isn\'t supported :(</h1>";
}
var textarea = document.getElementById("textarea"),
inputFile = document.getElementById("input-file"),
appname = "notepad",
untitled = "untitled.txt",
isModified = false,
fi... |
I have created a program that allows the user to view/add/delete employees and also view employee payslip, either weekly employee or monthly employee, which is all done in the console.
My programme runs fine and does as asked, but I feel it is not OOP. Can anyone suggest any changes to make it more OO?
Please see the 5... |
My function takes the values of the profit (function declared as fieldProfit) and the field score (function declared as fieldScore). If both are above 10, then you earn a badge, hence, innerbadge = 1.
But, there's also another condition that must be met: the field or (x, y) coordinates have to fall in the area depicted... |
For a Project Euler problem, I made a Ruby roman numeral converter:
def romanize(num)
digits = {
1000 => "M",
900 => "CM", 500 => "D", 400 => "CD", 100 => "C",
90 => "XC", 50 => "L", 40 => "XL", 10 => "X",
9 => "IX", 5 => "V", 4 => "IV", 1 => "I"
}
digits.reduc... |
This might be a loaded question, but here goes. I have some code that is very similar between all the methods. I am trying to find a way to accomplish all methods with a generic method/function. I'm not sure if I should be using delegates, and if so how to implement in this specific situation, or if there is a much m... |
I have the following code and am wondering if this can be further optimized and also beautified (in order to be more readable) :
if( ( subType = entry.getSubType() ) ==null
||
!(subType.equals("typeA") || subType.equals("typeB"))
||
( version>=5 && (subType.equals("typeA") || subType.equals("typeB")) ... |
I'm using Munkres library from https://github.com/bmc/munkres/ to calculate maximum profit (reversed problem).
What do you think about this coding style?
def get_no_of_vowels(str):
return sum(str.lower().count(c) for c in "aeiuoy")
def get_no_of_consonants(str):
return sum(str.lower().count(c) for c in "bcdfgh... |
I have been looking for an algorithm for splitting a file into smaller pieces, which satisfy the following requirements:
The first line in the original file is a header, this header must be carried over to the resulting files
The ability to specify the approximate size to split off, for example, I want to split a file... |
Problem: Make a slider, located at the bottom of the page. The slider should be dynamically loaded only when a div (#slider) becomes visible on the screen. Images do not have to load all at once. Load the first two images, then load the third when we switched to the second, and so on.
I would like other users to look l... |
This is a working stack implementation using a linked list. I'm just curious to know if this is a good way of doing it. Any suggestions are welcome. Can we keep track of the number of elements in the stack using a count variable as used in the code?
#include <cstdlib>
#include<iostream>
using namespace std;
class no... |
I've written some XSLT where I want to assign values to some variables.
Depending on whether or not a condition is met, I want the variable to be populated with a computed value and I want it to have a default value otherwise.
I've written the following code that appears to work, but I think that there may be a better ... |
I have created a Job Scheduler, and i want some review, new ideas for it.
Scheduler.cs
public abstract class Scheduler
{
#region Fields && Properties
private readonly List<Job> _jobs = new List<Job>();
private readonly Random _rand = new Random();
private Job _currentlyExecutingJob;
private Thread ... |
This is a program that I wrote to add two numbers together that are too large for the C language to store. It stores the numbers as strings instead and processes one digit at a time. But I suspect that the program could be done in fewer steps. In what ways can I reduce the size of my program? Where am I taking more ... |
I am trying to write something that will copy the current <input>s value and enter it into any <input> that start with the same name.
<input> names will follow this pattern: price-0, price-1, price-2, upc-0, upc-1, upc-2.
So if a user enters a value in <input name="price-0"> and hits copy the value should be transferre... |
I have this code which compares data from two data tables. It does this by using a primary column and inserting the new record from table2 to table1. This loop continues for a large number of tables. I want to optimize it. Kindly give suggestions.
foreach (DataRow drRow in table2.Rows)
{
if(!table1.Rows.Contains(d... |
At the moment I have seven if statements that resemble the following code:
if(hit.collider.gameObject.tag == "Colour1" && start_time > look_at_time)
{
new_colour1.ChangeObjectMaterialColour(hit.collider.gameObject.renderer.material.color);
var colums = GameObject.FindGameObjectsWithTag(... |
CodeEval's "Grid Walk" problem is as follows:
There is a monkey which can walk around on a planar grid. The monkey can move one space at a time left, right, up or down. That is, from (x, y) the monkey can go to (x+1, y), (x-1, y), (x, y+1), and (x, y-1). Points where the sum of the digits of the absolute value of the ... |
Would you please run through this code and provide your comments?
void quote_container::allocate(string *i_string, string *i_value){
string temp_name = *i_string;
double temp_value;
// Convert the input string to upper case.
stringToUpper(temp_name);
if (temp_name =="OPEN"){
temp_value =... |
I've wrote a generic function to add an item to an Array 2D
This is what I have:
Private Sub Add_Item_Array_2D(ByRef Array_2D As String(,), _
ByVal Items As String())
Dim tmp_array(Array_2D.GetUpperBound(0) + 1, Array_2D.GetUpperBound(1)) As String
For x As Integer = 0 To Array_2... |
I'm currently populating my drop downlists like this...
public List<NewLogin> GetRolesForDDL()
{
using (database db = new database())
{
return (from r in db.UserRole
select new NewLogin
{
UserRole = r.Role,
... |
I've written my first completely self-written jQuery today. I just used the jQuery docs and I'm reasonably proud I got it to work, and working fine. It's not a very complex problem I'm solving, just an animated UI element, but it are my first steps, and I want to make sure I'm starting off right.
I think it's a lot of ... |
I've finally got all my code working as expected and it handles the data quickly. But now I'm looking to refactor it because there is some duplicate sections that just looks like can be broken down for more efficiency and readability. With out making this too long, here is the original:
I created functions createNumL... |
How will you merge two sorted arrays, when The longer array has empty spaces to accomodate the second array. Complexity: O (items in longer + items in smaller). Request for making code concise, clean and optimal.
public final class MergeArrays {
private MergeArrays() {}
private static void check(Integer[] ... |
Someone posted a question on http://math.stackexchange.com earlier because their program to tranpose a matrix wasn't working. I copied the code they posted (which was just the transpose method) and added the code necessary to check if it worked on their example matrix and it does, so there's obviously a problem elsewhe... |
I plan on including this work in a portfolio.
Will this code get me hired or laughed at?
More specifically:
How would you rate the general complexity of the code?
How bad does the code smell?
Is the VC too fat?
Glaring best practices mistakes?
Follow-up questions:
Can you expand on what you said about magic numbers... |
I'm open to any comments on this code/approach. This is mostly architecture and threading.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.ServiceModel;
using System.ServiceProcess;
using System.Configuration;
using System.Configuration.I... |
I need to use sockets from winsok2.h. So, I written a class NetObject to use it. But, when I do compilation I am getting an error:
error LNK2019: unresolved external symbol "public: int __thiscall wsa::NetObject::connect(void)" (?connect@NetObject@wsa@@QAEHXZ) referenced in function _main
I do this using Visual C++ co... |
I'm trying to simulate the Monty Hall problem, to statistically determine if there is any benefit to changing my choice after a door containing a goat is open (testing this guy's Monty Hall theory on YouTube).
So, does this manage to simulate it properly? (Just for the curious: Changing doors doesn't seem to have any b... |
I'm new to scala and have been working to understand the syntax so that I can be more efficient. How does this look in terms of functional syntax and scala idioms?
In particular, I'd like to know if this is a good way of handling futures. I'm aware of onComplete, onSuccess, etc..., matching but I had trouble getting ... |
Can this be shortened/improved? I'm trying to make a password checker in Python.
Could the ifs be put into a for loop? If so, how?
pw = input("Enter password to test: ")
caps = sum(1 for c in pw if c.isupper())
lower = sum(1 for c in pw if c.islower())
nums = sum(1 for c in pw if c.isnumeric())
scr = ['weak', 'mediu... |
I'm a beginner in JEE development. I have just finished a web application that I'm going to deploy in a server.
It's a new level for me; it's not just a simple application that I can run for 10 min, etc.
My question is for the quality of code. Of course we all know that a piece of code that works does not mean it's c... |
This is my solution to the problem in the title. The code is pretty straightforward. The one problem is with substring; it's \$O(n)\$ in .Net and creates garbage. Any other improvements?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LongestWordFromWords
{
internal ... |
function score_to_grade(score1) {
var score = 100 - score1;
if (score == 100)
return 'A+';
else if (score > 93)
return 'A';
else if (score > 87)
return 'A-';
else if (score > 81)
return 'B+';
else if (score > 69 )
return 'B';
else if (score > 63 )
return 'B-';
else if (score > ... |
I have implemented kNN (k-nearest neighbors) as follows, but it is very slow. I want to get an exact k-nearest-neighbor, not the approximate ones, so I didn't use the FLANN or ANN libraries.
mexFindNN.cpp
#include <iostream>
using namespace std;
#include "mex.h"
#include <cstdio>
#include <cstdlib>
#include <cmath>
#i... |
background
A little over a year ago I was given the creative freedom to develop on the side of my primary responsibilities. I want to move into development, but am not currently in that role. I was given the resources to develop a PHP application that handled a lot of the reporting functions for our business.
My proble... |
Is there any other way to shorten this code without sacrificing readability? I am fairly new to C#, let alone programming, and I wanted to know if this is as short as this code can possibly become. Feedback would be greatly welcomed.
Side note: was Questions.Questask used properly here, or could there have been a bet... |
This works just fine, however, the assignment was to write a recursive "function". I'm curious to see if this should count.
Any comments / suggestions/ stuff I should watch out for are appreciated.
#include <iostream>
#include <functional>
#include <cctype>
#include <cstdlib>
int main() {
char go_again = 'Y';
... |
[Please don't comment on using Turbo C++. I know that it's obsolete but we are taught this way only.]
#include<fstream.h>
#include<conio.h>
void main()
{
clrscr();
char ch;
ifstream read;
read.open("Employee.txt");
ofstream write;
write.open("Another.txt");
while(!read.eof())
{
read.get(ch); //Also whe... |
I am looking for a review regarding C++ streams behaviour conformance.
I have made this win32_file_streambuf so that I can use it in log4cplus project. I basically need it so that log files can be renamed when they are still opened by another process logging into the same file. This can be done when file is opened with... |
I have just wrote this Pong game in Pygame:
import pygame
import sys
import math
class Ball(object):
def __init__(self, x, y, width, height, vx, vy, colour):
self.x = x
self.y = y
self.width = width
self.height = height
self.vx = vx
self.vy = vy
self.colour =... |
I was working on a problem set and I came across this problem:
Assume s is a string of lower case characters.
Write a program that prints the longest substring of s in which the letters occur in alphabetical order. For example, if s = 'azcbobobegghakl', then your program should print:
Longest substring in alphabetical... |
Recently I was asked in an interview to convert the string say "aabbbccccddddd" to "a2b3c4d5". i.e we have to avoid repeating same character and just adding the repeat count. Here 'a' is repeated twice in the input and so we have to write it as 'a2' in the output. Also i have to write a function to reverse the format (... |
I need to optimize this piece of code I made because this will run in real-time mode.
It's a matrix shifter that pulls downward and will neglect any transparent element.
Code:
void shiftDown(int col)
{
int x = 0; //transparent element
int N = 5; //size
int i,j,k,l;
for ( i = N - 1;i >= 0; --i )
{... |
I recently had a programming challenge, which was to create the N grams. The description is as follows:
Trigram analysis is very simple. Look at each set of three adjacent
words in a document. Use the first two words of the set as a key, and
remember the fact that the third word followed that key. Once you’ve
f... |
I have a method which checks all of its surrounding squares and returns the number of bombs around it. It uses a long list of if statements, which is pretty ugly and probably inefficient.
public int countArround(){
int bombNum = 0;
//x=0 y=1 works
if(((SmartSquare)board.getSquareAt(xLocation, yLocati... |
Maze, assumption - single point of entry and a single point of exit. Also directions to travel in maze are North South East West. Request for optimization and code cleanup.
final class Coordinate {
private final int x;
private final int y;
public Coordinate(int x, int y) {
this.x = x;
this... |
I want to implement a thread-safe singly linked list in C. Its nodes contain unique entries and I only need functions to add nodes (to head only), remove nodes and to locate a specific node.
I am reasonably confident of the linked-list logic (any performance tips would be greatly appreciated though), but I am more conc... |
I have implemented my first program in JavaScript, Rock-Paper-Scissors. I would like JavaScript developers to help me make this program more JavaScript-like by following the idioms of the language. I am also open to any suggestions related to simplification of logic and code readability.
The following is the complete l... |
According to https://stackoverflow.com/questions/19608546/optimize-regex-for-maximum-speed
and comments to ask my question here .
Please help me to optimize following regex to best performance . I have read some articles but this problem should solve quickly to decrease cpu usage and delay time so i don't have enough t... |
I have an array of structure records and function intersection and difference.
The intersection function take list1,list2,list3(an array of records),and size of both list1 and list2.
Here, intersection and difference both are the boolean operators ( like : A U B , A - B , A intersection B). Also list1 and list2 are g... |
CellDrawableProvider is an Android class used in the game Tic-Tac-Toe. It provides drawables for cells of game board (drawables for figures X and O, and "Fire" if the cell is in the firing line). To save memory, this class uses a map to store the already created drawables.
class CellDrawableProvider {
private final... |
This is my solution to Project Euler problem 2:
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
The class fibonacci_Even_Sum_Calculator does two things:
calculate the sum of the even-valued Fibonacci numbers
cache the results in a dic... |
This is my importer to database from excel file. I would like to handle situations when any error raise. To not breaks whole import when one errors occurs.
For example when there is duplicated record and I have uniqueness validations. I would like to store this row id in errors table and inform about that at the end.
c... |
I want move a Vertical line segment across a plane or another way sweep the plane, from Left to right.
The figure illustrates how the segment is moving at the X-axis. When x1 >= X beginning and i translate it to the upper part and so on, till y2 which is the upper part of the segment reaches Y. You can think of it as ... |
I'm just learning OOP, and I have an assignment to create a Stack. I came up with the following. Is it "beauty" enough, or to "schooly". Where can I evolve?
This is the class:
class Stack
{
private int _length;
private List<int> _members = new List<int>();
public Stack()
{
_leng... |
I have just made what seems to me to be the first reliable prime-checking program that works. However, I am not sure if it is completely reliable, or if there are problems. It relies on list-making more than math, and it can be slow for bigger numbers. Do you think there are any problems?
def primeChecker(x):
if... |
Generate new password and send to user, if user is registered.
Two TextBox on page, txtUserName & txtEamil.
User can provide either UserName or Email to get new password.
If UserName is provided then find User on username, if exists then
generate new password and Email.
If user provided email then check if any user ex... |
let reply = ref ""
let doAuto =
async {
let! resultAA =
async { return SqlCmd.aaHits query |> Async.RunSynchronously |> List.ofSeq }
let! resultBB =
async { return SqlCmd.bbHits query |> Async.RunSynchronously |> List.ofSeq }
let! resultCC =
async { r... |
I have a list of tuples (key, value1, value2, ...). I simplify the tuple here so it is only of length 2. Keys contain duplicated figures.
xs = zip([1,2,2,3,3,3,4,1,1,2,2], range(11)) # simple to input
[(1, 0),
(2, 1),
(2, 2),
(3, 3),
(3, 4),
(3, 5),
(4, 6),
(1, 7),
(1, 8),
(2, 9),
(2, 10)]
Now, I would like... |
The idea is to get a listing of monthly bills with amounts paid. The subquery does a total through a group by using bill_id and party_id.
I wish to know how it can be improved. I'm not comfortable with JOINs and am willing to learn.
SELECT
bill.id as bill_id,
master.id as party_id,
master.name as party_name... |
Today I started to make a class called Fraction, where the class will act just like a fraction does in real mathematics. I am doing this just for the challenge. So far I only made the addition part, because I wanted to know if anybody had any suggestions for me.
#include <iostream>
#include <string>
#include <cmath> //... |
I've made an unbeatable Tic-Tac-Toe in Python 3.3. While it truly was unbeatable, it was an eyesore to look at and nigh impossible to read. That code is here.
I have since then optimized it for Python 2.7.5 as follows:
from random import randrange, random
from time import sleep
#First, setup the board!!
def draw_boa... |
My in-laws taught me a dice game a couple years ago, and we play every once in a while. A recent excellent answer from @radarbob inspired me to proceed with translating the rules of that dice game into code.
Here's what came out of it:
So it works perfectly, and somehow I'm just as unlucky with this virtual version ... |
I wrote some math formulas in Haskell and was wondering about how to clean the code up and make it more readable.
import Math.Gamma
pdf :: Double -> Double -> Double -> Double -> Double
pdf mu alpha beta x =
( beta / (2 * alpha * gamma ( 1/beta) ) ) **
exp ( -1* ( abs(x - mu )/alpha )) ** beta
cdf :: Double ... |
I know heaps are commonly implemented by an array. But, I wanted to share my pointer implementation and have your feedback(s) :)
General idea:
I convert the index to its binary value and then trace the heap (0 = leftChild & 1 = rightChild)] Note: The first 1 is for entering the root.
I do the push at the same time.
E... |
I was just wondering if this is a good example, following good practices, of a C program for launching an interpreted script from a native binary executable. Here the interpreter is Perl and the script an implementation of something analogous to du --apparent-size, but the idea is general.
Also, is this code secure aga... |
I have a lock class, that handels a database lock. It's not important how.
It is used in the beginning of a large operation, here is how it is used today:
public void LargeOperation()
{
try
{
MyLock.DoLock("SomeId");
// Do lots of stuff that might thorw exceptions
}
finally
... |
I have done the source code for my lesson, which I shall publish later on my website:
<script src="three.min.js"></script>
<script>
var renderer, scene, camera, geometry, material, mesh, light, axisRotation;
function createScene() {
renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, wi... |
I've written a program showing the process of bubble sort arithmetic in C. I need some suggestions on improving it.
#include <stdio.h>
#include <Windows.h>
#include <stdlib.h>
#include <time.h>
#define SIZE 20
#define WIDE (SIZE * 2)
void RepaintScreen(int *pData, int count, int p1, int p2)
{
system("cls");
c... |
I have WCF Service. It works fine and I want to have test coverage for it. Unit tests and acceptance.
The problem is the static class in the code. How is it possible to avoid it?
If it will be refactored to the code without static classes - I can use mocks for example Moq.
I have also used Ninject as DI Framework so... |
As I get to some performance issues in my app and find that I use database access in a bad way.
So I decided to move to singleton pattern.
I need someone to review this code and confirm me that I made a good database access via singleton pattern or I am doing something wrong:
This is the class:
@interface DataAccessCon... |
I have to create a button which counts from 0 to 9, and after 9 come 0 again. One of my friends said that this code is not good enough. Can you explain to me why it's a problem to use -1?
int szám = 0;
private void counterButton_Click(object sender, EventArgs e)
{
szám++;
this.Text = szám.ToString();
if (sz... |
I am fairly new to jQuery and I am making a new search results page. In this snippet I am switching from a grid to list view and vice versa. Can anyone suggest a cleaner method of performing this change? I did try using a variable to minimize all my (this) calls but I couldn't get them to work. Any help would be much a... |
I'm writing a C++ library with MinGW (4.8.0, DW2, POSIX) compiler. But this library must be used by another compiler. I've read this post, so I've re-written the C++ library interface in this way:
#ifndef SERIALPORT_H
#define SERIALPORT_H
#include <cstring> // size_t
#include <memory> // unique_ptr
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.