instruction stringlengths 71 39k |
|---|
I've been studying hard and asking a lot of questions - I finally came a cross an exercise in LYAH that looked like it was easy enough but a perfect candidate for practicing.
The below program has a bunch of helper funcs in there, but the one of interest is neighbors/3. It takes a Pair type and Edge number, and a BiMo... |
At the moment I am using this to check a boolean property in sharepoint 2007 using C# and .Net Framework 3.5
if (bool.Parse(listItem.Properties["Boolean Property"].ToString()) == false)
is there any better way of doing it ?
Edit
when my code try to convert property into string it gives me exception even when am valida... |
I've had some help designing my field boxes and I was hoping to get feedback on the code. The fields will increase in complexity which is why I thought to structure it this way (image upload fields, textbox with WYSIWYG controls etc.
CSS
.error { height: 27px; background-color: red; margin-bottom: 4px;}
.lft { float: ... |
I wrote my own exception class, deriving from std::runtime_error to have Error-IDs, timestamps and inner exceptions. It seems to work, but are there any drawbacks?
The only thing I see is the deep-copy in the copy-constructor, which is not efficient, when there are many nested exceptions. But exceptions should be rare ... |
I'm trying to get my head around object oriented programming, and I'm starting in JavaScript. I have put a working demo of my code on JSFiddle (here), but the class is below.
My main concerns are that as soon as the object is called with a constructor, all the properties are populated straight away (there are no method... |
I have based my code off several tutorials which has culminated what I think is quite a complicated CSS layout. It has a docked footer. The sidebars are turned on dynamically in my template depending if there is content. The site is designed to work in the following scenarios:
1 Column
No div class lft
No div class r... |
I am still learning OOP and I need a little help, I don't really know how to properly make this not look so terrible.
Any thoughts?
<?php
class Noti {
public static $app;
public static $user;
public static $url;
public static $result;
public static $data;
public static $title;
public stati... |
What should I use to cache the result so that it takes less time to search? It currently takes a large number of minutes to complete 10000 test cases with range 1-99999999999999 (18 times 9 - the worst case), even though the search values have been hard-coded for testing purposes (1600, 1501).
Set<Integer> set = new T... |
I have created a simple ArrayList with some methods from the actual ArrayList in Java.
I am testing this for mistakes, but I am learning Java and my tests are maybe not comprehensive.
public class SJUArrayList<E> {
// Data fields
private E[] theData;
private int size = 0;
private int capacity = 0;
... |
I am making a stats page for my Android game, and I have never really used the Android XML layout stuff, so I'm sure things are a little messy and strange. The layout ends up looking pretty good, and I'm just seeing if I can remove some of the repetitive crap and maybe better understand some of the stuff I did that se... |
I'm implementing a variation of the SuperFastHash in VBA for use in Excel (32-bit version, so no LongLong available) to hash strings.
To get around the limitations of signed 32-bit Long values, I'm doing the addition and bit-shifting using Double types, and then converting from Double to Long in a way that truncates it... |
How should I make this more Ruby-like or just "better"?
def password_format_is_valid?(submitted_password)
#Gets regular expression for password format validation from settings and applies it
regex = Regexp.new(Setting['global_admin.password_format_regex'])
if submitted_password =~ regex then
return true
el... |
I am trying to write a price calculator for proof reading using javascript. It works but I am sure that my code could be improved quite a bit.
The concept is as follows:
There are three factors affecting the price:
word count
proof reading type
timeline (how quickly the document is proof read)
The user enters a word... |
I threw this together for a web dev class I am taking at school and I thought I'd throw it up to see what criticism I could get on my JavaScript, design, whatever.
Bonus points if you can tell me how I can fix the bug with users clicking to quickly and more than two cards flipping at a time.
Disclaimer: I know that I l... |
Gentlemen!
So what I have here is a function who's main purpose is to check whether an attribute exists and if so add it to another list for a maximum of 3 entries. The first item in the list should always be checked while the rest of the list should be inserted into the new list randomly.
ex:
Old List: 0, 1, 2, 3, 4... |
Gentlemen!
I am hoping to find a more efficient (less hairy) way to do the following code.
The public interface will call calculateListItemValue and pass the following variables
$source_list: stdClass() with a structure similar to List JSON below.
$target_list: stdClass() with a structure similar to List JSON below.... |
Here's a bit of one of my web forms which is reached by clicking on a link in a calendar. Based on what you click, you end up at this page with a different QueryString. Based on that QueryString, we hide/show and enable/disable controls related to actions associated with the QueryString, as well as the role of user.
... |
What is your opinion on method ordering?
Should it be public methods at the top followed by private methods?
or
Should it be linear order so that methods calling methods stack on top of each other?
Which do you think is better for maintainability / readability?
Examples
Public first:
public class Main {
@Override
... |
I have a node template that grabs fields from a content type.
In the node--[contenttype].tpl.php file I have two sections (The second is html/php and grabs variables from the first section or from the content type and simply displayed it).
The first is strictly php and does three things:
Grabs numbers from one of the... |
I'm using twitter mobile and I have a login-dialog. login-Dialog is a modal dialog. To call it the user calls loginDialog.show();
I'm not all that comfortable with the coding style I've adopted (i'm very much self schooled in JavaScript) and I'd be interested to hear peoples opinions on the code structure and process... |
As I was working with .NET, I started wondering how I would implement the LINQ methods syntax in Javascript. So here is my first try; is there a more elegant, or more performant, way to write this code?
// usage : the functions take a predicate function as input and modify the array accordingly
var collection;
(functi... |
I have just created my first jQuery plugin. I am looking to suggestions on how to improve it, leading to a code optimization.
(function($) {
var plugin_name = 'W.jQuery.FieldEvents';
var name_space = 'wFieldEvents';
var methods = {
init : function(options) {
return this.each(function(){
... |
I have the following code that unfortunately is really slow:
private void FilterSessionByDate()
{
SessionsFilteredByDate =
BusinessClient.Instance.Tracker.GetAllMilestonesInSessionObjects().Where(
i => i.CreatedDate >= GetFromDate() && i.CreatedDate <= GetToDate());
}
private void FilterSessionsB... |
I've got a code that is working in my environment.
Nevertheless it is pretty ugly.
This is what I am trying to do.
I get a selectbox from a side with a lot of city names.
I filter some names and push them into an array and hide them. The other ones are also pushed into an array, but shown.
Now I append two options to t... |
Writing my first ASP.NET Web API web service. Still learing the power of Linq as well. I feel like there is a more ideomatic way of doing this:
public class StylesController : ApiController
{
private Entities db = new Entities();
// GET api/Styles
public IEnumerable<Style> GetStyles(int division = 0, int f... |
I have a STI table and want to be able to render a collection using
render @collection
with every elements of the collection using their own partial or, if they don't have one, the parent partial. You know, partial inheritance.
So I added to my parent model :
def to_partial_path
self.class._to_partial_path
end
pr... |
Is there a cleaner way to do the following?
friend_ids = [1,2,3,4,5]
friendIDsQuery = ""
friend_ids.each_with_index do |friend_id, index|
friendIDsQuery += "SELECT id FROM test WHERE user_id = #{friend_id}"
if index != friend_ids.size - 1
friendIDsQuery += " INTERSECT "
end
end
Basically I'm passing in an a... |
This code works, but I'm sure it isn't written according to "best practices" for closures. On the other hand, at least it's intuitive to me...
the taskRunner object runs functions on setTimeout, so as not to block the UI for too long. I'm breaking this function into chunks and running one chunk at a time. I'm passi... |
I have created a simple array-based Stack class with some methods like the actual Stack in Java.
I am testing this for mistakes, but since I am learning Java, my tests may not be as comprehensive as they should.
import java.util.*;
public class SJUStack<E> {
// Data Fields
private E[] theData;
private int ... |
How can I refactor this redundant code?
$("#txtShippingAddressFullName").change(function () {
$("#txtBillingAddressFullName").val($(this).val());
})
$("#txtShippingAddress").change(function () {
$("#txtBillingAddress").val($(this).val());
})
$("#txtShippingPostalCode").change(function () {
$("#txtBillingP... |
The problem presented to me:
Declare a two-dimensional array of ints in main. Write a method to read in the size of each dimension, allocate memory for the array and return it (DON'T DO THIS IN MAIN, BUT CALL THIS METHOD IN MAIN).
Write another method to initialize each element to the sum of its indices (for example... |
I am currently using this code, but I am pretty sure there is a better way of doing it:
private string ReturnEmployeeName(string userName)
{
try
{
// Username coming is RandomDomain\RandomLengthUsername.whatever
string[] sAMAccountName = userName.Split('\\');
return sAMAccountName[1]... |
I am trying to write a generic JavaScript subroutine to set the periodicity in the week:
var items = {"0": "none", "1":"Daily", "2": "Every weekday (Monday to Friday)", "3": "Weekly"};
I would like to improve this to make it more generic and readable if possible.
var callback = selectDay(idValue);
createSelect(items,... |
I've spent a few days making the transition from WinForms to WPF, and do not have much time for tutorials as the work needs to be done quickly. I was wondering if anyone could take a look at a sample of my code and point out any conventions that I'm missing (and that are commonplace in modern WPF usage). I've picked ... |
A question was asked over at math.SE (here) about whether or not there are infinitely many superpalindromes. I'm going to rephrase the definition to a more suitable one for coding purposes:
Definition: A superpalindrome is a product of primes p(1) * p(2) * ... * p(k), where p(i)<=p(i+1) for 1<=i<=k-1, such that p(1)... |
I have two choices of implementing a method, the first one is a generic type where the client code does not have to cast
public T GetControl<T>(string controlName) where T : Control
{
return (T)ControlManager.GetControl( controlName);
//I simplify the logic here, in my case this is a bit
... |
I'm currently writing some code in PyQt4 that takes a value and a control and binds the value to the control. Once the user saves the form it will unbind all the values and save it back to a custom object (in this case QgsFeature).
At the moment, I have the bind and unbind code which uses if/elif statements to work ou... |
I don't like how this config has so much duplication. Any suggestions on how to at least shorten it somewhat? Normally we only have one server block as the staging server is separate from production, but the client has gotten their own server so we'll need to stage on that.
upstream upgrade-release{
server 127.0.0.... |
I've read a lot about using MVC in game development and it seems to be a good way (speaking of testing, code reusing, etc ...)
I created a XNA project and tried to implement MVC. But I'm not sure if I'm doing it right.
I seperated the game into three blocks:
Renderers (the "View")
GameObjects and GameLogic (the "Model... |
I've written the following function to parse a configuration file. I did my best to make it simple, but it's still over 30 lines and has too much indentation caused by a series of if statements.
Any suggestions make it easier to read are welcome.
int
parse_config (FILE * conf_file, module_initializer_t init)
{
char *... |
It's common pattern when you need to assign a variable inside a block
def query(sql)
logger.debug "Db: Executing query #{sql}"
result = nil
ts = Benchmark.realtime do
result = @db.exec sql
end
logger.debug "Db: Query completed in #{ts}"
result
end
Is there a more elegant way to rewrite this snippet?
|
I'm binding a handler to the keyup event of all input and textareas in a document:
$(document).on('keyup','input,textarea',$.debounce(600, editor.handleGlobalChange));
I don't want the handler to fire on a specific input field. So I want to unbind the keyup event:
$('#afield').off('keyup');
However this does not unbi... |
I am trying to get into C stuff, and I thought it would be a good idea to try and implement a circular buffer.
I have defined my struct like this:
typedef struct
{
int8_t* buffer;
int8_t* buffer_end;
int8_t* data_start;
int8_t* data_end;
int64_t count;
int64_t size;
} ring_buffer;
And th... |
I'm trying to reproduce the Google Schemer (schemer.com) effect they use with their buttons for indicating a user wanting to do something/already doing something. I more or less got it replicated but it seems like the amount of code is a bit much.
JSFiddle
Does it seem like too much code for something that seems to be ... |
I have this class that has these two methods that are so closely related to the each other. I do not want to pass the flags so I kept them separate. I was wondering if there is a way to rewrite it so that I do not have to repeat so closely!
class Test extends Controller
{
public static function nonFormatt... |
I'm pretty new to JQuery, maybe a week's worth of experience, but I'm having a lot of fun so far. One of the things I thought I would give a shot is attempting to implement a custom CMS for my current project. And it's going fairly well. So well in fact, that I thought I would start adding some nifty little features an... |
I have the following code:
The HTML part consist of two containers. Both containers have a list of hour and day weeks.
This code is used to manage these lists of inputs.
The JavaScript code works but I am wondering if it is possible to improve it, because the JavaScript code consists of around about 230 lines of... |
I wrote a class that uses RestSharp to access Rest and HTTP API web services. I tested it and it works however I was wondering if any changes could be made to it to make it better.
public class RequestHandler
{
//Client to translate Rest Request intot HTTP request and process the result.
private RestClient clie... |
This is a CodeEval challenge taken from here:
Challenge description:
Imagine we have an immutable array of size N which we know to be
filled with integers ranging from 0 to N-2, inclusive. Suppose we know
that the array contains exactly one duplicated entry and that
duplicate appears exactly twice. Find the dupl... |
I would like to write a python or c++ function to print numbers like the following examples (with n as input parameter):
When n = 3, print:
1 2 3
8 0 4
7 6 5
When n = 4, print:
4 5 6 7
15 0 1 8
14 3 2 9
13 12 11 10
I have an answer in the following code block, but it is not quite elegant. Does anyone have a be... |
Is my following (very basic) class considered good use for PDO integration?
Or is there a better, more efficient way?
class Page {
public $title;
public $db;
public function __construct($title) {
$this->title = $title;
}
public function connect($host, $dbname, $username, $password) {
... |
I'm hoping that the more experienced devs here can help me improve these methods. I'm building a basic MVC framework for myself (as a learning project,) and I'd really appreciate your insights. Things I'm looking for specifically are:
Efficiency: can these methods be improved (particularly with the Request:parseURI() ... |
I have a Windows-service and this service will connect to an ftp server and do download, upload, and rename operations.
My service runs every 30 seconds, so the ftp server will be busy during these operations.
My question is: is my code useful for this job? Because my download/upload/rename functions open a webrequest ... |
I currently use setInterval and a wait flag to process this collection. Is there a cleaner way?
var wait = false;
var processInterval = setInterval(function(){
if(!wait){
var currentVideo = videos.shift();
if(currentVideo){
wait = true;
validateSongById(currentVideo.videoId... |
What I can think of improving is:
Show stack on screen to fail gracefully i.e. improved catch part of try..catch
Make the try part shorter to improve readability
Make imports with * to improve readability so you don't have to import the same package twice
Source code:
//source is probably public domain since prv.se i... |
Examples:
char test1[] = " ";
char test2[] = " hello z";
char test3[] = "hello world ";
char test4[] = "x y z ";
Results:
" "
" olleh z"
"olleh dlrow "
"x y z "
The problem:
Reverse every world in a string, ignore the spaces.
The following is my code. The basic idea is to sca... |
I often find myself writing code as follows...
var startX, startY, dragging = false, element = document.getElementById("whatever");
var start = function(e){
dragging = true;
startX = e.pageX;
startY = e.pageY;
element.style.opacity = 0.5;
}
var move = function(e){
if (!dragging) return;
var deltaX = start... |
Problem:
Given a randomly ordered array of n-elements, partition the elements
into two subsets such that elements <= x are in one subset and elements
x are in the other subset.
One way to do this is to sort the array in ascending order. But with
this solution we actually ordered the array in addition to partitio... |
This function checks if an attribute has been passed and if not, asks user for input.
I'm new in bash scripting and would like to get some feedback. Is it okay or should I refactor this code somehow to make it more concise?
#!/usr/bin/env bash
fn() {
if [ -z "$1" ]; then
read -p "username:" username
el... |
I've created this fiddle to demonstrate something I've been working on. I've been trying to mimic the behaviour of Twitter where if a tweet is expanded, the border-radius and margins of the previous and next tweets are altered.
I've used toggleclass to get this working. I would like advice about how to clean up my code... |
This is what the code should do:
Check if the first dimensions and the second dimensions of each 2-dimensionalarray are the same. If they are not the same, then return a 0x0 2-dimensional array. array, otherwise do the following;
Allocate memory for a local 2-dim. array with the same dimensions as one of the 2-dim. a... |
Below is my attempt at the beginnings of a reusable ado.net data access class. Please let me know of any improvements that I could make.
Thanks!
public class DataAccess : IDisposable
{
public DbProviderFactory Factory { get; set; }
public string Connection { get; set; }
public string ProviderName { get;... |
I have been programming in C++ for around a month now, just long enough, I figure, to develop bad habits. Can anyone point out where I'm making mistakes and offer topics I should investigate to understand why?
#include <iostream>
#include <cassert>
#include <sstream>
#include <string>
using namespace std;
string get_l... |
I would really like to hear how I can improve my form validator. Next, I want to refactor it into OO and learn a testing framework like Jasmine.
Some things I know I could improve:
Don't make it tied to the DOM as much (using parent().parent(), for ex.).
Combined validations can't be used. For example, using isBlank a... |
I updated my code according to a few suggestions from my last post, so I thought I'd repost it to see what other feedback I could get. I also commented it heavily and fixed some of the functionality.
One question I do have is what is the difference between defining a function by doing
var funcName = function(){};
ra... |
I have created iterator and generator versions of Python's range():
Generator version
def irange(*args):
if len(args) > 3:
raise TypeError('irange() expected at most 3 arguments, got %s' % (len(args)))
elif len(args) == 1:
start_element = 0
end_element = args[0]
step = 1
else:
start_element ... |
I have a use case where I want to use both HttpRequestInterceptor and HttpResponseInterceptor in one class.
I'm asking if the following would be a good solution and what are the potential problems?
public interface HttpRequestResponseInterceptor extends HttpRequestInterceptor, HttpResponseInterceptor {}
Then I imple... |
This is a Java method that takes as input a 2 dimensional array called grid.
It uses the i1 and j1 values from when the corresponding grid[i1][j1] position is true for the first time, and then i2 and j2 from when the corresponding grid[i2][j2] position is true for the second time.
A call is then made to drawLine(i1, ... |
I'm trying to make a Node.js server as minimal as possible to show a landing page, but i'm not sure this is the greatest and fastest way to do it.
I'm using dirty to store my html data.
My app.js file
var http = require('http')
, db = require('dirty')('pages.db')
, url = require('url')
, fs = require('fs');
http.creat... |
I had an exercise as below for an interview. I used two design patterns: factory and decorator. I put my code at the end of it.
How could I improve the solution?
Basic OOD & Solution Design Requirements
Develop a simple Visual Studio CONSOLE Application which simulates a vector-based drawing package.
Your applicatio... |
selected_hour=12
dates=[]
date1 = datetime.datetime(2012, 9, 10, 11, 46, 45)
date2 = datetime.datetime(2012, 9, 10, 12, 46, 45)
date3 = datetime.datetime(2012, 9, 10, 13, 47, 45)
date4 = datetime.datetime(2012, 9, 10, 13, 06, 45)
dates.append(date1)
dates.append(date2)
dates.append(date3)
dates.append(date4)
for i in ... |
I'm making a converter app, and after realising I would have to type about 200 lines of code to get it working with more than 5 units converted, I should have a better conversion calculation.
What I have currently is a ifelse that find out what units i selected from the wheel, a sting to find out what it should answer ... |
Compute the number of connected component in a matrix, saying M. Given
two items with coordinates [x1, y1] and [x2, y2] in M, if
M(x1, y1) == -1 and
M(x2, y2) == -1 and
|x1-x2| + |y1-y2| == 1
then they are connected.
Example:
-1 0 -1 0 0
-1 -1 0 -1 -1
0 0 0 0 -1
0 0 0 -1 -1
0 0 0 -1 0
0 -1 0 0 0... |
Which of the following way of checking whether a function returns TRUE or FALSE is best, in terms of efficiency and code readability?
I was told by a friend that Method B is a good practice, but I believe Method A is better since it checks whether function returns TRUE then assigns.
Method A: (Checks whether function i... |
Its working but I don't think its the best way of doing it. I also changed variable names just to let you know,
string [] columnN = AnotherString.Split(','); //Another String is something like this = "HEhehehehehE heeh, aSKdjhkaaksjd, asldkhja slkdlk, asdajsdlka, asdljkasd, asdkasjdasd, asdasdasdl, askdjasd"
... |
I'm writing an ORPG. The code below is client-side.
I have a main thread looping in Game::Run:
Game::~Game()
{
PopAllStates();
}
void Game::Run()
{
sf::Event Event;
while(Window->isOpen())
{
if(LoadQueueMutex.try_lock())
{
while(!LoadQueue.empty())
{
... |
I need to check if a map is subset of another map. For this, I have written the following code:
#include <string>
#include <iostream>
#include <map>
using namespace std;
/**
* Checks if rhs is a subset of lhs
*/
template<class Map>
bool map_compare(Map &lhs, Map &rhs)
{
if(rhs.size() > lhs.size() || rhs.empty()... |
I have a relatively simple project to parse some HTTP server logs using Python and SQLite. I wrote up the code but I'm always looking for tips on being a better Python scripter. Though this is a simple task and my code works as written, I was hoping for some pointers to improve my coding ability.
import re
import sqlit... |
The following code is a simple random password generator that spits out a randomized password based on some input flags.
import string
import random
import argparse
def gen_char(lower, upper, digit, special):
_lower_letters = string.ascii_lowercase
_upper_letters = string.ascii_uppercase
_digits = string.... |
The Monty Hall Problem is a simple puzzle involving probability that even stumps professionals in careers dealing with some heavy-duty math. Here's the basic problem:
Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say... |
I'm a Clojure n00b (but am experienced with other languages) and am learning the language as I find time - enjoying it so far, though the strange dreams and accidental use of parenthesis elsewhere (e.g. Google searches) are a bit disconcerting!
Usually when learning a new language the first thing I do is implement Conw... |
Previously I asked a question on how to group dictionaries in a list in a hierarchical structure.
Initially I wanted to group a list of dictionaries that looks like the following, using multiple keys:
[{'dept':1, 'age':10, 'name':'Sam'},
{'dept':1, 'age':12, 'name':'John'},
.
.
.
{'dept':2,'age':20, 'name':'Mary'},
{'d... |
What is the simplest way of hiding labels and inputs in a way that they do not affect the layout. See image and the code below. The label text3 is hidden and there is no extra gap between text2 and text4. In this implementation I put both in div container and change its .style.display property.
Edit: the figure is exca... |
I would like to get some feedback on the following implementation of disjoint sets, based on disjoint-sets forests (Cormen, et.al., Introduction to Algorithms, 2nd ed., p.505ff). It should have the following properties:
Abstracts away all internal data structures and can be used to create disjoint sets of any type T
S... |
I am trying to write a merge sort algorithm. I can't tell if this is actually a canonical merge sort. If I knew how to calculate the runtime I would give that a go. Does anyone have any pointers?
public static void main(String[] argsv) {
int[] A = {2, 4, 5, 7, 1, 2, 3, 6};
int[] L, R;
L = new int[A.length... |
Below is a module that executes a sequence of actions in any possible order. LANGUAGE_DataKinds and LANGUAGE_DefaultSignatures are predefined cpp symbols.
Is this permutation applicative/monad implementation clear? I am particularly concerned about the use of DataKinds and GADTs, and if I should instead split it in t... |
I have the following code:
var sessionsWithError = SessionsFilteredByDate
.Where(i => i.TrackerId > 0 && i.StatusId == 0)
.Select(i => i.SessionId);
var sessionsWithErrorFixed = BusinessClient.Instance.Tracker
.GetAllTrackerAttempts()
.Select(i => i.SessionId);
var sessionsWithErrorIntersection = sessio... |
I have just started learning some Scheme this weekend. I recently solved a problem that goes something like:
Count the number of ways possible to give out a certain amount of change using
1 5 10 25 and 50 cent pieces.
--SICP 1.16
So my code to this question looks like this:
(define (make-change amount)
(define coin-... |
The following code works but I am wondering if it can be improved both readability and performance.
I am using jquery and underscore.
Any suggestions, comments or feedbacks will be appreciate.
thanks.
var getThemeName = function (theme_name, transparency) {
if (theme_name === 'light') {
if (transparency) {
... |
I'm trying to write a Python module to handle matrices. (I know about numpy, this is just for fun)
So far I have written a few classes, Matrix, Dim, and Vec. Matrix and Vec are both subclasses of Dim. When creating a matrix, one would first start out with a list of lists and they would create a matrix like:
startingLi... |
I have an instructor who is very stringent on makefiles only containing rules and dependencies that need to be included.
The structure for the program is very basic. The requirement is to produce two executable files: a3b and a3m. There was some code duplication, so I included that in a source code file called myarr... |
I'm in the process of building a small application and obviously I need some sort of way to authenticate users. I'm not sure if I am way off or if this is close to what I should be thinking. Please let me know what you think...
<?php
class Authentication_controller {
private __constructor() {
include(Authen... |
I am writing a simple script to automate my regression testing. I am new to bash scripting and my goal is achieve the most efficient and clean code. I have written a simple function to allow me to select which subject I would like to test. This will loop until I select the exit option. Again, this is quite simple; howe... |
I am trying to generate LCM by prime factorization. I have already done the other way around to generate LCM using GCD but I am trying to achieve it using prime factorization.
I am getting right prime factors but the problem is that to generate LCM we need to multiply each factor the greatest number of times it occurs... |
I have the following class inheritances hierarchy:
First the abstract parent class:
<?php
abstract class SegmentParserAbstract{
/** @var ParserResult */
protected $_result;
protected $_invalidSegmentMessage;
protected $_segmentRegex;
protected $_segment;
abstract protected function createSegmentObject();
public functi... |
I tried to implement an unrolled linked list in C#. I only needed to add things and clear the whole list so I didn't implement IList<T> (I tried but it was getting too complex, so I postponed it).
Why I did it?
I needed a collection that should be able to handle millions of items and I was getting OutOfMemoryExceptions... |
I have to select all the rows from a database table containing a defined (long)sessionId where the sessionId row is indexed.
But it is slow, and since the code to access it is really simple, I'm wondering where the problem is. Here is the code of the three layers:
var localPath = BusinessClient.Instance.Tracker.GetSpec... |
This presumably simple task resulted in much more scripting logic than I thought would be necessary.
Goal: when the user clicks a button inside one of the divs, it affects said div.
Issues: I did not wish to have my function target specific elements in my DOM. (ex. targeting <a> by ID). Also, because my function is tra... |
I need to upload some images to a server. This is done with a json object. The json object has 2 values, a timestamp and a Base64 encoded string of the image. I am using the jackson library and was wondering if this is a good way to upload the images. I am worried about memory consumption if I happen to upload images a... |
I haven't studied a lot about positioning of controls in ASP.NET using .Net framework 3.5 but still I know following control positioning technique isn't the best one, just to mention its a user control,
<asp:Label ID="Label2" runat="server" Text="Number of Days"></asp:Label>
&nbs... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.