instruction stringlengths 71 71.9k |
|---|
We have a system with a non standard database solution. All trips to the DB are rather expensive. We cannot use entity framework.
Currently our lazy loading is on an entity by entity basis. So if I have a Customer and access their Orders object it only loads the Orders for that customer.
Something like so
//DAL
public... |
I created the body of an email by using the following bit of code:
msgBody &= " Name: " & Venuename & vbNewLine & "Address:" & _
"" & Venueaddress & nxtline & "City: " & Venuecity & nxtline & "State:" & _
"" & Venuestate & nxtline & "Zip: " & Venuezip & nxtline & "Phone: " & Venuephone & nxtline & ... |
I am trying to make my class a bit cleaner, especially some of its methods like Count, __add__, remove and __iter__. I feel like I could use cleaner code on the above methods and get the same results.
Bag class represents and defines methods, operators, and an iterator for the Bag class. Bags are similar to sets, and h... |
Given the length of an array and a char, I would like to replace every element in a char array with that given char.
Using a for loop, I'm changing each element to that char. Is there a better way to do it, or a specific method for that?
using System;
using System.Collections.Generic;
namespace TestProject
{
class... |
I was doing a problem, SPOJ: FLIB. My code was running slow (getting Time Limit Exceeded error) when I was using Code1.
However, my code accepted within the required time limit when I hardcoded the multiplication instead, using Code2. Can someone tell how this was a significant change? Note that this program relies hea... |
In order to read a whole file as a string using standard libraries you have to allocate memory, terminate the string, determine size of the file and size of each element.
This could happen with fread until I decided to automatize it using this:
char *readFile (FILE* fp, char *source)
{
unsigned long long int size;
... |
"The C Programming Language" (2nd Edition) by Kernighan and Richie has this exercise:
Write a program to print all input lines that are longer than 80 characters
I have written the following code for this exercise:
#include <stdio.h>
#define MAXLEN 1000
#define MINLEN 80
int main(void)
{
int c;
int index = ... |
Code
I have the following piece of code
#define equidIND(divid, recip) (size_t)((divid) * (recip) + 0.5)
...
// Get index for average velocity
//idx_velo_avg = (size_t)(velo_avg * funmaps_velo->map_velo_step_recip + 0.5);
idx_velo_avg = equidIND(velo_avg, funmaps_velo->map_vel... |
I'm using the following piece of JavaScript to emulate class extending. Is this a valid way to go or does it have some drawbacks which should definitely be fixed?
var Validator = function (inputId) {
"use strict";
var self = this;
self.inputId = inputId;
window.document.getElementById(inputId).onblur... |
Any feedback is welcome:
public class HexToDecimal {
static String hexRep = "0123456789ABCDEF";
public static void main(String[] args) {
System.out.println(HexToDecimal.hexToDecimal("AB"));
}
public static int hexToDecimal(String hex) {
int counter = hex.length()-1;
int sum ... |
There are 3 search fields, and at least one must be filled out. When the search button is clicked the search fields are checked, if none are filled in show the error window with the error message for this error. If at least one field is filled in get a code based on the search criteria. If the code was not successfully... |
I have as recently as last week picked php back up to code in. My experience with it has always been quite limited, but as I am now making a simple application for my job (for internal use) I am stumbling upon some small difficulties (or questions rather).
<?php include_once 'config.php'; include_once 'browsercheck.php... |
To become better acquainted with the Intel Parallel Studio XE profilers I'm currently messing around with a simple concurrent freelist. I'm fairly certain that it's thread-safe. It uses Acq/Rel semantics, Tagged Pointers to avoid the ABA problem and users of the free list can't actually touch the freelist header data. ... |
I wanted to resolve the puzzle from this link using Python 3. It works and gives me the correct value but I would like to know if it is possible to resolve this problem with a few lines or how I can improve/optimize my code.
import time
start = time.time()
max=0
gx=0
gy=0
gi=0
gj=0
for i in range(999,99,-1):
for j... |
I needed a simple expiring in-memory cache module for a project I'm working on and I've come up with the following.
My requirements for the cache module are:
Be able to expire objects after certain period of time
Use what we have in the standard library
Keep it simple
So far I've got this.
"""
Expiring in-memory cach... |
I made a little Python3 script to grab video clips from a website for viewing off-line later and would like your critique, advice, tips & tricks and/or learning resources to create better code. (Project on GitHub)
#!/usr/bin/env python3
''' phgrab.py: clip downloader. '''
import os
import sys
import argparse
import ur... |
I have a database with 4 tables filled with millions of rows. I have my program run on several computers computing data and then returning it to the database. The huge bottleneck in my program design is that for each calculation, it has to download the data and then perform calculations on it and then save the results ... |
I have 2 connections. How can I reduce this to one connection?
//AuthentificationController class:
public string Register(string nickName, string email, string password)
{
try
{
if(!UserWorker.IsUserRegistered(nickName)) //connect
{
UserWorker.RegisterUser(nickName... |
This is code I wrote for calculating bezier curves as quickly and RAM efficiently as possible.
I would like to know if there are faster ways to optimize anything, because I am very new to C++ and efficiency methods.
Lastly, if there is a variable that could be more explicitly named, also let me know.
#include <vector>
... |
I'm creating an event hub object in for a large project I am building in JavaScript. The project will have modules in charge of the UI, commands, and rendering. Each module will use this hub for broadcasting events to each other.
This is my JavaScript library (I cut out RequireJS for conciseness):
Hub = Object.create (... |
To find answers where users expressed their gratitude (by mentioning "thank" in comments),
I put together this SEDE query (latest):
DECLARE @username AS NVARCHAR(60) = ##DisplayName:string? ##;
DECLARE @userId AS INT = ##UserId:int?-1##;
-- SpecialThanks: Special thanks only "Enter 1 for YES, 0 for NO"
DECLARE @Specia... |
I wrote a PS script to backup data from single user pcs to their network homedrive. The purpose of this tool is to save some time and ensure process consistency when reimaging/replacing machines. I would appreciate your critiques and ideas. I am new to Powershell scripting.
Breakdown of the scripts job:
BACKUP:
Creat... |
I wanted to create a basic String class that will hold a CString and have:
constructor, destructor, copy constructor
assignment operator (both from String and CString)
<< and >> operators to stream with cout and cin
==, < and > operators to compare Strings
[ ] operator to access a certain char in a string
Len() func... |
I'm new to web development, and I'm constantly torn between good code and bad code. I was wondering if you could help me improve my following code and see if I'm doing it right in terms of how I use it on the line by line basis: - t code checks to see if a cookie exists if it doesnt exist it sets a cookie to last for 2... |
I haven't coded all winter, and it seems like everything I learned about efficiency from my data structures class leaked out my head. I was wondering if I can get some help in making my code less verbose, and more efficient, as some of the things I do seem redundant. My code is correct (I'm confident as I tested it), a... |
I've already done quite a bit of cleaning up. For example, the strings dryCheck and blueCheck no longer exist, instead they're replaced with "else". But I think this could be done 10x better, so if you know how (no advanced C++ lingo etc), that would be great!
A red seed will grow into a flower when planted in soil te... |
I am creating a simple support ticket system. I thought It would be a nice little feature to show the current date and time. Since I want to show the current time I thought JavaScript would be best versus using PHP. I have looked at different questions posted by other user about the topic and created the following sni... |
Basically, what this program does is that this generates a random number, and asks the user to guess it with multiple chances. So, if the user is close, it says that the user is close, and if the user is not close, then it says that the user is too high/low and if the user guesses it right, it congratulates the user.
S... |
Here is the culprit; headers omitted for brevity, and also, see notes afterwards:
/**
* A GUI-neutral background task executor
*
* <p>A very common scenario when programming with GUI toolkits is the need to
* perform operations in the background without blocking the "UI thread" (this
* would be the infamous EDT, o... |
This is a simple Area Calculator coded in Java. What this does is that it prompts the user to select a shape, and asks for the details needed to calculate the area of that specific shape.
Main.java:
package com.AreaCalculator;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {... |
I am practicing some simple Java coding problems in an attempt to learn while doing them. I would like to know if my code is redundant/is there an easier way to accomplish the same thing?
Question: Which Alien?
"A person who witnessed the appearance of the alien has come forward
to describe the alien's appearance." ... |
I am trying to build a websocket server to run on the Raspberry Pi. The websocket server has to push periodic realtime update to a browser. Here is a sample code that I am planning to use. The example code here sends the current time instead of sensor data.
Most of the code is built form an example. However, what I nee... |
While looking for Naruto posts
(= overlooked accepted answers well worthy of upvotes),
I noticed some odd false positives,
selfie answers,
where the user who asked the question accepted his own answer under suspicious circumstances.
I'd call suspicious circumstance the case when other answers exist with positive votes,... |
I've been working on a live form validation project, initially I intended on finding a way to solely use CSS for said validation but it quickly became apparent I would require some jQuery to get it to function properly. That said, I'd like another set of eyes on my jQuery to see if anyone has improvements or tips to st... |
I'm looking for an algorithm to make my code faster and better for big strings.
Problem link
Let the simple prettiness of a string be the count of vowels (I, E, A, O, U, Y) divided by the length of the string. Find the sum of the simple prettiness of all substrings of a given string (with precision within 1 part per m... |
Any suggestions are welcome.
package je3.io;
import java.io.*;
import java.nio.charset.Charset;
/**
* Created by IDEA on 30/01/15.
*/
public class CountCharsWordsLines {
public static long[] count(String filename) throws IOException {
long[] counts = new long[3];
try(InputStream in = new FileInp... |
This is what I've done;
import Control.Applicative
import Control.Monad
import qualified System.Directory as SD
main = do
files <- SD.getDirectoryContents =<< SD.getCurrentDirectory
exes <- filterM (liftA SD.executable <$> SD.getPermissions) files
print exes
This works fine, but I can't help feeling that t... |
I am new to object-oriented concepts. The following is my attempt at creating a basic calculator using class and operator overloading concepts. Please review it for improvements. Also, how do I make it more intuitive? I want to display: +,-,*,/ as options and use switch on them.
#include <iostream>
#include <conio.h>
... |
I develop Windows Phone App with Prism framework (MVVM).
I use data caching. To get data I use proxy service. Proxy service creates two tasks:
the first task is receiving data from a web service and update data in local database (SqLite).
the second task is receiving data from the local database.
The ViewModel laun... |
I'm currently working on a kind of PHP Quiz about mathematical calculations. We show a mathematical equation, and user need to input his answer.
Currently, this is what I have written:
echo '<div class="table-title">Super Quizz</div>';
echo '<div class="row text-center quizz">';
function addition($x, $y) { return $x... |
As part of my C++ training, I wanted to create a basic complex number class for basic complex number calculations.
The class should have the following:
constructor (non explicit, for implicit conversions)
<< and >> operators to stream with cout and cin
==, != operators to compare complex numbers
+, +=, -, -=, *, *=, ... |
Around June of last year, I made my very first GUI 'app.' Wish I knew of this amazing site then, I thought for posterity's sake it would be great to get it reviewed.
It's a simple I/O window just to keep track of the quantity of X exercise that was done, and if I used these two other workout apps.
I'd like to evaluate:... |
I've got a rather long function that will take the size of a triangle print it with stars and give the user the option of whether or not they want stars printed inside the triangle, and the orientation (point up or down). I was hoping for some general refactoring methodologies I could apply.
Every permutation is possi... |
A Person has coordinates and an Item has coordinates as well, and hence both are derived from Entity, which has the coordinates data member. If a person holding an item moves, the coordinates of the item must change to whatever the person's new coordinates are. And if he drops the item, this is no longer true. So I ... |
Any suggestions are welcome.
package je3.io;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* Created by IDEA on 31/01/15.
*/
public class DirWalker {
private List<File> recursiveList = new ArrayList<File>();
public void walkDir(String pathname) {
File d = new File(path... |
I have a project in embedded systems and I have to write the code in C, and make it simple.
This is my first time, and it's only a simulation of how it should work.
#include<iostream.h>
#include<stdio.h>
void manualMode();
void defaultMode();
int temp, timeToWash, operation;
int main() {
int mode =0, part=3, w... |
I've come up with the following code to handle drag and drop operation. It's composed of a constructor function that returns an objects with methods to attach to event handlers.
Notes about this solution:
It's client responsibility to attach methods to event handlers;
specific CSS classes should be added to DOM elemen... |
Inspired by this question, I decided to implement a Disjoint-set data structure in Python 3. I mainly followed this description for understanding the algorithm (but did not do the optimizations for path compression, union by rank etc. -- so mine is a "naive" implementation).
Here is the Wikipedia article for reference.... |
In my app, I have an ObservableCollection of MenuItems:
public ObservableCollection<MenuItem> ItemList { get; set; }
When an item in it is selected (either programatically or by the user), this method is run:
public void SelectionChangedWS()
{
if (!NavButtonUsed) { Back.Insert(0, CurrentItem); }
if (Forward.C... |
I am experimenting with ECS design and I am looking for a solid way to implement a message bus for use between the different systems.
Here is a stripped-down version of my current implementation:
#include <iostream>
#include <cstdlib>
#include <functional>
#include <vector>
struct BaseEvent
{
static size_t type_co... |
I wrote a record which encapsulates conversion of colors between TColor, RGB values, CMYK values, and HSV/HSB values. It seems to work (at least for the purpose I made it), but I'm not too confident about the rest. Specifically the conversion between RGB and HSV. This record supports implicit conversion with TColor. I ... |
public function insert($table, $fields = array(), $values = array()) {
$fields = '`' . implode ( '`,`', $fields ) . '`';
$values = "'" . implode ( "','", $values ) . "'";
$sql = "INSERT INTO {$table} ($fields) VALUES($values)";
if ($this->_pdo->prepare ( $sql )) {
if ($this->_pdo->exec ( $sql )... |
I'm super new to this so please be nice. I tried solving Chris Pine's challenge to print the entire lyrics to 99 bottles of beer on the wall. This seems to work, but is there a better/more efficient way to do it? Just want to learn how to improve it if I can.
var1 = 99
loop do
puts (var1.to_s) + ' bottles of beer o... |
I'm new to JavaScript and was hoping there was a cleaner way to write this. It's a block of code that looks at a group of documents in a collection (called Messages), and makes a call to the GitHub API for each one. If any of the API calls finds a certain string in the response, the function returns true via callback. ... |
The previous and initial iteration at Kruskal's algorithm in Java
Now what I did is remove the fields and let the actual Kruskal-routine create the required data structures in the local scope, which leads to thread safety.
The only file that changed is KruskalMSTFinder.java:
package net.coderodde.graph.mst.support;
im... |
When I last did a lot of Java programming, I'd do this:
All classes in a package would be default (package) visibility.
Each package would have a public PackageNamePack factory class, e.g. BusinessPack.
And the package would have a number of interfaces.
The package factory would have methods like newBusiness(...) whi... |
The program is displaying given number (right now it is only signed int) converted to different numeral system (binary,octal and hexadecimal for now).
Number can be input in the text box and the display updates automatically in the ConvrterDisplay UserControl. Form has a possibility to enable autoincrement provied by ... |
The code I wrote to do this effect stays "fixed" on top or on bottom. I did it the manual hard-coded way and wanted some advice on the best way to write something like this.
jsFiddle
<script type="text/javascript">
function toggle_visibility(id) {
if (id == 'firstDivHeader')
{
document.getElementById('firstDivResults... |
I had come up with the following code:
hello_worlds 0 = putStr ""
hello_worlds x = do putStrLn "Hello World"
hello_worlds (x-1)
main = do
n <- readLn :: IO Int
hello_worlds n
I am aware that it is making one extra call to putStr.
Is there any better way of doing this? If so, please give some... |
I'm trying to implement an algorithm for a resource-constrained project scheduling problem. I have several resources, resource constraints and all of this is in integer time domain. With my class ResourceUtilization I want to assure that resource constraints are not violated in all time. Key element of my class is arra... |
Input: An array of integers.
Output: That same array, but with the even numbers at the front and the uneven numbers at the back of the array.
I wrote three different solutions, depending on the needs of the client.
First solution:
// linear time not stable and not in-place
private static void partition1(int[] a){
/... |
The problem is:
Define a procedure that takes 3 number arguments and returns the sum of the squares of the 2 largest numbers.
I am a CS graduate and I am revising my university notes. This is my code so far:
(define (square n) (* n n))
(define (square_of_larger_numbs a b c)
(cond ((and (> a b) (> a c))
(c... |
I'm starting with make, and I made my first makefile to build my project. I don't know if it's the best way to do it or not, so I share with you my makefile to get your opinion on it:
Directory structure:
├── LICENSE
├── Makefile
├── objs
│ └── parser.o
├── out
│ ├── libsip.a
│ └── parser.h
├── README.md
├── src... |
URL: http://jsfiddle.net/rabbit_aaron/ve7deecw/
This is again, a JUST FOR FUN project. In this attempt, I use a closure instead of validating caller to ensure only member methods can access private methods.
Pros:
Easy to implement
Works in strict mode
All class instances has the same private methods
Yes, real private,... |
This is a simple class for a label with a score that animates counting up or down. When someone in the game scores points, the numbers count up or down to the new total.
Here is an example of what it looks like:
I ran into a few problems when building this class. It was important to prevent the building of further ... |
I have the following piece of code in my project, and that a few times:
$this->uniqueSessionKey = $settings->get('uniqueSessionKey') ? $settings->get('uniqueSessionKey') : $_SERVER['HTTP_USER_AGENT'] . time();
I was wondering if there's a better way of writing this, especially the part where it checks if $settings->ge... |
I am taking Stanford's Introduction to Databases Self-Paced online course. I have gone through the videos in the SQL mini-course, and I am having trouble completing the exercises.
The following is the question from the SQL Movie-Rating Query Exercises, Question 7:
For each movie that has at least one rating, find the... |
Input: Real number y and Integer number x
Output: x^y
Constraint: Must be done in O(log(y)) time.
Notice that O(log(y)) is O(length-of(y)).
public static double expon(double x, int y){
double result = 1.0;
double part = x;
for (int i = 0; i < 32; i++){
if (((y >> i) & 1) == 1){
resul... |
I implemented the Simple Factory Pattern with some unit tests, but I'm with a feeling that I did something wrong and that I can improve it.
Tell me what you think about the code (source and tests).
PizzaFactoryTest.php:
<?php namespace Pattern\SimpleFactory;
use PHPUnit_Framework_TestCase;
class PizzaFactoryTest exte... |
I am learning Python (3) and Django (1.7) after a while in PHP (not POO). I am rebuilding my own website that has public members. My members have a user account, a public profile and a private profile. When a member signs in, an email is sent to the admins to say that a new member has joined the team and a new email is... |
I'm quite new to Scala and was surprised that there doesn't seem to be anything like Java's try-with-resources block. So of course I wrote my own little construct. Is there anything I could improve?
import scala.util.control.NonFatal
import scala.util.Try
import scala.util.Failure
import scala.util.Success
object TryW... |
I'm working on a script that will be able to press the login button on any site for an app I'm working on. I have it working (still a few edge cases to work out such as multiple submit buttons and iFrames and I'm going to rewrite it to make it prettier once I figure them out).
Can you think of any ways I could improve ... |
Recently, I perform re-factor on one of my frequent used custom enum, by removing its getter.
My rational for doing so it.
The enum's custom fields are immutable
Only use getters when it is necessary.
Less typing. Reduce verbosity.
This is a very stable class, with only 17 commits, since 2008. Its getters behavior ha... |
This is a header file for my bezier curve utility and several of BezierCurve2D's methods return newly created arrays of Point2D objects.
Should I create (using new) and delete objects in the same scopes? Should I have these methods receive a pre-allocated space of Point2Ds?
#ifndef BEZIER_UTILITY_H
#define BEZIER_UTILI... |
Here is my simple chat program. I'm wondering whether it has an acceptable design (both object oriented design and network design).
If you want to run it, I can provide the solution folder.
Server
public class Server
{
private TcpListener _tcpListener;
private readonly int _packetSize = 64;
private int _cl... |
pwgen is a nice password generator utility.
When you run it, it fills the terminal with a bunch of random passwords,
giving you many options to choose from and pick something you like,
for example:
lvk3U7cKJYkl pLBJ007977Qx b9xhj8NWPfWQ
pMgUJBUuXwpG OAAqf6Y9TXqc fJOyxoGYCRSQ
bpbwp6f2MxEH fUYTJUqg0ZMB GjVVEQxuer0k
oqT... |
As nobody has provided input, I have updated the question. (The next one is coming soon)
Coding to this interface:
namespace ThorsAnvil
{
namespace Serialization
{
class ParserInterface
{
public:
enum class ParserToken {Error, DocStart, DocEnd, MapStart, MapEnd, ArrayStart, ArrayEnd, Key, Value};
... |
In Json strings characters can be escaped with \\.
Here is an iterator that can read such strings and convert the escaped characters to UTF-8
#ifndef THORSANVIL_SERIALIZATION_UNICODE_ITERATOR_H
#define THORSANVIL_SERIALIZATION_UNICODE_ITERATOR_H
#include <iterator>
namespace ThorsAnvil
{
namespace Serialization
... |
Today, a solution written in Python was posted to this challenge, and since I was inspired by it, I made a version in EcmaScript 6.
I tried to explore some new language constructs:
arrow functions
template Strings
let
for..of
generators
The code:
function* bottlesOfBeer(howMany=99){
let pluralizeBottles = count => ... |
I'm trying to implement function downpairs which takes monad of pairs and transform it into pair of monad
My current implementation is
import Control.Monad
import Control.Arrow
import Data.Maybe
downpair :: (Monad m) => m (a, b) -> (m a, m b)
downpair = ((return . fst =<<) &&& (return . snd =<<))
main = do
prin... |
I'm doing a project in ms sql and I have to fill table with random records.
Here is a definition of table:
create table invoice(
id_invoice INT PRIMARY KEY IDENTITY(1,1),
id_employee INT FOREIGN KEY REFERENCES Employee(id_employee),
id_client INT FOREIGN KEY REFERENCES Client(id_client),
id_service INT ... |
My program....
Downloads a file
Connects to a server
If one of these operations were to fail, the program stalls for a minute and goes back to step one.
So, I would avoid recursion and the use of global variables. I think I did the first one right, but I need help to avoid the second one. What would I do if I need to... |
It's been a while since I last wrote some lolcode, so I felt like tackling Project Euler #1.
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
This is the code/script I wrote to solv... |
For one of my [WIP] project, I extended the dictionary class a lot with specific handlers, as such I determined that I wanted KeyError and TypeError exceptions to be specific to my project's parser. I extended the exception class like this:
Github Permalink
"""Exception classes
"""
class ValveException(Exception):
... |
I just finished working through Exercise 16 of Learn Python The Hard Way.
To further study, I wanted to create a script that will read and display a file's contents on screen, and then have the user re-write the file with three lines.
Can my code be written in a much cleaner, pythonic way?
from sys import argv
script,... |
First LOLCODE program, run here. This program inputs a Fibonacci number from the user, then determines and prints whether the number is in the Fibonacci series. What do you think?
HAI 1.2
HOW IZ I GetNum
VISIBLE "Entr yr numbr: "
I HAS A WatzNum
GIMMEH WatzNum
FOUND YR WatzNum
... |
Is there a neater way to write this code?
var table, field, dbFieldEntries;
var s = 'one.two';
// The DB field is always the first parameter
dbFieldEntries = s.split( '.' );
if( dbFieldEntries.length === 1 ){
field = dbEntryEntries[ 0 ];
} else {
table = dbEntryEntries[ 0 ];
fi... |
def smoothen(heightProfile, travelTime):
newHeightProfile = []
# Berechne einen gleitenden Mittelwert
smoothingInterval = 30 * travelTime
for i in xrange(smoothingInterval):
heightProfile.append(heightProfile[-1])
for i in xrange(len(heightProfile) - smoothingInterval):
mean = 0
... |
As a programming exercise, I've attempted a Tic-Tac-Toe solver which takes a finished board and determines a winner.
On top of checks for malformed input/ambiguous games (e.g. both players with winning positions), what else can I do to improve this? In particular, is the coding style acceptable and are there better w... |
The Edmonds-Karp algorithm relies on breadth-first search in order to find an augmenting path in the residual flow network. This version of the algorithm uses bidirectional breadth-first search in order to speed up the entire algorithm. My profiling reports consistently speed ups of at least 3.
The files DirectedGraphN... |
Very useful operation that hasn't been merged into a function.. until now.
This is supposed to insert a substring into a previously d.allocated source string.
void strapp (char *source_offset, int position, char *appendage)
{
size_t appendage_size = strlen(appendage) + 1;
char copy[strlen(source_offset)];
... |
I am building a PHP framework and would like to get some feedback on a few different sections of the project. I consider myself still a neophyte in PHP so I would like to ask if I'm going about completing these different tasks in an efficient and or correct way.
I have create two classes, initializer and Loader. The i... |
I wrote a minimalistic thread pool using some C++11 features. I've used it on two projects so far and it has worked fine, but when I ran the code on my laptop, I believe that my thread pool might be entering some kind of dead-locked state -- occasionally the CPU activity drops to almost nothing, and the program hangs.
... |
This is more of a 'model' of TicTacToe, as you'll see it's not "gameified" in the sense that it will allow for inputs and outputs nor will it record any "active" state of the game but those things are trivial to implement.
I'm cheating a little bit on the functional paradigm in my function to rotate the grid, but this ... |
I'm visiting some code that I wrote for one of my finals projects and wanted to know whether there were a more optimal, more elegant way to do this so it does not look so "hard-coded".
The problem was that I needed to calculate the Determinant of a matrix, and, at the time (some of it was rushed) I did not know of a be... |
I'm using jquery and cookie.jquery to remember the scroll position. Is there anything I can do to improve my code? Thanks!
$(document).ready(function() {
// convert cokkie variable for easy access
var prev_scroll_position = $.cookie('prev_scroll_position');
// scroll to position
$(window).scrollTop(pr... |
I'm just starting to learn JavaScript. I implemented the Diamond kata, and I would appreciate if anybody could give me some feedback. I'm particularly concerned about learning the most 'idiomatic' way to do things in JavaScript, style conventions, etc.
The diamond kata consists of the following problem statement:
Give... |
This may be a bit overwhelming, but me and a friend of mine have written a Database class with methods for our queries. All of these queries should be generic so we can use them in multiple ways. We make use of PDO.
These are the thing bothering me;
We need a session class to handle all the sessions within our classes... |
For the problem given:
Douglas Hofstadter’s Pulitzer-prize-winning book, Gödel, Escher, Bach, poses the following mathematical puzzle.
Pick a positive integer \$n\$ as the start.
If \$n\$ is even, divide it by 2.
If \$n\$ is odd, multiply it by 3 and add 1.
Continue this process until \$n\$ is 1.
The thesis is... |
I am creating a shopping cart application to learn Spring MVC. I want to display a list of all categories and subcategories in more than one page. i.e; Home Page, Products page, and Category page.
In the Home Page controller I am retrieving the list of categories, subcategories and featured products and passing them to... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.