instruction stringlengths 71 71.9k |
|---|
I've come up with the following routine to read data from a file stream, but I don't want any NULLs in the stream to terminate the string early. This function will read in a "line", and allow it to be processed with normal C string functions. Does anyone see any inherent problems or potential bugs in this routine?
ch... |
Are there any aspects I could improve of my HttpSession wrapper class?
Other suggestions are also welcome.
namespace Http;
class HttpSession
{
private $data;
public function __construct($name = null, array $iniSettings = [])
{
if ($name) {
session_name($name);
}
foreac... |
I've found a question on SO (here), which is a prime number generator that uses channels. First of all, I had some trouble to find out how this code works, but later on, I saw the fun of it. Then, all the sudden, I saw the light! The code can be used perfectly to benchmark the difference between channels versus a for l... |
I've built a website that scrapes a guitar forum's pages and populates Rails model. I'm using rake task along with heroku scheduler to run background scrapes every hour.
On the homepage, the forum ads (in the form of a Post Model) are displayed using a dataTables (jQuery plugin), so user can search from the front-end.
... |
I run a script to download a file and unzip it. An import process then runs and leaves the files in their source location. I wrote the fully functioning code below to clean up that directory to be ready to use the next night.
I streamlined as much as I believe possible. I realize ~15 lines of code isn't exactly verbose... |
This query seems to have way too many parentheses.
SELECT
CAST(ISNULL(ROUND(CAST((SUM(product1) + SUM(product2)) AS FLOAT) / CAST(salescalls.visits AS FLOAT) * 100, 2), 0) AS VARCHAR) + '%' AS avrg
FROM sales, salescalls
WHERE sales.salescallId = salescalls.id
|
I used JS to re-populate the shipping address into the billing address when a checkbox is clicked. I'm wondering whether there is a more concise/better way to write the code below:
var checkBox = document.getElementById('order_use_billing');
var shipFirstName = document.getElementById('order_ship_address_attributes_fi... |
This post is the result of reading through and following the LOLCODE Specification 1.2 ("smoking the manual", right?), and writing and executing my code on compileonline.com.
My "hello world" was going to be a fizzbuzz. I like it because it nicely illustrates the basics of a language - variables, operators, looping, co... |
I recently had an interview problem where I was asked to find a compact representation of nodes in a tree.
As an example, consider the following tree:
A
/ | \
B C D
/ | \ | \
E F G H I
/\
... |
A BST has two nodes swapped. Figure out which two nodes.
Looking for code-review, optimizations and best practices.
public class SwappedNodes {
private TreeNode root;
SwappedNodes(List<Integer> items) {
create(items);
}
private void create (List<Integer> items) {
if (items.isEmpty()) ... |
I'm working on a script that will be able to send mass e-mails. I'm using cron to run this script. I'm fetching e-mails from queue.
I need to ensure that:
To one e-mail will NEVER be sent more than one message (it could be executed more than once)
One e-mail must have only one recipient (not multiple to)
It must to ju... |
I took the belated plunge to look at Autolayout. Normally I'd animate based on a UIView's frame (i.e I'd have used the following):
NSArray *sortedArray = [self.buttonArray sortedArrayUsingDescriptors:[NSArray arrayWithObject:ascendingSort]];
for (int i = 0;i<sortedArray.count;i++) {
UIButton * theButton = [s... |
I like to know if there's anything that I may have missed in this implementation. The method tries to provide the absolute path of the binary or script which is likely to execute based on the provided path. I carefully based it from how cmd.exe chooses the file to execute. It intends to be platform-independent but so f... |
Using:
ToastUtils.LONG.show(context, R.string.greeting);
Code:
public class ToastUtils {
public static ToastUtils LONG = new ToastUtils(Toast.LENGTH_LONG);
public static ToastUtils SHORT = new ToastUtils(Toast.LENGTH_SHORT);
private final int duration;
private ToastUtils(int duration) {
this.... |
I'm not sure if this could be more efficient because I don't think I should need 2 keyframe loops in addition to the for loop?
for i in (1..19)
.l:nth-child({i})
n = (20 - i)
height 0
if i >= 10
margin-left ((n * n) * (1.25/n)) + 17 px
box-shadow 0px 0px (n+4)px 0 rgba(40,70,200, 0.5),0px 0px (i+8)px 0 rgba(80,1... |
After lots of attempts thanks to all the Android enthusiasts, I've found a method to handle large images efficiently in Android Applications in order to get rid of OutOfMemoryError. But I really need to know is this the correct formal way of doing this? Do I need to add some more, or should any changes be made? Please ... |
I want to define an exit code for some exceptions and some exceptions only. I want that the only input is that dictionary with the definition.
import sys
exit_codes = { ValueError:'10', KeyError:'25' }
try:
raise Some_Exception
except Exception as exit_err:
if any([isinstance(exit_err, exceptions) for excepti... |
The function im2col in MATLAB is very useful to vectorize Patch based Image Processing algorithms. The problem is the function isn't optimized and doesn't use C Code. I'm trying to build efficient C code for that.
This is the code I created:
function [ mColumnImage ] = ImageToColumns( mInputImage, blockRadius )
% -----... |
I wrote a function that solve a special problem. But one of my 'special hardcore software engineers' told me that this is a bad solution - but he will not give me a better solution. So I ask you: What could I do better? (This is more an academic exercise than a bottleneck in my software.)
I have an array $tags of {n} o... |
Can this be simplified in any way?
if ($('.content').length && (document.referrer.search('page1.html') > 0) ||
$('.content').length && (document.referrer.search('page2.html') > 0) ||
$('.content').length && (document.referrer.search('page3.html') > 0) ||
$('.content').length && (document.referrer.search('pa... |
I made an adapter function to convert a const char * to char ** splitting the words in the initial string at each white space (leading, consecutive and trailing white spaces should be ignored).
#include <iostream>
#include <vector>
#include <cctype>
void str2arg(const char * str, std::vector<char*> & arg, std::string ... |
I've recently started a new job and been drafted on to a project that's running late. My task was initially to add Bluetooth connectivity to a C# app, but at the request of a more senior colleague I've had to write a standalone executable to open up two Bluetooth connections and forward any data sent/received from the ... |
Just looking to do some super-duper basic email validation and was wondering if my code is efficient.
IE8 compatibility is a requirement.
/**
* Email validation is futile
* Make sure the @ symbol is not the first or last character
*/
jQuery.validator.addMethod("easyEmail", function(value, element, param) {
value... |
This code will be passed a string which will contain one or more hostnames.
A hostname can be
dotted-decimal
plain name (like my_host)
FQDN or even partially qualified
A string containing regex (my_hos[tes])
target_list is an array of known hosts to match any regex against.
Any suggestions on cleaning this up?
sub ex... |
I wrote this Ruby Mod 11 (perhaps it's a bit generous to call it that) implementation to validate Brazilian CPF documents, which use a Mod 11 algorithm. CPF format is a 9 digit number followed by two checksums. It's often presented in this format 012.345.678-90. Feedback is welcome.
class CPF
attr_reader :digits
L... |
I've written an eCommerce shopping cart handler class in PHP. Please review the code and inform me of any errors and/or badly written code and/or badly handled logics. Please also inform me of any missing functionality or security loopholes.
class Cart extends Sessions{
protected $cartProducts = array();
protected $db... |
I'm attempting to define an abstract interface for a key value store.
Some requirements:
Once a key has been written it should never be overwritten (although it may be deleted
Transactions with multiple operations are not required
To begin with, this is the basic interface:
class KVS a where
get :: ByteString -> a... |
I have the following PHP code but I'm unsure, based on the many things I've read, whether or not this is actually safe from an SQL injection attack.
$mysqli = new mysqli("address.address.address", "username", "password", "database");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n... |
I'll soon begin teaching a beginners' programming class. It's voluntary, so I thought I'd make it interesting by teaching Python programming and then introduce the kids to Pygame, so that they can make their own games. To try out Pygame (I've never used it before) and to see exactly how easy it is to make a game, I mad... |
I wanted to write a function to generate only unpronounceable words. I realised afterwards that the same thing could probably be achieved by just taking out the vowels. Regardless, I feel that there is probably a better way to iterate through the syllable checking.
function unpronouncable(length) {
var twoLetters =... |
I have two csv files that I need to compare and merge together. There is a 'big' list with many records and columns of data and a 'small' list of the desired records and some additional data. The ultimate goal is to output the records on the small list joined with the data in the big list.
The below code seems to make... |
I have read on numerous occasions that tests should not be coupled to implementation details - this makes perfect sense.
Now I am having some trouble decoupling my tests from implementation details and am kindly asking for some help.
The relevant portion of the repository that I am testing looks like this:
public class... |
I need to add support for persistent cookies on an Android app that I'm building for Authentication/Authorization. This app uses Volley for making HTTP requests and its minSdkVersion is set to 9 (Gingerbread). Therefore Volley uses HttpUrlConnection internally.
What I had to do was create a new java.net.CookieStore tha... |
Motivation
Although I love coding in C++, I sometimes yearn for the syntactic sugar of Python. C++11 has somewhat eased the pain by such beautiful analogies like this:
# python
for i in [1, 5, 7]:
// C++11
for(auto i: {1, 5, 7})
Unfortunately, C++ puts an end to this as soon as you want to do such crazy things as hav... |
I have a main form which does processing for an extended period of time. Normally, progress bars are used to show either the loading status or simply show the program is still running/hasn't freezed.
For this form, I wanted to give it a more snazzy look by reusing a common loading GIF found on the web that many users ... |
I was doing this exercise from here. I made a solution work but can't help feel it could have been done in fewer lines. I'm quite new to python so I'm not too sure of the little shortcuts.
def shift(S, n):
word = ''
for i in S:
if ord(i) == 32:
word += ' '
elif ord(i)+n > 90:
a = n... |
I've created a MiniStack to assist in removing recursion from routines using a manual stack.
Obviously if the stack is an object it lives on the heap and its creation and destruction takes a significant amount of time. Therefore any heap based option is out for loops that create and destroy the TStack.
Is there anythi... |
I'm still learning C, but I'm trying to make sure I've got a decent grasp on working with "strings" and data structures.
If possible, I'd like a little input on how I'm handling this and see if
it could be done more efficiently
I'm setting myself up for unforeseen negative consequences
I'm using the functions appropri... |
I'm pretty new to PHP and programming general so I'm quite sure my code is an absolute mess. My goal is to write good code, that others can understand just by looking at it.
This is a simple login system I've been working on. Critique at will.
Link to said code - GitHub
General area of interest are the classes:
<?php
/... |
I wrote this script to help me keep track of who has worked together and for what project or discussion in my classes.
I make a Google Sheet with the names of the students going across the first row and down the first column. Each student gets a number corresponding to their location in the spreadsheet. The value is th... |
I have designed a tool that generates some HTML files and a CSS file in a directory, which then feed into a tool called Jutoh that uses these to make eBooks.
However, my output files are of the form 1.htm, 2.htm and so on. Jutoh ranks 10.htm to preceed 2.htm and therefore, I wrote a method to convert 1.htm into 0001.ht... |
I have been working last night on implementing Tower of Hanoi without using recursion. I have found an algorithm on Wikipedia about the same topic here. I have implemented it and it's working fine (for odd numbers for now). But I am not happy with the code because it's kinda bulky, hence I want to modify it in a way so... |
I am working on a project in which I construct a URL with a valid hostname (but not a blocked hostname) and then execute that URL using RestTemplate from my main application thread. I also have a single background thread in my application which parses the data from the url and extracts the block list of hostnames from ... |
I have a background thread which runs every 5 minutes. I am using ScheduledExecutorService for this. Every five minutes, I am making a call to one of my service and parsing the response coming back from that service.
public class ThreadScheduler {
private final ScheduledExecutorService scheduler = Executors.newSchedul... |
Gmail had this awesome feature and it was discontinued for some reason. Nowadays I have installed a nice Google Chrome plugin for this job.
A couple of months ago I had to develop a similar feature for a project and I think that could be improved but I don't know how.
I'm here asking for a code review or suggestions.
... |
Are there ways to simplify the getLoadComponent(Class<T> type) method? The call LoadComponentFX lcfx = l.getLoadComponent(LoadComponentFX.class); seams a bit clumsy to me.
Here is my code:
public abstract class LoadComponent {}
public class LoadComponentFX extends LoadComponent {}
public class Load {
Set<LoadComp... |
I am calling show_thumb to create thumbnails , but I am realizing that it is making the site load a little bit slower.
Below are two functions: show_thumb function that shows the thumbnail and make_thumb_gd that takes care of the thumbnail. Any suggestion on making it faster? The current approach makes the site slow, b... |
Just working through the questions on 4Clojure as I learn the language. This is my solution for #69. Would appreciate feedback as this one gave me a little trouble.
(fn merge-with2 [f m & ms]
(let [update-or-add (fn update-or-add [m1 k f arg]
(let [x (get m1 k)]
... |
Here is a routine I put together to convert SQL Server's internal DateTime representation (BINARY(8)) to a FILETIME. I know that the SQL DateTime (as in GetDate()) is not precise and will vary from the SystemTimeAsFileTime. But it should be different by milliseconds, but by seconds, right?
In any case, here is my routi... |
FizzBuzz was fun, and I got great feedback and learned a few things (which I hope I put in practice here), but only scratched the surface. I wanted to explore the LOLCODE language a bit more, so I implemented a little rock-paper-scissors, to play with functions, parameters, return values.. and user input.
Unfortunately... |
This is my first attempt at writing a c++ program, so bear with me. I tried to use as many methods as I learned in about a week-long period.
#include <iostream>
#include <stdlib.h>
#include <time.h>
void generator(char tree, char water, char land)
{
const char tileList[] = {tree, water, land};
int tileIndex =... |
Scenario:
I am working on a Java/ZK Subscriber Management application. There are 2 tabs: Basic Info and STB-VC. The first one for creating a new subscriber and the second one for assigning STB/VC(Set-top box and viewing card).
I am trying to achieve/ensure Someone can only click/use the second tabpanel only after cre... |
OK, here's the problem space:
Lwjgl, a graphical library, has the ability to throw an unchecked LWJGLException on certain methods - like Display.create(). This becomes a problem when you have to off-load all work done by Display onto a single thread using an ExecutorService - that's what I'm doing, unfortunately, due t... |
Some patterns are emerging ("fmap (b->a) . fmap (c->b) . .. . (IO z)"). Also infix zip is kind-of a hack.
What is:
Best practice in point-free style?
Best practice?
Elegance > Performance; Functional > Imperative
import qualified Data.Map.Lazy as M
import qualified Data.ByteString.Char8 as BS
fromFile :: FilePath -... |
I have some JavaScript that was put together for functionality but I wanted to know if there was a better way to write it. As it stands it's a little hard to read and follow.
$(document).ready(function(){
var loop = null;
$("li").click(function(){
$("li").css("box-shadow", "none");
$(".selector").css("visibili... |
This is a follow-up to: Serializing JSON data coming from two URLs in the same object
I have two URLs (urlA and urlB) and they both give me a JSON response back in the same JSON format. Below is my JSON string which I am getting back by calling from urlA. I have shortened it down by having only three reportRecords for ... |
At the moment I am auto loading my classes with:
spl_autoload_register(function ($class) {
require_once 'classes/class.'. $class .'.php';
});
And instantiating the class with:
$backend = new backend();
$dashboard = new dashboard();
$article = new article();
$video = new video();
$theme = new theme();
These are in... |
In my eyes most of the GNU stuff is bloated and doesn't really fit my view of how a Linux environment should look like. I have come up with my own minimalist implementation of the GNU Coreutils, but I have not touched C in a long time and my programming style reflects that a little.
rmdir.c is a good representation of... |
A problem posted here to Code Review prompted me to experiment with a general-purpose merge-sort algorithm for any fixed-length record data.
External / File-based mergesort
I answered that question, which specifically deals with int values in a file, and proposed an answer that suggested a MappedByteBuffer.
These NIO c... |
Here is a screenshot of my setup:
Here is the actual code:
#activate python virtualenv
activate_this = 'C:/Users/D/Dropbox/_mypyapp/learnbottle/learnbottle/scripts/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
#import dependencies
import os
from bottle import route, run, template
#this is w... |
This is my solution to this SO question, which can formulated as
take the sequence A002260, i.e., 1, 1, 2, 1, 2, 3, ...
concatenate all its digits
find the digit at a given position (1-based)]
What bothers me is that my solution is rather complicated and fails near Long.MAX_VALUE due to overflow. I also wonder if thi... |
I've tried to make Game of Life in console and this is the algorithm I used to generate new generation:
void processGeneration() {
population = 0;
int neighbors;
int tempGrid[ROWS][COLS];
for(int i = 0; i < ROWS; i++) {
for(int j = 0; j < COLS; j++) {
if (grid[i][j] == -1) {
... |
I was trying to figure out what a minimal ECS might look like in Lua; here's what I came up with. This is based very loosely on darkf/microecs.
local function createSystem(components, process)
local function handle(entity)
for i, component in ipairs(components) do
if entity[component] == nil then return end... |
I have implemented the K-Mean clustering Algorithm in Numpy:
from __future__ import division
import numpy as np
def kmean_step(centroids, datapoints):
ds = centroids[:,np.newaxis]-datapoints
e_dists = np.sqrt(np.sum(np.square(ds),axis=-1))
cluster_allocs = np.argmin(e_dists, axis=0)
clusters = [datapo... |
I'm scraping some comments from Reddit using Reddit JSON API and R. Since the data does not have a flat structure, extracting it is a little tricky, but I've found a way.
To give you a flavour of what I'm having to do, here is a brief example:
x = "http://www.reddit.com/r/funny/comments/2eerfs/fifa_glitch_cosplay/.json... |
I have provided a simple implementation of a linked list using my own super classes and interface. The implementation is for adding, deleting obtaining the size of thew list. I have not yet provided the iterator in the current code as it's not in the scope for now.
SimpleList.java
package com.learn.linkedlist;
import ... |
I'm relatively new to PHP and programming as whole. I'm sure my code could be better in a lot of ways, most of which I can't fully grasp at the moment. As it stands I'm trying to avoid the general noobie mistakes(whatever they may be). And also trying to code better and cleaner so that other people can understand witho... |
I'm new to Java and I really don't understand how to make more classes work like one. So if anybody could explain and help me divide my large code into smaller classes (like Player.java, Main.java, Move.java, etc.). I want to check if the player hits the wall, and the easiest way is to make player object a blocks obje... |
I decided to build a basic eCommerce application in c++ as a learning experience. In the past, I've gone with a fat controller, skinny model approach, and while it has worked, my results always end up messy and the code is/was kind of individual to the applications. To try something new, I wanted to incorporate the sin... |
I have the following C# method to split a path string. The only thing I know is a fixed string in the path and I have to split the full path into two parts, first part should be one level below the fixed string and the rest should be the second part.
For example, if I have the following path:
string mainText = @"C:\A... |
I am trying to implement the algorithm described in the paper Statistical Test for the Comparison of Samples from Mutational Spectra (Adams & Skopek, 1986) DOI: 10.1016/0022-2836(87)90669-3:
$$p = \dfrac{\prod\limits_{i=1}^{N}(R_i!)\prod\limits_{j=1}^{M}(C_j!)}{T!\prod\limits_{i=1}^{N}\prod\limits_{j=1}^{M}(X_{ij}!)}$$... |
I sometimes find myself using multiple expressions checking on a single flag to control the state of some template, in this example, a Facebook log in button.
On a second look, however, I noticed this pattern might bear a significant performance drawback for making Angular have to update the DOM in multiple places ever... |
I am currently developing a Content Management System, and I have just completed the Error Handling system, which handles errors according to the user's settings.
I want to know every single thing I could improve to make it more flexible, robust, light weight and fast processing. If there are better ways of doing thing... |
Based on this SO answer I have created a method that produce the set intersection of several sequences:
private static IEnumerable<TSource> Intersect<TSource>(this IEnumerable<IEnumerable<TSource>> source)
{
using (IEnumerator<IEnumerable<TSource>> sourceIterator = source.GetEnumerator())
{
//if ther... |
I would like to hear other people's opinion on how I unit tested a functionality in a Backbone Model. As you see below, the code under test, upon being called to toggle, toggles its completed state and saves the new state:
// js/models/todo.js
var app = app || {};
// Todo Model
// ----------
// Our basic **To... |
I have implemented functions that will let me reverse a one-to-many value 'Map', that is a plain JavaScript object.
For example,
var map = {'foo': 'bar', 'baz': 'bar', 'moo': 'zoo'};
becomes
var reversedMap = {'zoo': ['moo'], 'bar': ['foo', 'baz']}
and also a function to bring back reversed map to a non-reversed ma... |
Here's a followup to Minimal entity component system. Please see that question for background.
-- ecs.lua
local unpack = table.unpack or _G.unpack
local function addComponent(entity, component, instance)
entity[component] = setmetatable(instance or {}, { __index = component })
return entity
end
local function ge... |
This simple game is built on the ECS described here: Minimal entity component system, take 2
local ecs = require 'ecs'
local ui = require 'ui'
local entities = {}
local velocitySystem = ecs.createSystem(
{ 'position', 'velocity' },
function (entity, pos, vel)
pos.x = pos.x + vel.vx
pos.y = pos.y + vel.vy
... |
I am using Telerik's Kendo UI suite for a project, and was excited when they announced compatibility with Angular, but as I got a lot of code written I realized that they hadn't yet made the widget directives work with real JSON data - it only bound and talked to bare bones primitives. This was an undesired behavior, a... |
I have written this program to solve this problem by Arbitrator solution algorithm, mentioned here, to solve this. It states that each philosopher should ask permission from Waiter to get the Fork. Philosopher cannot start eating until he has both the forks. I have implemented logic that he should either hold both fork... |
I have implemented a small library that handles synchronous events with POSIX compliant threads. I oriented me on the already existing POSIX thread API. Here are the files I created:
ptevent.h
/*!
* @file ptevent.h
* @copyright < Pro Fusion , 2014 >
* @date 31.08.14
* @discussion
* Sy... |
Description
To increase the awareness of my previous brainfuck question here's also a brainfuck interpreter.
This is written with Java 8
Class Summary (298 lines in 4 files, making a total of 7409 bytes)
BrainF.java: Represents a Brainfuck program/execution
BrainFCommand.java: Enum for the various Brainfuck commands
... |
I saw a talk by Jack Diederich a few weeks ago titled "Stop Writing Classes" and noticed that some of my code perhaps echoes what he argues against (to the effect of "classes with two methods, one of which is __init__") in my code. For some parser that needed to run through a bunch of data, I created a couple classes t... |
It would be helpful to know where I could improve the style of it, so it follows the style guide better, and also any ways I could compact it - especially at the end, where I have added items to a list then removed them. Is there a more elegant way to do that?
def reptillint(sentence,mini,maxi,error1):
maxi = int(... |
My goal is to create a simple restful api that will be accessed by an AngularJS front end. Even though it's fairly simple, I'd like understand how to make it more reliable, secure, and best-practices compliant. The whole api is contained in a single file, I'm not overly concerned about organization at the moment (unles... |
So I have this code that is my attempt at a coding test from Codility. While my code produces correct results according to the requirements, (which unfortunately are copyrighted so I don't think I can reproduce them here), but I feel like it could be better organized, and in some places use a more functional approach t... |
I'm writing a program in Scala to perform Hamiltonian Monte Carlo (HMC), coupled with Gibbs sampling of some variables. The algorithm, with the modifications such as perturbing epsilon and l and performing Gibbs updates on some variables may be found in the easily available book chapter "MCMC using Hamiltonian Dynamics... |
I've implemented a simple binary search tree for practice purposes:
#ifndef BST_H
#define BST_H
template <typename T>
class treeNode {
public:
treeNode *left;
treeNode *right;
T key;
treeNode(T key)
: key(key)
, left(nullptr)
, right(nullptr) {
}
};
template <typename T>
cla... |
I'm developing a PHP function for calculating labor percentage (labor cost/sales) accounting for daily and weekly overtime rules, if applicable, based on the payroll period; the wages for each employee in the time input search range are calculated then summed to determine total labor cost.
The function takes start/end ... |
I created a Backup class because I couldn't find one that worked well on Windows and remotely, to do this I have combined a lot of questions on stackoverflow with a lot of trial and error to get it to work on these two platforms. I'm fairly new to OOP, and I really just want to get some tips on handling passing error m... |
I want to verify that a given directed graph is connected and acyclic (DAG). I have implemented a modification of the Tarjan's strongly connected components algorithm in imperative style (as the original).
Every suggestion to improve simplicity, readability and suitable use of F# constructs will be wellcome.
Note: the ... |
I've created a MD5 shuffler with a defined number pattern. Does this make sense? Will this make storing passwords more secure? Is it efficient?
<?php
echo "<pre>";
$md5 = "e2fc714c4727ee9395f324cd2e7f331f";
echo "Old hash: " . $md5 . "<br />";
$hash = str_split($md5, 1);
$shuffle = explode(",", "24,29,21,23,2,30... |
I'm trying to accomplish something very simple as seen here.
HTML
<div id="header">
<div class="container">
<img src="#">
<ul id="header_nav">
<li>Link</li>
<li>Link</li>
<li>Link</li>
</ul>
</div>
</div>
CSS
.container {
padding-left: 80px;
p... |
I wrote this class in order to not having to write tag every time (because of code duplication and risk of typos).
public class TaggedLogger {
public static final TaggedLogger GLOBAL = new TaggedLogger("Global");
private final String tag;
public static TaggedLogger forClass(Class<?> someClass) {
... |
The following code draws a red rectangle bouncing between the borders of a white display. I'm not particularly happy with the update function:
(require 'lispbuilder-sdl)
(defun update-h-speed (state h-border top-left-border)
(if (or (< (cdr (assoc 'h-coord state)) top-left-border) ;;if too left
(> (cdr (assoc ... |
I'm making a web application for a restaurant kind of type. The idea is to administrate the orders and customers.
For selecting one of the orders and showing more specific data about it, I have this PHP script. As you can see I am using prepared statements to prevent SQL injection.
<?php
try {
$connection = new P... |
Countdown is a British gameshow where contestants compete in word and number challenges. During the numbers round, six numbers are chosen semi-randomly and the task is to combine them using addition, subtraction, multiplication and division in order to reach a target number.
For example, the numbers might be [75; 25; 7... |
I wrote a function to normalize sparse matrix along rows using C++ Eigen; however, I feel that it can be improved, and that I am not using some built in functions of Eigen.
#include <iostream>
#include <Eigen/Dense>
#include <Eigen/Sparse>
#include <vector>
#include <math.h>
using namespace Eigen;
std::vector<double>... |
I have a Rails app where I'm trying to select a list of facilities based on what region is selected in a form. So far, I've implemented group_collection_select to do this as well as a bit of CoffeeScript.
It works when creating a new record and selecting a region. The behavior being to only show facilities listed for... |
The example for downgrading ReentrantReadWriteLock in the Java documentation seems really unsafe when handling exceptions. I tried to write a simple class to simplify it. Do you see any cases where it can fail?
I'm looking for a review from a concurrency point of view, such as if this code may fail if an exception is t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.