instruction stringlengths 71 39k |
|---|
I've written the following explode function using break. The intended behavior is, that a list is divided into sublists by a predicate function, i.e. those elements which match the predicate are the separators - no empty lists should be returned.
Here are some examples:
explode id [True, True, False] = [[False]]
explod... |
Inspired by this post (along with a number of other people by the looks of it), I created a poker hand identifier with a very similar format. Note that the syntax of the hands is a little different to make parsing easier - rather than "A:C K:C Q:C J:C 10:C", the input is of the form "[(A,C),(K,C),(Q,C),(J,C),(10,C)]".
... |
Bell number \$B(n)\$ is defined as the number of ways of splitting \$n\$ into any number of parts, also defined as the sum of previous \$n\$ Stirling numbers of second kind.
Here is a snippet of Python code that Wikipedia provides (slightly modified) to print bell numbers:
def bell_numbers(start, stop):
t = [[1]] ... |
I have to interface to some old code using nested arrays, so I have to convert my nested Lists to nested arrays. Any idea, suggestions, improvements are warmly welcomed.
public static <E> int getNestedListMaxSize(List<List<E>> list){
int result = 0;
if (list != null && list.size() > 0){
for (List<E> inn... |
Im working on a small desktop app which controls services on a server. For controlling services i am using ServiceController class. What i want to do is; testing my code and abstract the ServiceController class from my code. So i did something like below.
public interface IServiceControllerWrapper
{
st... |
I want to create lists of the nodes of a binary tree at each depth.
So if the depth is X I would have X lists.
Please see my approach. I think it is correct. Am I right to believe it is correct? Any input is welcome:
public List<List<BinaryNode>> getNodesPerDepth(BinaryNode root){
if(root == null) {
... |
This is for a plugin I am making for the game called Minecraft. The code is responsible for finding out the blocks placed by the player and if they are in the following sequence as shown in the picture then create an Antenna. block in block.getType() returns the block placed by the player. Also, it doesn't matter in wh... |
I'm switching to Ruby from Java and so, for exercise purposes, I wrote this verbose leap year Ruby program. The comments express my concerns about Ruby best practices. I'd be glad if some Ruby experienced programmer could dispel my doubts. Every hint such as "in Ruby you can achieve this thing better this way" is truly... |
I needed to build a slider, and this is my first attempt. I'm trying to make it as dynamic as possible. My code works, but I'm wondering if there is a better way and if anyone has any suggestions. I'll be making the width calculated as well. I just have it hardcoded for testing.
Also, I need to make pagination for this... |
I have 30 icons, and after hover, different icons are shown. How can I write this shorter?
jQuery
$('#iconTech01').hover(
function() {
$('#iconTechBig01').stop(true, true).fadeIn("slow");
$('#iconTech01 img').stop(true, true).fadeOut("slow");
},
function() {
$... |
The reason why I want to have something like this is to be able to add custom methods/props to certain arrays only. I came up with this little object that works well but I'm wondering if you guys have better way.
(function (scope) {
var target = scope || window;
target.Hurray = function() {
this.length... |
Edit
The rest of my code utilises the Command/Query seperation pattern. I'll probably move this out into a command and a query but for now I've written this directly in my MVC controller for brevity.
Original
I'm quite new to Fluent NHibernate and its various workings. This code is designed to receive an array of tag n... |
I need to pass an array of values in Url.Action.
Currently I'm doing:
var redirectUrl = Url.Action("search", new {
q = criteria.Q,
advanced = criteria.Advanced,
salaryfrom = criteria.SalaryFrom,
salaryto = criteria.SalaryTo,
});
if (criteria.JobTypes != null)
redirectUrl += c... |
I am not experienced in C++, and wrote this code for implementing a stack data structure using a linked list.
Can you please point out any flaws, errors, stupid mistakes, general improvements etc that can make this code better?
#include <iostream>
us... |
I was building a quiz module for one website. It is a simple true/false statements where you first choose the answer, the correct answer is displayed, and then you can move forward to the next question.
For better understanding, please find working code snippet here.
I need mentor guidance in order to make my existing... |
I wrote a factorial/permutations/combinations program in Java, and I want to do the same in C#. I noticed (from various research) that when you use the ulong variable type, the max value is higher than Java's long. My limitation in the Java version was that the long type was too small to do numbers like 30, or 100. ... |
I struggled a short while to make this work, so I'm wondering if there are any smarter ways for finding the highest of two values per array element? Uh, hard to explain by words, but by code its easy:
Data (random):
(a) (b) // a and b are both positive values.
10 0.5
13 10.8
8 0.123
9 0.123
... |
The Enumeration in question is based on int, so the following Extension returns a Dictionary<int, string> of the Enum's Value and Description.
Is there a cleaner way of implementing this?
public enum TeamDepartments
{
[Description("Geschäftsleitung")] Management = 1,
[Description("Verkaufsleitung")] Sales = 2
}... |
I have an extremely simple self-playing Tetris game which I coded up and I am looking to see how it could be improved. It would also be a learning curve for me to see how those much better than I am would go about improving the code.
###############################################################################
## an... |
I have a Windows application and want to self-host a WCF in it. This MSDN article walks you through how to self-host WCF in a console. Jason Henderson's article demonstrates how to call the service. But the problem is, I don't want to host my service in another Windows process. I want to host it in my client applicatio... |
I have a code snippet below and because of habit from other programming languages I wanted to use a do-while loop instead. But Python offers only the construct which I show as a second code snippet instead of a do-while*loop.
What is the best pythonic way to code this?
ch = getch()
while ch != "q":
do_something()
c... |
I am creating a skeleton application to demonstrate use of the Strategy design pattern and inversion of control inside a Strategy.
The application is the backend of a simple board game, which also has the capability to save and load the board. Since we can have different types of data stores for saving, I have used an ... |
The idea is to take the common-known (and awfully bad performing) Fibonacci(n) recursive method:
# recursively computate fibonacci(n)
def fib(n)
n <= 2 ? 1 : fib(n-2) + fib(n-1)
end
and to optimize it with some Ruby reflection:
require 'benchmark'
def fib(n)
# if n<= 2 fib(n) = 1
return 1 if n <= 2
... |
I am looking into splay trees and I implemented a version. It seems correct. Could someone please let me know if this indeed correct and how to improve it?
I will just show the insert item and splay. It should be enough.
The code is not that big as it seems in the first look. Briefly, I try to implement the splay tree ... |
The Demo for what I have made is located here: http://jsfiddle.net/maniator/H5LKy/181/
Basically I am trying to make a Wheel of Fortune type game.
Is there anything I could improve on in the code?
var WOF = (function() {
Array.prototype.randomize = function() {
this.sort(function(a, b) {
return... |
I need a way to store and retrieve callbacks in Ruby, so I made a Callbacks class. Any suggestions would be greatly appreciated.
class Callbacks
def initialize
# name: name of callback
# event: event of which it belongs
# callback: block to call
@callbacks = []
end
def add name, event, &block
... |
I am interested in printing all numbers that do not have a match in an array.
Example: 1,3,4,5,3,4,5,5,6 result 1,5,6
Please review my solution bellow. What would be a much better way for this? Any input on how to improve this is welcome
public static Integer[] outputSinglePair(Integer[] numbers){
if(numbers ... |
I've written a class for loading a template file and replacing the variables with actual data. Please review my code and suggest improvements.
<?php
/**
* This class will helpful for variable replacement from a loaded file
*
* @author V V R
* @version 1.0
*/
class Parser {
public $dir = "";
public $text =... |
I did a quick google search, and it didn't show up.
I haven't noticed it posted in pylint.py, or PEP8.py.
My emacs mode doesn't warn me if my imports are listed arbitrarily...does anyone do this?
import longest.modulename.first
import medium.sizename
import short
import sys
import os
from imports import go_at_the_bott... |
I have this custom IComparer I use to sort a list of SurveyResponse objects, but it seems really inefficient, both in terms of runtime performance, and code elegance and maintainability. I thought of implementing IComparable for each of these components, and each CompareTo knowing its "parent" to compare, but the sort ... |
I much prefer the Java enhanced for each loop, but I often find there are certain times where I need to break from a loop, take the following contrived example:
final List<String> strings = new ArrayList<>(
Arrays.asList(new String[] { "test", "new", "break", "notThere","last" }));
boolean found;
for(String s : st... |
What I'm asking for is the review of a particular implementation of the haversine formula, found under:
http://blog.julien.cayzac.name/2008/10/arc-and-distance-between-two-points-on.html
This site is linked under the wikipedia article: http://en.wikipedia.org/wiki/Haversine_formula
Problem: I get the wrong distance for... |
My co-worker claims that using a parameterized Like statement is equivalent to dynamic sql and won't have its execution plan cached for reuse. He says that using sp_executesql will allow the execution plan to be cached, increasing the performance of identical searches. However, in the context of this query, the argumen... |
I originally made this as a way to use character strings as a base-256 number, but then realized that I could turn it into a method for encryption instead. The only thing is that since I'm using a basic addition algorithm for the encryption process, I'm iterating through a string by one character at a time (which seems... |
I'm just starting to experiment with F# (from a C# background). I think I'm starting to get into the right way of thinking, but this code still seems pretty awkward. Is there a better (more terse) way to accoAny comments appreciated. (BTW, this is supposed to sum all even fibonacci numbers up to 4,000,000)
let rec f... |
I whipped this up last night and was wondering if anyone had any thoughts/comments on it; for example, on:
Code organisation
Coding style
Other improvements
Semantic errors
(ns tictactoe.core)
(comment "
Author: Liam Goodacre
Date: 03/06/12
This module allows the creation and progression of tictactoe games... |
I would like to know how I could improve my C# project. I'm not really sure whether or not I'm allowed to just post a link to the Google Code project here, so sorry if it's not allowed, I'll edit my question if someone tells me so.
http://code.google.com/p/simple-irc/source/browse/#svn%2Ftrunk
The reason I'm posting th... |
At the moment, I have this code:
(function() {
var lastSelectedIndex = -1;
function onSelTypeSelected() {
// #selType is a <select> tag
// var selType = document.getElementById("selType");
var selType = this;
// finished(onSuccess, onError)
loader.finished(function(data) {
lastSelectedIndex... |
As a part of picking up concatenative programming, I decided to implement the common concatenative operations in PostScript. Here is my attempt at implementing some of the words in other concatenative languages in PostScript. Would any one who is familiar with PostScript and functional/concatenative programming comment... |
I have written following small utility to abstract away the lazy initialization logic. (I tend to use lazy variables quite often.)
Are there any issues in this implementation?
// File: F0.java
public abstract class F0<A> {
public abstract A apply();
}
// File: Lazy.java
public class Lazy<A> {
private boolean isIni... |
I am writing my own website where users sign up. It then saves that data in an array. I want to know if this is effective or if there are better ways to do it.
var isLoggedOn = false;
var numberOfUsers = 0;
var users = new Array();
var correct = false;
var currentUser = new User();
var date = new Array();
var userNumbe... |
I have files containing data sets which contain 11,000 rows. I have to run a loop through each row, which is taking me 25 minutes for each file.
z <- read.zoo("Title.txt", tz = "")
for(i in seq_along(z[,1])) {
if(is.na(coredata(z[i,1]))) next
ctr <- i
while(ctr < length(z[,1])) {
if( ( ab... |
I'm an amateur coder writing a geometry library in Python, and would like some feedback regarding my implementation of a class for 3D Vectors.
My priority is to have a really friendly API for beginners who are just starting out writing code, to build it with as few dependencies as possible (no numpy or scipy), and for ... |
I'm trying to write a Java program that, given a particular number of groups and number of total participants, creates a list of all possible ways to fill that number of groups evenly using all the participants. The group number/order doesn't matter. For instance, if {} denotes one possible way to create a set of group... |
Is this a reasonable C++ wrapper function for Python's "list.count([character])" method?
int count( char CHAR, string STR ) {
int counter = 0;
for ( int i = 0 ; i < STR.size() - 1 ; i++ ) {
if ( STR[i] == CHAR ) {
counter++;
}
}
return counter;
}
//Edited "for( int i = 0 ; i... |
I'm just trying to see if there's a better way to write the code between the asterisk markers.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Activate extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('users/usersmodel');
}
p... |
I have files containing data set which contain 11,000 rows. I have to run a loop through each row, this is taking me 25minutes for each file.
I am using following code:
z <- read.zoo("Title.txt", tz = "")
for(i in seq_along(z[,1])) {
if(is.na(coredata(z[i,1]))) next
ctr <- i
while(ctr < length(z[,1])) {
if(ab... |
In my last question on Stack Overflow I was a very confused newcomer about classes and OOP and how to correctly implement everything to make things easier. So I started a different example to practice.
This has the classes of a band and person. The people audition but only some get in and the rest leave to form their ... |
Here's one more controller I'm trying to get reviewed for. Any thoughts?
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Login extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('users/usersmodel');
}
public function index()
{
... |
Assume the following situation: you have an object that can store any object based on a key (basically, IDictionary<string, object>). You want to store objects of various types into it that are not directly related. (For example, the dictionary can be an ASP.NET Session, or it can represent a dictionary that will be se... |
I have tried to incorporate comments from my previous code review into this. So, I am hoping for less mistakes. If you spot any, please let me know mercilessly!
#include <iostream>
#include <queue>
void printsub(int* p, int len, std::queue<int> q) {
if (!len) {
while(!q.empty()) {
std::cout <<... |
I'm attempting to write a bit of code that allows for easy and safe access to objects in a file. It seems to work great but I was curious if there was an easier way to do this or if Java already has something like this. If there isn't anything like this any critiques of my code would be appreciated as I'm trying to lea... |
Summary:
I've implemented what I think is a complete Java implementation of the Scala Option class. Could you please review and let me know if I have correctly and completely implemented it? And if not, could you please indicate where I have security, multi-threading, persistence, etc. defects?
Details:
I'm learning Sc... |
My background is with C and python, and Javascript is fairly new to me, so I'm wondering if this is reasonable code.
In particular, is it appropriate to use the higher order function makecb in this context, or is there a better/shorter/clearer way of writing it?
$(function(){
var controllers = {
"#showhelp": { na... |
I wrote this because I need to store an unknown bundle to a database. Most everyone suggested to Parcel it. The problem is the android docs specifically say not to use parcel for persistent storage. With some help from palacsint I was able to refactor my original code to the following:
public class AndroidBundleSeri... |
Problem Statement:
First Case: Where inclusion and exclusion both are not empty so that means inclusion overrides anything in exclusion so for that algorithm is like this:
If key is either equal to 155 or 156 and if temp is there in inclusion
then go into that if loop and do whatever you want. But if temp is not
t... |
This is my first attempt at BDD and RSpec. I'm more of a C# xUnit kind of guy.
I wrote this class while developing a 2D random tile map generator (just for fun). The project is still ongoing.
I would particularly like some review on:
Test granularity/scope in relation to BDD
Use of RSpec
Are these too much like unit ... |
Learning Scala
I'm trying to learn Scala and I'm interested in criticism about how to make my code more idiomatic. I've programmed a simple Connect-four game. Can I get some feedback?
https://github.com/jamiely/connect-four-scala
The two most important classes are Board.scala and Game.scala. They are shown below for yo... |
I need some advice\suggestions on how to create\handle database connections for a project I'm working on. I'm creating a simple work order system for my company using PHP 5.4.3, right now there isn't any type of authentication as I'm not ready for that complexity.
So far I'm planning on the following structure:
class D... |
I have an interface named ICodeRunner, defined like this:
public interface ICodeRunner
{
ExecutionResult Run(string code);
}
I have more classes that implement ICodeRunner, but regardless of which one is used, in some contexts only I have to impose a time limit on the execution of the Run method. This is a reg... |
I am trying to get user's current location base on the accuracy and less battery consumption.
Please review my code to help determine if I am going in right direction.
Location location = null;
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criter... |
I have this function takes a long time to complete. Is there a way i can improve it to quicken the procedure
function do_updatebonus() {
global $site_config;
$res200 = SQL_Query_exec("SELECT DISTINCT userid FROM peers WHERE seeder = 'yes'");
while ($row200 = mysql_fetch_assoc($res200)) {
$userid =... |
I would like to execute a series of events at the time at which they occur.
The events are stored in a list and always sorted by time of execution.
volatileEvents.Sort(SortScriptEventAscending.Comparer);
I would like to have my update method execute the following points.
The list should be checked to see if it contai... |
In view of the recent LinkedIn breach, would anyone care to review my data access routines relating to user access?
This is a standard node.js module, accessing a Postgres database.
(function () {
'use strict';
var crypto = require('crypto'),
hash = function (pass, salt) {
var h = crypto.c... |
I am using this onset source code and this fft file to try to perform onset detection. Currently the code is working, but as my DSP and C skills are subpar I could use some advice on how to improve it.
My main points of insecurity are the FFT (maybe there is a more suitable method out there?) and the C code. All advic... |
Consider an 8-bit complier, in which we have an integer of size, say
2-words i.e. 16-bits or 2 bytes. You need to store three integer
values which are supposed to be as:
Name Range Size Required
--------------------------------------------------
Integer 1 0-3 2bits (00-11 in binary)
Integ... |
I have implemented a socket listener that runs on my Linux Ubuntu server accepting connections and then starting up a new thread to listen on those connections (classic socket listener approach). The socket listener is persistant and the way it is restarted is by restarting the server.
I have implemented a logging fe... |
I have a simple atomic access class designed to work with Windows threads:
template <class aa_type>
class AtomicAccess{
private:
CRITICAL_SECTION lock;
aa_type value;
public:
AtomicAccess(){
InitializeCriticalSection(&lock);
}
~AtomicAccess(){
DeleteCriticalSection(&lock);
}
... |
I am working through the exercises in the book Accelerated C++. I wanted to get some feedback on proper use of the Standard Library, correctness, overall style, portability, etc.
/*******************************************************************************
Accelerated C++ Chapter 3
Write a program to count how man... |
I have been tasked with creating financial reports. I am looking for any suggestions on improving performance, readability/formatting or best practices.
/*setting dummy parameters */
SET DATEFORMAT dmy
DECLARE @startProduct NVARCHAR = ''
DECLARE @endProduct NVARCHAR = 'zzzzzzzzzzzzzzzzzzzzzz'
DECLARE @startGroup NVAR... |
I am a PHP newbie, gone through a couple starter tutorials which went ok, so I thought I'd try creating a more complex project to get some experience. It is a NetBeans PHP project where I try to replicate some of the functionality from Microsoft's CodeDOM technology and Zend_CodeGenerator. Basically it is a class libra... |
I have a particular if statement that could be written in different ways, and I'm curious as to whether there's any significant difference in readability that I should prefer one over the other:
The flow can be boiled down to
if string does not begin with '_'
do stuff
else
throw error
Some different ways of wr... |
I just started learning Haskell, and I must say it is unlike anything else. As my first not-entirely-trivial piece of code I tried to write a simple Bayes Classifier. It is in two parts, a classifier module and a cli.
What could be done to improve it? Is it entirely awful? Is it too imperative? Any and all feedback app... |
I have two string variables site_inclusion and site_exclusion. If site_inclusion has some values, then I don't care what values site_exclusion contains. This means site_inclusion overrides site_exclusion if site_inclusion has some values. But if site_inclusion is null and site_exclusion has some values, then go into ... |
The program finds the first non repeating character in a character array, array contains only small case letters.
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char a2z[26]={0};//Hash
char input[100] = "abcbbbcdegh";//sample input, only small case english alphabets
int n = strlen(input);
fo... |
I am having a popup which is styled to match the page and am using that single popup to display messages to the user. My popup contains one h1 element and an ASP.NET Label.
The h1 element and Label contents and color change according to the operation: if the information was successfully inserted the h1 text becomes Suc... |
I just answered the question on project euler about finding circular primes below 1 million using python. My solution is below. I was able to reduce the running time of the solution from 9 seconds to about 3 seconds. I would like to see what else can be done to the code to reduce its running time further. This is stric... |
I needed a singleton in JavaScript in order to make a DataManager which is called multiple times, but I just want it to load its data only the first time it is called, then give pieces of the data out view public methods, never loading the initial data again.
I found a number of approaches to building singletons in Jav... |
I'm a beginner programmer and I'm hoping someone would be willing to take a look at my code and tell me how to improve my coding style and development approach. Sorry about not commenting, I will try to get into the habit of commenting.
board.h
#include <iostream>
#include <vector>
using namespace std;
class board{
... |
I'm beginning to learn HTML and CSS, and since our lead developer is busy finishing up our project, I was asked to code the landing page.
I read up on some tutorials and beginning books, so I have a general grasp of things. But I'm curious as to how I use HTML and CSS to layout images efficiently.
When I first made t... |
In order to do its work, a DataProcessor needs Data and otherData.
One instance of Data will be shared over a set of DataProcessor,
but each DataProcessor has its own otherData.
For sharing Data instances, fields of Data could not be defined inside DataProcessor,
thus, there are two hierarchies: Data and DataProcessor.... |
I'm trying to create a generic function that takes a data structure as input and then sends each non-empty item—e.g.: str, int—individually:
def print_this(v, delim1="", delim2=""):
print v, delim1, delim2
def pass_many(vals, some_funct, args=None):
if vals:
if type(vals) == list or type(vals) == tuple... |
I know this may be very time consuming for you as the answerer of this question, but I have recently been looking into C# and I decided that I would try to develop a pinging application, so that I did. I have all the functionality. I just have a question regarding readability and how to set up the individual documents.... |
I'm trying declare a string in ANSI C and am not sure of the best way to do it.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
char *InitStr(char *ReturnStr){
ReturnStr = NULL;
ReturnStr = realloc( ReturnStr, strlen("") +1 );
strcpy( ReturnStr , "");
return Return... |
As a learning process I created 'reverse' function in a few different ways. Tinkering with 'reverse' made currying, folds and other stuff easier to understand. Almost natural!
I know these are trivial things for someone who had years of Haskell practice. Try to look at if from the perspective of real beginner. Level ze... |
I need to write a service to return objects in pages of size 20. The caching of these objects is done in pages of size 60.
To abstract the logic of streaming differently-sized pages, I wrote this PagingAdapter class:
public abstract class PagingAdapter<T> implements Iterable<List<T>> {
private final int callerPage... |
This is my first VBScript I have ever written and I would like to know if there is any obvious blunders in the code. All the code should do is check if file exists then change the Yahoo URL to the Google URL in the XML file. Note: The code seems to function properly.
Dim objFSO
Set objFSO = CreateObject("Scripting.File... |
I have to list a integers from a text file separated by newlines into a python list. I ended up with the code above which works (for my case) but certainly is far form optimal.
def readIntegers(pathToFile):
f = open(pathToFile)
contents = f.read()
f.close()
tmpStr = ""
integers = []
for char... |
Every shim I have seen for this function has used the IE-only CSS expression trick. While there's no denying it's effective, it's made useless if the browser is not IE and doesn't support querySelectorAll either.
jQuery is out of the question, since I don't want to get a whole framework just to shim one tiny little fun... |
I am not sure the square brackets are correct (although it has not yet failed some simple tests). I would also like to reduce and simplify this code to one line if practical. I think the code is self explanatory.
str = str.replace(/[\n]/g,'<br>')
str = str.replace(/[\t]/g,' ')
|
I have been programming a simple number guessing game and I am wondering if there is any way of making my code more efficient and cleaner. I have spent some time on it implementing error checking to make it as safe as I know how. I feel as if the way's that I have done this may be 'long winded' so if you know of a shor... |
I have a small social networking site built in CodeIgniter. Any registered user can send messages to others by visiting their profile.
Today I noticed that one user sent bulk messages to 200 users. How he was able to do that?
Suggestions to make the code secure are welcome.
I have a textarea and a send button on the pr... |
I just got back from my interview where I had to solve the following problem:
Write a C++ program that prints the following pattern using nested for loops.
*
***
*****
***
*
Here is my solution:
int inc = 2;
for (int i = 1; i >= 1; i += inc){
for (int j = 0; j < i; j++ )
std::cout<<'*';
std::cout<<en... |
Question is short. Assuming that I don't need reference itself, would this cast
((TextView) findViewById(R.id.someTextView)).setText("lala");
be better (or at least not worse) than:
TextView tv=(TextView) findViewById(R.id.someTextView);
tv.setText("lala");
|
/********************************************************************************************
* ToDo - Make CIO and IServer basic functions....complete break down to functions.
*******************************************************************************************/
/**********************************************... |
I need a singleton that can safely operate in a multi-thread environment. Threading and concurrency is new to me, so I'm not sure if this implementation holds. Take a look:
public class ObserverSingleton {
private static ObserverSingleton _instance;
private ArrayList<OnRequestFinishedListener> _listeners;
... |
I've just written this function for a test, but now I want to rewrite it for production.
I would like to know the best way to do this, or if this is "best practice" I think it's too long for the minimal stuff it does.
The whole idea is something like this: I have a one page with three sections floated left and a couple... |
This is my first real Cocoa app that I am writing. The first version of this app was just one long applescript. So in my app auto git, I have an NSTask instead of Tell terminal. My code looks like this:
-(void) runScript:(NSString *) path:(NSString* )cmd1:(NSString *) cmd2:(NSString *) cmd3{
NSTask *aTask = [[NSTa... |
I have a switch statement that checks whether or not one string matched another that was stored in an array. However, there are multiple cases in which the same result is returned for multiple matches. I originally had a large amount of if/else checks, but tried to shorten that down with the switch statement. I was won... |
The .htaccess file redirects all requests to this file and the $_REQUEST['path'] variable contains the url after the base url.
$url = '';
$urlSegments = [];
$resource = '';
$action = '';
$parameters = [];
if(isset($_REQUEST['path'])){
$url = $_REQUEST['path'];
$urlSegments = explode('/', $url);
if(!empty(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.