instruction stringlengths 71 39k |
|---|
I have implemented Zeller's algorithm in Python to calculate the day of the week for some given date. I would like to get some feedback on how I can make the code shorter and more elegant:
def input_value(input_name, prompt, min_num, max_num):
while True:
data = raw_input(prompt)
if data:
... |
My inspiration for creating this protocol came from iOS 5's "dismissViewControllerAnimated:completion:" addition to UIViewController. I wanted this functionality in iOS 4.3.
I find using the modal view's -viewDidDissapear to invoke methods on the presenting view controller work's very well. One benefit is the ability... |
This is from an answer to my own StackOverflow question on how to efficiently find a regular number that is greater than or equal to a given value.
I originally implemented this in C# but translated it to Python because I guessed (correctly) that it would be shorter and would eliminate a third-party library dependency.... |
It compiles, works well, solves my problem of zipping old or big log files and removes them from a hard drive. However, following this answer, I would like to know what was wrong with the code.
Dir.foreach(FileUtils.pwd()) do |f|
if f.end_with?('log')
File.open(f) do |file|
if File.size(f) > MAX... |
I've been playing with Clojure for the last few evenings, going through the well known 99 problems (I'm using a set adapted for Scala).
Problem 26
Given a set S and a no. of items K, returns all possible
combinations of K items that can be taken from set S.
Here's my solution:
(defn combinations [k s]
(cond
(... |
I saw this question "Is this implementation of an Asynchronous TCP/UDP Server correct" and it is very similar to what I want to do but it goes about it in a different way so I am wondering if anyone would mind doing some constructive critism on my method please.
I'm looking for any feedback along the lines of "when x ... |
i'm rewriting some Matlab code to c++ using armadillo, a libs for linear algebra. really good libs, IMHO. but i had to translate some matlab construct because armadillo isn't matlab.
i want to share my little snippet because i think there should be a better way (in terms of speed, mainly) to solve thoose little problem... |
I'm writing a checkout form for purchasing online tests. You can buy a certification or a recertification, as well as a pdf or book study manual.
I'm using Jinja2 templates to provide test data into the Javascript. The test object is a dictionary with the following structure. All prices are in cents.
test {
id: ... |
I wrote some code which divides a line through the words of the text so that each substring is no longer than MaxWidth. It works well, but it's very slow.
Pattern pattern = Pattern.compile("(.{1," + symbols + "}(\\b|\\s))"); // symbols - MaxWidth
Pattern pattern2 = Pattern.compile("\\s.*");
while ((line = in.readLine(... |
I have recently been trying to improve the quality of my code. Towards this goal I want to start writing unit tests and I also am trying to implement things i have read as best practices. I have read that its better to have a class raise exceptions over returning error codes. In the below class I have an init method th... |
I'm working on a Game Of Life clone as my first project. I'm still relatively new to programming, so my code is probably not really optimised.
The biggest bottleneck is in my Start() method, but that contains a lot of Unity3D specific methods which most people here probably don't know about. That's why I'm leaving that... |
I need to count non-transparent pixels in a canvas. I am pretty sure there is a nice and elegant syntax for doing this. Note that the data returned by getImageData is not a regular array and cannot be sliced, for example, or it does not have a reduce method.
data = context.getImageData(0, 0, canvas.width, canvas.height... |
This is a script I wrote to find the n biggest files in a given directory (recursively):
import heapq
import os, os.path
import sys
import operator
def file_sizes(directory):
for path, _, filenames in os.walk(directory):
for name in filenames:
full_path = os.path.join(path, name)
yi... |
This is my first 'large' JS project and I was hoping someone could have a quick look and suggest better coding practices, how it could be cleaner etc. It revolves around a one page web-site and contains some AJAX.
$(document).ready(function () {
var curpoints;
//int globals
var sectionload... |
I build a collection to ensure only valid entities in an array so I don't have to validate after every function / method call as I could rely on the collection to have only valid entities stored.
class WorldCollection implements Collection, ArrayAccess {
private $container = array();
private $oValidator;
... |
I wrote code in python that works slow. Because I am new to python, I am not sure that I am doing everything right. My question is what I can do optimally?
About the problem: I have 25 *.json files, each is about 80 MB. Each file just contain json strings. I need make some histogram based on data.
In this part I want ... |
I'm using manually implemented properties to handle sharing code between forms intended to edit a base object, and those intended to edit a derived version. My current setup works as long as everyone accesses the property and not the base object; but after spending an hour or so tracking down a bug that was due to man... |
I've stripped this down to its bare bones removing stopping/cancellation logic etc... to keep it simple.
The Producer is a very simple class containing a timer. At regular intervals the TimerOnElapsed will let the host now that it has another batch of items available. The onus is on the host to pull that next batch us... |
The problem
I'm trying to position a chosen element so that it's always horizontally aligned against the right-hand side of the page, and vertically aligned with the center of the web browser's vertical inner scrollbar, i.e. the part of the scrollbar that moves as you scroll up and down the page. The "handlebar", if y... |
I've written a DOM element selector engine that I'm really quite happy with, and I'd love to hear some opinions on it from my fellow JavaScripters :D
It's called Atomic, and I've got a repository for it over at GitHub - and I've also included the code below...
Check it out (if you're in the mood) and let me know what y... |
I need to allow incoming HTML in string parameters in my projects action methods, so we have disabled Input Validation. I have a good HTML sanitizer; the review I am interested in is the way I bound it into my project.
I have the following Model Binder:
public class EIMBaseModelBinder : DefaultModelBinder
{
... |
While implementing auto refreshing div in jQuery that fetches updates on posts periodically as can be seen on Twitter, Facebook etc.
I had to think about making the refresh as efficient as possible. I decided to send a request to the server every 30 seconds - 1 minute. And, the request will be sent only if the browser ... |
What's a better and more elegant way of writing this:
$('#footer form').submit(function(event) {
event.preventDefault(event);
$('#footer form .preload').spin(opts);
$.post('contact.php', $(this).serialize(), function(response) {
$('#footer form .preload div').remove();
$('#footer form h5').r... |
I need to model an IP address and thought using a state machine (the state_machine gem) would be a good idea.
An IP has the following characteristics:
It is assigned to a server.
It can be in state unbound (implies unprotected), bound (implies protected), reserved.
It has several firewall rules which should be automa... |
I have a Dictionary<string,string> and want to flatten it out with this pattern:
{key}={value}|{key}={value}|{key}={value}|
I tried with a LINQ approach at first but couldn't solve it, so I ended up writing an extension method like this:
public static string ToString(this Dictionary<string,string> source, string keyVa... |
/**
* Implements hook_field_validate().
*
* @param string $entity_type
* @param object $entity
* @param array $field
* @param array $instance
* @param array $langcode
* @param array $items
* @param array $errors
*
* @return void
*/
function field_validate($entity_type, $entity, $field, $instance, $langcode,... |
I'm a newbie to Python, and I was wondering whether anyone could give me any pointers on improving the following code:
import pygame, sys, time
from pygame.locals import *
# Define defaults
bg = (0,0,0) # background colour
spl = (255,255,255) # splash colour
ver = "INDEV v1.0" # current version
img = "icn.png" # corne... |
I am trying to finish the K&R book on C. Below is an exercise which took a long time to finish. I would like some feedback on optimization or any blatant issues with the code.
Exercise 1-21
Write a program entab that replaces strings of blanks by
the minimum number of tabs and blanks to achieve the same spacing.
A... |
I've tomcat running on my Macbook pro and a web application.
Making a request to a servlet (below i'm showing post method code) and tipping top command in terminal show a java process with 200/300% cpu usage.
The servlet make a request to a mongo database to retrieve 389 documents and then iterate over this documents,p... |
It works pretty well, but I suspect there's too many variables, and I wonder what else.
I'm using this library: Python APT.
#!/usr/bin/env python3
import argparse
import apt
def getdeps(deptype, pkg, otherpkg):
deps = list()
name = otherpkg.shortname
otherpkg = otherpkg.candidate
for deplist in otherp... |
I'm just trying to see if anyone disagrees with the way I'm handling my logic for this. Something doesn't feel right with it but I don't quite know what it is.
Just wanted to add that the new_password_key is NOT a password for the user to log in with. As of right now I was going to have them directed to a page from a l... |
I created my first gem for Rails today. https://github.com/Fivell/activeresource-response.
This gem adds possibility to access http response object from result of activeresource call.
I don't know how to create test for this gem.
Also I want to ask if there is more simply and elegant way to do this?
Is it really threa... |
Is my destructor correct? Does it properly deallocate the subtrees?
#ifndef HEADER_GUARD__TREE
#define HEADER_GUARD__TREE
#include <deque>
namespace Sandbox {
class Node {
public:
Node();
Node( Node* parent );
virtual ~Node();
Node* GetFirstChild();
Node* GetChild( i... |
I wrote a program to copy a .doc template, add some text to it, then save and close it. I have to do this many times, and saving and closing a word document is slow. I decided to use multi-threading, but I'm a noob at this stuff and just wrote what came to me. Any feedback would be greatly appreciated (on any aspect, ... |
I'm interested in finding the most elegant and 'correct' solution to this problem. I'm new to JS/PHP and I'm really excited to be working with it. The goal is to compare the size of a given image to the size of a 'frame' for the image (going to be a <div> or <li> eventually) and resize the image accordingly. Users will... |
I need your opinion. Which way do you think is right?
The definition of message in this code bothers me because it is a single method that has two separate behaviors. Depending on how many arguments are passed the method will do different things--that stinks.
On the other hand, calling message in the block just feels... |
I have two threads, called Fun and Boring. Each thread takes the same read-only data and runs some calculations over it and returns a [0.0, 1.0] result.
In the current setup, Fun acts as the main thread. It gathers, prepares, and stores the data in a global variable; a memory barrier is used. It then signals (via an... |
I'd just like to get some pointers on my newbie-ish C here. The intention is to have an environment variable provide the "prefix" for any paths this app needs.
For example, APP_PREFIX could be /opt/app, a path the app wanted to get could be /etc/app.conf, and so app_path("/etc/app.conf") should return /opt/app/etc/app.... |
I recently answered a question on Stack Overflow where someone asked for advice about making a Hash thread-safe. They indicated that performance was important and that there would be a heavy read bias. I suggested a read-write lock, but couldn't find a Ruby implementation available anywhere. The only thing I found was ... |
I wrote this code using jQuery, but I think it can be improved. Can you provide some feedback?
var $i = 1,
totalImg = $('.home-featured-bg .absolute div').length,
$theWidth = $(window).width(),
$theHeight = $(window).height();
$('.home-featured-bg .absolute').css('width',$theWidth * totalImg+'px');
... |
I have created a page that displays markers for local attractions on a Google map. There are a few functions that do similar tasks and I have tried to reduce these by incorporating them into one function, but to no avail. Any suggestions on how to go about doing this?
<script type="text/javascript" src="//maps.googlea... |
I am using Trail Division Method with a pre-calculated list of primes to calculate the prime factorization of all numbers less than M (M <= 10^7).
I am using an array of vectors of pairs. The format for 10 is as follows:
PF[10][0].first = 2 // Base
PF[10][0].second = 1 // Exp
PF[10][1].first = 5
PF[10][1].second = 1
... |
I'm creating Sudoku in JS but can't find the way to extract the numbers from the squares. The numbers from the rows and columns are easy to extract but I can't find the way around the squares. According to users input, I'll validate the column, then the row and finally the squares to see if the numbers are being repeat... |
I have the following SQL statement that I think could be improved in areas (I believe there may be a way to use where over having, but I'm not sure how and I'm sure there's a way to reference the last updated column in the having clause but I'm unsure how to do it). Any suggestions would be greatly appreciated:
/* Show... |
I need multiple read access to some data which can be updated from time to time.
I created a class for managing lock-less access to the data. The class uses 2 counters, one for count of the acquired references and another one for the count of released references. The update function replaces the data pointer and then w... |
I am trying to make some code shorter and usable. Can someone look over the code I wrote and let me know if it's done correctly? I think it is but it seems a little too simple. The code allows a user to select a location form a drop down, then goes to that page.
Old Code
if (typeof $.uniform === "undefine... |
The problem I want to solve is to replace a given string inside tags.
For example, if I'm given:
Some text abc [tag]some text abc, more text abc[/tag] still some more text
I want to replace abc for def but only inside the tags, so the output would be:
Some text abc [tag]some text def, more text def[/tag] still some ... |
I did this code for somebody but need it to be double checked before I pass it onto them. Code seems fine but I need someone to confirm I have coded the crossover methods correctly.
Would be great if somebody that is familiar with genetic algorithms and crossover methods, could confirm that I have the correct logic and... |
This Socket Server should handle about 5000 lines of log file entries per second from at least 15 machines from same network. Any tips to further optimize this script or are there any big mistakes?
class Server {
private $callback;
private $clients;
private $socket;
public function __construct($ip... |
I built an extension method to cycle through all items of an IEnumerable starting at some index:
public static IEnumerable<T> Circle<T>(this IEnumerable<T> list, int startIndex)
{
if (list != null)
{
List<T> firstList = new List<T>();
using (var enumerator = list.GetEnumerator())
{
... |
I am building a web app with using UOW and Repository pattern. I have seen many different samples and found each one to be different, so not sure which is the correct way to go. I have a basic understanding of both these patterns and I wanted to know if I should keep one UOW implementation for all the tables in my proj... |
I have this query built using the above, but it feels like it could be improved to make it more concise:
private IQueryable<Lead> _queryLeadsByHeat(int? ownerUserId, bool warmLeads)
{
var predicate = PredicateBuilder.False<Lead>();
predicate = predicate.Or(x => x.LeadPool.DecreaseByUn... |
Is there any simple way to detect user keystrokes that result in character input? In other words, ignore all soft keys and modifier keys? This works but seems sort of hacky:
var keycode = event.keyCode ? event.keyCode : event.charCode
if((keycode>=48 && keycode<=90) || (keycode>=96 && keycode<=111) || (keycode>=186 && ... |
I have been working on a parser generator, in which I want to employ a sort of fluent configuration interface - avoiding the pre-compile step that usually comes with parser generators. It's supposed to be a tool not just for language construction, but also for generalized parsing tasks that you usually end up coding ma... |
I'm trying to implement this algorithm for computing LCM (from the cut-the-knot website). This is my Java code:
public class LcmAlgorithm {
public static void main(String[] args) {
long[] input = { 28, 50, 14 };
System.out.println(lcm(input));
}
private static long lcm(long[] inputs) {
long[] compute = in... |
def as_size( s )
prefix = %W(TiB GiB MiB KiB B)
s = s.to_f
i = prefix.length - 1
while s > 512 && i > 0
s /= 1024
i -= 1
end
("%#{s > 9 ? 'd' : '.1f'} #{prefix[i]}" % s).gsub /\.0/, ''
end
I'd like a clean and fast code to convert raw file size to human-readable format. Any hints?
Update (faster fo... |
I figure there is a better way that I should be doing this:
if !db.collection_names.include?("reports".to_s)
db.create_collection("reports")
end
if !db.collection_names.include?("days".to_s)
db.create_collection("days")
end
if !db.collection_names.include?("users".to_s)
db.create_collection("users")
end
|
K&R 1.8 exercise:
Write a program to count blanks,tabs, and newlines.
Is this a viable solution to the problem and is it properly formatted? I have never programmed in C before, so I just wanted to see if this is proper c programming as it were.
#include <stdio.h>
/* count blanks,tabs and new lines*/
int main(void)... |
I wrote a simple class to deal with parsing and handling URIs for the project I'm currently working on, since it relies a lot on that functionality (eg the Router class and some HTML helpers). Here is the code already commented:
<?php
# URI class
class uri {
# URI scheme
public $scheme;
# URI host
pu... |
I'm not a programmer, but am playing around with a binary tree Class in Python and would like help with a recursive method to count interior nodes of a given tree.
The code below seems to work, but is this solution the clearest, in terms of logic, for counting interior nodes? I'm keen that the code is the cleanest and ... |
This is the code I came up with.It seems correct.
I am interested in:
1) Improvements on code
2) How can it be better than this? i.e. this is O(N^2) Could I have done better in complexity? What should I have read to do it?
Thanks
public int lengthOfLongestSubstringNoRepetitions(String s) {
if(s == nul... |
I have implemented the structure below at least 5 times, and it is getting cumbersome. Is there a better approach?
Current code-segment implemented
public XmlNodeList Templates {
get {
return this.GetElementsByTagName( "Templates" );
}
set {
foreach( UITemplateAssoc nd in value ) {
this.AddTemplate... |
How could this constructor code be improved? I feel like I'm not doing something optimally here...
@interface JGProduct : NSObject {
NSString *identifier;
}
+(JGProduct *)productWithIdentifier:(NSString *)identifier_;
-(JGProduct *)initWithIdentifier:(NSString *)identifier_;
@end
@implementation JGProduct
+(JGP... |
Some time ago I wrote myself a simple blog. The index page is generated
with PHP5, using an SQLite3 database via the variable id handed to it via
the URL.
The SQLite database contains a table called pages. The id refers of course
to the id intergers in this table. Other columns are title, body, time and
timezone.
The t... |
I'm creating a website that parses in currency rates of the three major cities listed below in the $cities array.
<?php
// Feed URL's //
$theMoneyConverter = 'http://themoneyconverter.com/rss-feed/';
// Define arrays //
$cities = array(
'London',
'New York',
'Paris'
);
$currencyCode = array(
'GBP',
... |
I'm working on a webpage with language detection and I have the following script so far (it's simple). I still haven't done the user detection, so it's not available to find the user language (yet), but this will be easily implemented. Though I'm not asking for that, I'm asking for other ways to improve this code. So ... |
the question is simple, for a input [apple, banana, orange, apple, banana, apple], the program will count it as a map: {apple : 3, orange: 1, banana: 2}, then sort this map by it's values, get [(apple, 3), (banana, 2), (orange, 1)]
below is my go version, I'm a go newbie, could you please review it and lecture me how t... |
Here is my code to do it:
import Random (randomR, Random, StdGen)
generateRandoms :: (Random a, Num a) => StdGen -> a -> a -> [b] -> [a]
generateRandoms gen min max = map fst . tail . scanl f (0, gen)
where f (x, g) _ = randomR (min, max) g
The problem I have with this is that I need to pass a list to it e.g., v... |
This was a code test I was asked to complete by employer, and since they rejected me, I wonder what should I have done differently.
var w = 7, h = 6;
var currentPlayer = 1;
var animationInProgress = 0;
var winner = 0;
var map = new Array(h);
var mapHtml = "";
for (var i = 0; i < w; i++) {
map[i] = new Array(h);
... |
I basically want to convert all categorical column in an R dataframe to several binary columns:
For example, a categorical column like
Company
-------
IBM
Microsoft
Google
will be converted to 3 columns:
Company_is_IBM Company_is_Microsoft Company_is_Google
1 0 0
0 ... |
Currently I'm displaying a news feed from an XML file and using a counter to limit the number of news articles that are displayed. But I'm unsure if this is the best way to do it.
Here is my code.
<?php
function get_news($feed) {
$xml = new SimpleXmlElement(uwe_get_file($feed));
$counter = 0;
foreach ($xml->channel->i... |
I'm sure there's a better way to approach the following. I'm writing a plugin where users can enter settings in the following format:
Setting: "object1setting -> object2setting"
It's done this way to allow for multiple objects to be passed within the same JS call. I'm breaking the the strings apart at the "->" symbol a... |
I have 3 tables: students and classes and years. In a fourth table called StudentsInClass, I'm saving students classes in each year. Now I want to show a list of students with their className in Current Year.
This is the query I use but I'm not feeling good with it:
@StartRow int,
@EndRow int
As
SET NOCOUNT ON;
... |
As an exercise in learning Haskell, I implemented a simple key value store, where you can put and get values (as ByteStrings). (For reference this is inspired by this short note describing bitcask's design). I'd appreciate feedback on any aspect (style, 'haskellyness', library usage etc.) of my implementation:
{-# LANG... |
I'm studying C on K&R and now I'm facing a recursion exercise that states:
Write a recursive version of the function reverse(s), which reverses the string s in place.
I've written the code below and I'm pretty sure that it works. I'll be glad to receive some critiques about it.
Reverse function:
/* reverse: reverse ... |
I've written this "little" typeof extension for my JS. What do you think about it?
Its aim is to provide a single reliable typeof in JavaScript, consistent between native vars and objects. I've tested it both in FF 4+, IE 7+, Chrome 12, Safari 5. Also, if you have a different browser (also the version), can you test it... |
I recently discovered that there is no free read-write lock implementation for Ruby available on the Internet, so I built one myself. The intention is to keep it posted on GitHub indefinitely for the Ruby community at large to use.
The code is at https://github.com/alexdowad/showcase/blob/master/ruby-threads/read_write... |
I've just implemented a background animate on some social media icons where the image goes from grey to color on :hover.
I wanted to know if there's a better way to write the following but also implement a fade, so as the background animates, it's also fading in on hover.
<script type="text/javascript">
$(function... |
The Service:
<?php
namespace TestApp\Services\Ext;
class ExtFilterParser {
private $parsedFilters = array();
private $filters = '';
private $requestParam = 'filter';
public function __toString() {
return $this->filters;
}
public function getParsedFilters() {
return $this->pa... |
In my time off I thought I'd implement some idiomatic data structures, starting with a linked list.
Here's my current version:
#include <iostream>
using namespace std;
struct node{
int data;
node *next;
};
void traverseList(node *head){
for(node *iterator = head ; iterator ; iterator = iterator->next)
{
... |
I started playing with Python last week. This is a section of code from an application which reads a configuration file and launches ssh sessions and continuously displays data back to the local user.
The whole project is on Github.
def open_connections(sessions):
""" open_connections(sessions)
Opens ssh connec... |
I have a function that compares sequential elements from a python list and returns 1 and -1:
>>> up_down([0, 2, 1, 3])
[1, -1, 1]
I need a function to return all possible lists from a '-1, 1' list using the function up_down.
>>> possible_lists([1, -1])
[[0, 2, 1], [1, 0, 2]]
I'd like to know if I can write these func... |
I could not find a Boost Python converter which converts std::tuple, so I wrote one.
This was tested with a g++ 4.7 snapshot on Debian squeeze. It uses C++ 11 features,
specifically variadic templates, so requires a recent compiler. This is based on the answer to ""unpacking" a tuple to call a matching function pointer... |
I have an old mp3 player with a broken screen. Consequently, it's a real pain to turn shuffle mode on and off; however, there are a few albums that I wanted to mix together and have shuffled for when I'm working out.
That led me to whip up something in Python -- the first successful result was only about a dozen lines ... |
I have a directory of .xls workbooks with the following naming convention:
001.WIP Monthly Report
002.WIP Joes Custom Report
...
129.PUR Supplier Spend
The number of worksheets in each workbook varies but each worksheet is formatted the same way.
Row 5 holds column headers and rows 6 and beyond hold data:
A ... |
I wrote a simple client for handlersocket server, but I'm not a professional Java programmer and would like to know the opinion of Java developers on my code.
Well I have not yet decided how to implement a class HSResult.
My project is here
HSResult store initial query and answer as List of ChannelBuffers, where each C... |
I just invented PSEUDO Query!
var objects = $.pquery([
'##pquery##', // Initialize as PSEUDO Query Object
[document.body, 'css', [{'background-color':'#f00'}], 'append',
['##pquery##', // Helps distinguish array needing parsing from array of arguments
'<div />', 'text', 'LOL!']
],
['text... |
I wrote the binary search algorithm with Ruby, the code is below. The question is if there's any way to make it look cleaner?
def binary_search(sample_array, x, l, r)
mid = (l + r)/2
return -1 if r < l
return binary_search(sample_array, x, l, mid-1) if (sample_array[mid] > x)
return binary_search(sample_array, ... |
This program forms the reducer of a Hadoop MapReduce job. It reads data in from stdin that is tab delimited.
foo 1
foo 1
bar 1
and outputs
foo 2
bar 1
Any suggestions for improvements?
(use '[clojure.string :only [split]])
(def reducer (atom {}))
(defn update-map [map key]
(merge-with + map {key 1})... |
This is a script I have written to calculate the population standard deviation. I feel that this can be simplified and also be made more pythonic.
from math import sqrt
def mean(lst):
"""calculates mean"""
sum = 0
for i in range(len(lst)):
sum += lst[i]
return (sum / len(lst))
def stddev(lst)... |
I previously wrote the question about version 1 of my code, since then I have released a version 1.6.3. I would just like everyone's opinion on it. Here is the old question: FileMaker PHP API Interface
The code interacts with the FileMaker API for PHP which is the Official version of the FileMaker PHP API (not the fx.p... |
I am having a challenge problem. I have solved the problem but my solution is slow.
The problem is basically the distribution of scores among players. e.g for a 2 player game the possible scorecards combination is 2 because either player can win \$\{0,1\}\$ or \$\{1,0\}\$ while for a 3 player game the possible scorecar... |
For a specific test-scenario I wanted:
avoid accessing the file system through pythons builtin open-function
don't want to use 3rd party libraries like Michael Foord's Mock library
I would like to hear your opinion, if this seems like a valuable solution, or if there are
similar solutions with less lines of code
gra... |
As an update to previous code I've submitted:
Improvements this time are mainly having everything moved to a class, before I plough on and add more functionality (I've come back to C++ after a few years away and this is a revision exercise).
#include <iostream>
#include "LinkedList.h"
class LinkedList
{
public:
Li... |
Here it is at work: pcsn.nnja.co
As you can see, while the slider .shuffle works and is adjusting itself as it was intended to when the corresponding navigational item #menu-main-navigation li a is hovered upon, the effect is a bit erratic with abrupt mouse behavior.
My jQuery is located in the head:
$(document).ready(... |
This feels like the kind of problem that has an extremely elegant solution. But my code is mechanical and straightforward. Not bad but I'm interested if there's something nicer.
Performance is not really an issue. I'm looking for elegant/shorter, not faster.
No underscore.js please; it's not worth fighting my coworkers... |
Please review my first query project. It achieves the desired result, but am I doing it right?
window.onresize = centreBoxInViewport;
function displayLightBox(obj) {
// Get the path to the image
var path = obj.getAttribute("href");
// Create a new image, and set its source.
var image = new Image();
... |
I am building a Perl module which I am attempting to use as few non-core dependencies as possible. Should my following code fail, I would add a dependency on HTML::LinkExtor and be done with it, but I want to try. All I want is to extract the href= attributes from <a> tags. I do it using Text::Balanced which is core as... |
I managed to put together following code to correctly Populate RequestExecutionViewModel model,however this looks extremely verbose to me. I feel some sort of LINQ builtin mapping construct can be used to reduce the over all code size. Please suggest improvements.
string userName = User.Identity.Name;
List<Requests> re... |
Using Delphi XE2, I'm wondering if it would be usable to define a base object something like below.
Class is prone to be used in multiple projects.
I've chosen TSQLConnection as my starting point - since it's using the dbxpress framework and should be able to connect to a wide range of databases and other. But if a bet... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.