instruction
stringlengths
71
71.9k
We've got a "catch-all" in app.js that renders a .jade file if it exists: app.get('*', routes.render); index.js render: function(req, res) { fs.exists('views' + req.url + '.jade', function(exists) { if (exists) { //substring: "/admin" -> "admin" res.render(req.url.substring(1)); } else { ...
I am trying to combine two programs that analyze strings into one program. The result should look at a parent string and determine if a sub-string has an exact match or a "close" match within the parent string; if it does it returns the location of this match i.e. parent: abcdefefefef sub cde is exact and returns 2 s...
I've been using this code for quite some time, but am wondering if there's any improvements I can make to it. Basically it's just code that runs when the page loads or if the code is run after page load, it will run right away. Do you see any cross browser compatibility issues or any more efficient ways of writing this...
I am working on a project in which I have two tables in a different database with different schemas. So that means I have two different connection parameters for those two tables to connect using JDBC- Let's suppose below is the config.property file- TABLES: table1 table2 #For Table1 table1.url: jdbc:mysql://localhost...
I made a simple form validation. It's working alright. The thing is I want my code to be optimized. Can somebody show me some pointers to improve my code? Thanks in advance. $(document).ready(function(){ $('.submit').click(function(){ validateForm(); }); function validateForm(){ var nameReg = /^[A-Za-z...
After posting my first question and my first attempt which you can see here: Canvas spatial grid collision I have re-written it to try and implement what the person gave as an answer. I didn't do the prototype method as it was overkill for this and besides I am saving that for my next project! $(document).ready(functio...
I've tried to improve my code: separate HTML/PHP, much clear, next time change will be easier. After doing research on MVC/OOP, I've made the below code to learn. I understand this is not the MVC pattern now. Can anybody help me fix it to become actual MVC? get the result from db (list all) get the result from db (l...
I want to check if the length of phone number is appropriate for specified country (let's consider that only some countries have restriction, another countries accept phone number with various length). I have a Map, where the correct pairs are defined so this map can be used as a reference in the condition: public stat...
What is the difference between this two way and Which one is best? What do you suggest? 1. Use of query (db) directly in CI_Controller. as: $id = $this->input->post('id'); $query = $this->db->get_where('table1', array('id' => $id))->row(); $this->db->get_where('table2', array('idre' => $query->idre)); Or 2. U...
I can't get a peer review where I work, I was wondering how my code was and how could it be improved. https://github.com/lamondea/uploader Is it a good practice to use functions in classes or should it be replaced by external function that use the object returned by the class: class _export { public $nbr; pu...
A post by Yakk alerted me to the idea of named operators in C++. This look splendid (albeit very unorthodox). For instance, the following code can be made to compile trivially: vector<int> vec{ 1, 2, 3 }; cout << "3 in " << vec << ": " << (3 <in> vec) << '\n' << "5 in " << vec << ": " << (5 <in> vec) << '\n'; O...
I like the radix function and found a really neat way to compute its inverse in Python with a lambda and reduce() (so I really feel like I'm learning my cool functional programming stuff): def unradix(source,radix): # such beauty return reduce(lambda (x,y),s: (x*radix,y+s*x), source, (1,0)) where: >>> ...
I've written a SELECT statement that creates a List of all objects that depend on a single object, so that if I wanted to DROP that object I could DROP all referenced objects first without using CASCADE. It's a long script and I'm not sure if it's gonna work in every situation, so I just wanted to ask if I've missed so...
My objective is to make an array of unique keys from a list of objects. Example: Input: var input = [{"a":1, "b":2}, {"a":3, "c":4}, {"a":5}] Output: [ "a", "b", "c" ] Current approach: var outputObj={}; input.map( function( obj ) { Object.keys( obj ).map( function(key) { outputObj[key] = 1; }) ...
I am creating a game that contains a Board and Pieces. The Board is basically a 2D array of Pieces. [Think smaller chess board] One of the things that I want to accomplish is to be able to retrieve the left piece of a given.. (Also want to be able to retrieve the right, up, and down). The easiest way to achieve this is...
I am looking for feedback on this compact Python API for defining bitwise flags and setting/manipulating them. Under the hood, FlagType extends int and all operations are true bitwise, so there is little to no performance impact. Also, because they are all int, any standard bitwise operation can be performed on them...
I have a web application where I connect with a MySQL database using PDO and in some scripts there are a lot of queries one after the other which don't necessarily concern the same tables. i.e I will execute a SELECT statement in one, and then depending on some values I will UPDATE another and finally go and DELETE fro...
I would love to show you one of my bigger scripts to improve my technique. This script is some kind of Itempicker. You choose your Item first (toprow), then pick a color. The color of the active Item (basically the image) changes. A big deal for me was actually to design the script that way. The way that all the Items ...
I wonder which is better practice when I need to return the primary key value of a newly inserted record from a SQL stored procedure. Consider the following implementations: As Return Value CREATE PROCEDURE [CreateRecord] ( @value NVARCHAR(128) ) AS BEGIN INSERT [Records] ( [Value] ) VALUES ( @value ); RETURN S...
I'll try to provide exactly the amount of context that is necessary to understand the construct. I built an API (well, a small part of one) that works and is kind of usable, but rather unpretty and badly testable, and most of all unpretty. Testability is also an issue. The problem domain has the concept of an 'image' i...
This is based (somewhat loosely) on the code written in this railscast. I'm planning to re-use it in different places throughout the site, so I made it a bit more generic rather than based on IDs. However, I'm certain there's probably room for improvement. jQuery -> $('.org_type_choice').each -> cat_obj = $(this)...
I'm an experienced programmer but relatively new to Python (a month or so) so it's quite likely that I've made some gauche errors. I very much appreciate your time spent taking a look at my code. My intention is to do some experimentation with 1D cellular automata. For now, just totalistic ones (rules only based upon...
I'm new to using NUnit and have written a test to check for the existence of a database table. I have the below code that should check whether a new table named NewTable has been created in the database. It works correctly but I can't help feeling there's probably a better way of doing this. Thanks. using(var conn = co...
I have a booking with a method total which calculates the total price of the booking from the sum of all the prices of activities that belong to appointments. A booking has many appointments and the following seems to give the right answer, but it seems horrid. How can I improve this? def total # TODO shouldn'...
How do I make this more Ruby like? I want to return the host, for example if the URL is "http://www.facebook.com" then I want to get 'facebook.com'. Any other sub-domains without 'www' should give the subdomin as well. If the URL is "http://gist.github.com" then I want 'gist.github.com': def get_domain a = @url.spli...
I have a calculator created using C# that is running on a console. The calculator accepts a string input (e.g. 5+5) then produces the result (5+5=10). It will then prompt the user to enter another operator which will continue the evaluation (e.g. 10+5=15). To terminate the program, one can type the string "done". I ...
i just wanted to confirm if my codes below is correct. Feel free to make corrections. <?php class createConnection { var $host="localhost"; var $username="root"; var $password=""; var $database="wilbert"; var $myconn; function connectToDatabase() { $conn = mysql_connect($his->host,$this->username,$this->password); i...
I'm working on my larger project to date, and on top of that I'm using underscore for the first time. All is working perfectly but I'd like some criticism on the use of underscore templating and underscore after function. The goal of the app is to generate on the dom a messaging interface starting from an empty div. I...
I want to find out if there are any improvements I can make to this code. How can I make it better, faster and use less queries? Or is it fine the way I wrote it? <?php if ( $user_ID ) : ?> <?php global $user_identity; ?> <div id="boxtop"> <div class="boxtop"> <div class="bus"> <div class="busl"> <span class="bin"> Bin...
Could you please critisize the logger class below? Can it be used in a multi threaded web environment? If not how can I improve it? Is there anything wrong with locking in WriteToLog method or multithreading in FlushLog method? public class Logger { private static Logger instance; private static Queue<LogData> ...
I just started to learn Haskell, and i wrote a function that walks the directory tree recursively and pass the content of each directory to a callback function: The content of the directory is a tuple, containing a list of all the sub-directories, and a list of file names. If there is an error, the error is passed to ...
This code computes the function (3x^2-4x+16) / (5x^2+2x-4). I ran the program and it works, but I am fairly new to assembly language and am not quite sure how to make the most efficient use of the registers. Does this look ok or is there a better way to do it? .text .globl main main: ori $8, $0, 3 #put ...
As part of my data collection, I have to run multiple kinds of coverage processing on multiple Java projects. Below is my main Makefile intented only for gmake. Portability is not a requirement for me (for this project), but DRY and following make best practices are. Please comment on my code, and if there is any way t...
I'm new to PHP and had to put together a function that loads a random image from an array (it works fine). Here's what I came up with. Could it be improved? Any feedback would be appreciated. <?php function displayRandomPhotoArea() { $photoAreas = array("imageURL1", "imageURL2", "imageURL3", "imageURL4", "imageURL5...
I have this messy helper method: def gesture(klass, item, text, desc) element_class = klass.to_s + " gesture" content_tag :li do if klass == :sell link_to new_reply_path(item_id: item.id), title: desc, data: {qtip: desc}, class: element_class do content_tag(:div, nil, class: element_class) + ...
I came up with this code whilst answering this question. Is there a simpler way of doing this using standard library? I want to iterate over every object and do something with every other object. For example, 4 values 1, 2, 3, 4 would pair like: (1, 2), (1, 3), (1, 4) (2, 3), (2, 4) (3, 4) Each value combines with ev...
I put the full code at the rear of this post. I've recently answered a question, and the detail explanation is posted in Physical disk size not correct (IoCtlDiskGetDriveGeometry) And en passant answer another one DeviceIoControl does not set output buffer I'd like to know that if any one think there's any pr...
I had developed an application in which I hit several URLs and show data on mobile. But the problem is that it requires more time. If I check the same URL on Firebug tool I get a response in 2-3 seconds, but the same URL requires 8-15 seconds on mobile. In my Android application I am using HTTP get and post method as ...
Should the equals sign be alined on protocol buffers? I am having a huge discussion with a colleague and we can't get to decide on what's the best practice. message foobar { optional bool var_one_short = 1; optional bool var_two_looooooooong_name = 2; optional bool another_var = 3;...
I posted this on SO and would appreciate any ideas on it's stability. Much like the old double-buffering algorithm, this uses a List<T> to which are added entries. You can also take the list at any time, it will be atomically replaced with a new empty one. Both adding and removing is thread safe. You can add from many ...
I have some code that needs to update 2 separate databases with user credentials. The first database, I just use standard sql to do it. The second database, I have to use command line scripts to update a specific table. What I'm worried about is what to do if the first update fails, or if any of the updates fail. H...
I am trying to grab the ffprobe values from the video file into a variable that I can compare against others or move the value into a database. The question I have; Is there a better way of doing it than below? I don't like the multiple if/elif/line.startswith statements and I am not sure of split is the best way of ge...
Trying to implement a deep-iteration function with some constraints, I've noticed the faster solution is iterating it twice! Any attempt to avoid this resulted in slower code. So, the challenge: can you redesign the function below removing the code duplicate and doubled iteration, without making it slower? Constraints:...
The code realizes producer/consumer problem with multiple producers and consumers. Have this code any potential deadlock or races? //RandomDataProvider.cs namespace MyNamespace.Core { using System; /// <summary> /// Provides randomly generated data. /// </summary> public class RandomDataProvider ...
The facade pattern is used to abstract adding events. Should support IE5+ as stands. Looking for minor improvements. Don't need to support prior to IE5. I choose not to use a library. /*addEL ** dependencies - none ** browser - IE5+ ** notes - improved per answer */ NS.addEL = (function binding() { if (window...
*Originally posted this on stackoverflow but was told that it would be better suited here. So I'm looking for a better way to setup how an application talks with a database. I'm sure this question has been asked many times, and I dug through a few of the similar ones but couldn't find one that really flushed it out as...
I have recently implemented my SQLite helper class that supports SQLite in a memory class to be opened to not to be lost. Please review it and tell me if there is a coding problem and tell me what to do to prevent\fix it. using System; using System.Collections.Generic; using System.Data; using System.Data.SQLite; using...
I'm going to have a lot of integer values, and at any value change I might need to update any number of UI elements, other values which are computed from the first ones, etc. Sounds like time for the Visitor pattern, but I'm new to Java (more comfortable in C++). I have: import java.lang.ref.WeakReference; import jav...
I am working on a multithreaded project in which each thread will randomly find columns for that table and I will be using those columns in my SELECT sql query and then I will be executing that SELECT sql query. AFter exectuing that query, I will be looping through the result set and will add the data for each columns ...
I am tring to count the number of exceptions happening and log those exceptions as well. So what I did is, I created one method addException in which I am counting all the exceptions. addException method accepts two parameters, one is the String, and other is the boolean flag which means whether we want to terminate t...
This question was put forward by my senior to draw a hollow rectangle in C#, and with the condition that the rows and column would be specified by the user. I was stuck at first, but tried to code and after several hours I realized how it would be done, and then I accomplished the task. I would like to share my code, a...
I'm new to PHP and I would like to redirect the visitors of my website based on their operating system. Below is my solution. Is there anything that needs to be optimized? <?php // MOBILE $android = strpos($_SERVER['HTTP_USER_AGENT'],"Android"); $blackberry = strpos($_SERVER['HTTP_USER_AGENT'],"BB10"); ...
I wrote something to the effect of a try catch finally statement helper in functional style so that I can shorten much of the code I'm writing for my Service Layer that connects to an SQL database. Because of that, I found myself needing to code up a lot of try catch statements. I found this article this article on a f...
I have three sliders with different min, max values, everything is working fine from following the tutorials on the jQuery UI website. $("#yield").slider({ range: true, min: 15.2, max: 308, step: 0.3, values: [75.8, 241.4], slide: function (event, ui) { $("#yield-value").val(ui.values[0...
By browser unknown, i mean i don't know how far back support goes for this. Also, I'm wondering when I can delegate to typeof. I've heard typeof is faster but the method below is more widely supported and also mentioned in ES5. /*isType ** dependencies - none ** browser - unknwon ** */ NS.isType = function (type, o)...
I've coded this function where you read all text file in a directory and you save in a temporary file all values. The text files are x, y and z format. The function returns the name of the temporary file the bounding box the origin (top-left corner) and the bottom (bottom-right corner). I wish for some comments or ...
My main method (remove-random-edge) looks quite difficult to read. I'm new to list, so would appreciate any advice on how to improve the code. (defun find-node (node graph) (find-if #'(lambda (i) (eql node (first i))) graph)) ;; Input, graph, is in form ((from-1 to-1 to-2 to-3 ...) ;; (from...
I made my first script of MySQLi. I have just learnt it from 3rd party website. So, I am not sure I am using functions which are not deprecated or outdated. I should start to practice good scripts to access databases. So, I have posted here. Any mistake you see, please point it out. <?php include "functions.php"; $a ...
I'm implementing a checkers engine for a scientific experiment. I found out through profiling that this is one of the functions that takes up a lot of time. I'm not looking for an in-depth analysis, because I don't expect you to dive super deep into my code. Just: are there any obvious inefficiencies here? Like, is it ...
I made a Python function that takes an XML file as a parameter and returns a JSON. My goal is to convert some XML get from an old API to convert into Restful API. This function works, but it is really ugly. I try to clean everything, without success. Here are my tests: def test_one_node_with_more_than_two_children(...
I have a text file with lines that look like this: Robot(479.30432416307934|98.90610653676828) Robot(186.42081184420528|213.11277688981409) Robot(86.80794277768825|412.1359734884495) or, more general: Robot(DOUBLE|DOUBLE) How should I parse it in Java? I have written the following (tested and working) code: private s...
This my 3rd question on the same exercise, but by no means a duplicate. The two previous questions were posted on StackOverflow here and here. Now I'm posting my Oracle solution (below) that works. I wonder if the same could've been simpler and/or much more efficient. Not in terms of CTE or analytic expressions but wi...
Question Given a binary search tree, design an algorithm which creates a linked list of all the nodes at each depth (eg, if you have a tree with depth D, you’ll have D linked lists) Here is my attempt at a solution. I haven't test it, but I was trying to get feedback on whether or not this would be an appropriate app...
I have a list of boxes, and wish to group them into unconnected sets of overlapping boxes. (Note that two boxes A and B may not overlap each other, but if they are both overlapped by a box C, they will still be grouped together). The following works ok, but I feel like it could be made a lot more concise with LINQ, or ...
I want to create a program(in Java) which simulates the functionality of Arithmetic Logistic Unit(ALU). Here is my code. Please check is this correct. Can I implement it better? public class ALU { public static final int NOP = 0; public static final int SEQ = 1; public static final int SNE = 2; ...
I wrote a tail-recursive list-flattening function, but I'm not too happy with it. a) Is tail-recursion necessary here, or will the function be optimized without it? b) It's ugly how many clauses there are, and that I have to call out to flatten in the expression of the first clause of flatten_acc So, how could I do bet...
This question is about code style. I have this line in one of my models: has_many :owning_artists, :through => :artist_tracks, :source => :artist, :conditions => { :artist_tracks => { :artistic_role_id => 1, :another_memeber => 42 } } What is the best way to break this up on multiple lines, and indented of course, and...
I believe this is essentially the same method as the itertools.combinations function, but is there any way to make this code more more perfect in terms of speed, code size and readability : def all_subsets(source,size): index = len(source) index_sets = [()] for sz in xrange(size): ...
I am new to Python and not very familiar with advanced Python data structures. I have written a function to receive data from a socket in Python and perform string manipulations on it. The basic purpose of the code is to get the metadata from an Icecast radio stream based on suggestions I found elsewhere. The function ...
Is there a better way to get the underscore-case version of an ActiveRecord model's name? So far this works, but it's far from ideal: my_active_record_instance.class.name.underscore
I made a program that allows you to assign stats. However it uses some fairly complex if-else statements. Also, someone told me that goto statements were bad, but why is that? I know that switch might have been a better solution, but I cannot get switch statements to work for string variables. #include <iostream> int ...
I got a ton of helpful tips last time I posted some code, so I thought I would come back to the well. My function is deciding whether or not the secretWord has been guessed in my hangman game. I am trying to accomplish this by taking a list, lettersGuessed, and comparing it to the char in each index of the string secr...
This is my python solution to the first problem on Project Euler: n = 1 rn = 0 while n < 1000: if n%3 == 0 or n%5 == 0: rn += n n = n + 1 print(rn) I would like to find a way to keep everything in this python code to as little number of lines as possible (maybe even a one liner??), and possibly improve...
Here is my method: public JsonResult ValidateAll(string toys) { Dictionary<string, object> res = new Dictionary<string, object>(); List<string> result_check = new List<string>(); string[] lines = toys.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (string line in lines) ...
You might have read my question on shortening my code to a one-liner for Problem 1. So, I was wondering, is there any more tricks of the trade to shorten my Problem 2 solution: fib = [0, 1] final = 1 ra = 0 while final < 4000000: fib.append(fib[-1] + fib[-2]) final = fib[-1] fib.pop() for a in fib: if a%2 =...
I have to implement a class with has parent and child fields. The problem is that by adding a child it must immediately keep reference to its' parent. I implemented it and it seems to work but I am not quite sure if I did it right. Any advice will be useful! namespace DocumentToDocument { public class MyEventArgs<T>:...
In the following piece of code I use the same trick three times. But cannot figure out how to write a common function that will do it for all of them. I know there is a toggle method in jQuery that does something similar but in this situation I wasn't able to get it do the job for me, so I wrote this: // fallback for i...
I have been working on translating some code from C to C# but since I haven't been coding in C / C++ for many years now plus I do not want to resort to the unsafe keyword. I have made an attempt and would like some verification & optimisation suggestions. Here is the code in C/C++. #ifdef __cplusplus /* C++ cannot assi...
As you can see below, I have a method which executes statements based on the first letter of a component firing an ItemEvent: public void itemStateChanged(ItemEvent ie) { if(ie.getSource() == rRadioButton) { currentScale = "r"; ((DefaultEditor) rSpinner.getEditor()).getTextField().requestFocus(); ...
I have implemented changes from a question I asked on this widget here: Android widget code I've added and changed a few things, so I would love some more coding advice! public class SacWidgetService extends Service { private static final String TAG = "SAC WIDGET SERVICE"; AQuery aq; private String roseXML ...
I wrote a productivity app for Android. It lets you switch system settings, like Bluetooth, wife, screen brightness, volumes, ringtones, mobile data, airplane mode, etc. Unfortunately I have discovered that device manufacturers modify the OS in every possible way, disabling functionality, requesting additional permissi...
I am working on a project in which I have two tables in a different database with different schemas. So that means I have two different connection parameters for those two tables to connect using JDBC- Let's suppose below is the config.property file. NUMBER_OF_THREADS: 10 TOTAL_RUNNING_TIME: 2 SLEEP_TIME: 200 RANGE_VAL...
I'm having performance issues with this query. If I remove the status column, it runs very fast; but adding the subquery in the column section delays the query way too much (1.02 min execution). How can I modify this query so it runs faster while still getting the desired data? The reason I put that subquery there is ...
Is this an ideal use of if..else or can this code be simplified/beautified further? // If any image found and bigger than thumbnail settings, get that one if ( isset( $matches ) && !empty( $matches[1][0] ) ) { $image_found = $matches[1][0]; $image_dimensions = getimagesize($image_found); ...
I'd like to know any ways of shortening this UI window for Maya, at the moment, because I couldn't find very detailed documentation and not very skilled with python, I have just built this UI with the knowledge that I have already, I know it's not the best way of doing it (using empty text elements to fill gaps etc) Ca...
This script extracts all urls from a specific HTML div block (with BeautifulSoup 4) : raw_data = dl("http://somewhere") links = [] soup = BeautifulSoup(raw_data) data = str(soup.find_all('div', attrs={'class' : "results"})) for link in BeautifulSoup(data, parse_only = SoupStrainer('a')): links.append(urllib.parse....
I've got this code Double best = nodes.get(edge.getToNodeId()); if (best == null || (best > g+h)) { nodes.put(edge.getToNodeId(), g+h); if (best == null) { open.add(new State(edge.getToNodeId(), g, h, top)); } else { open.modify(new State(edge.getToNodeId(), g, h, top)); } } I don'...
So I create 3D tree like structures using L-systems. Basically this means I generate a string like this: "FFFFFFFF-[[FFFF-[[FF-[[F-[[X]+X]+F[+FX]-X]+F]]]]]" This string is then interpreted by a turtle performing certain actions for each character in the string. The problem is how to map characters to turtle actions i...
I wrote some code which compares numbers of all datatypes with each other. The standard Comparer which is implemented by every number Type only compares numbers of the same type. I cast to decimal because this is the largest possible number type and should cover everything. What do you think about the code? Is there a...
I am learning C# and I have made my way through the entire C# 101 course on buzz3D. The last project they have you do is create a product inventory system that must be split up between classes and only the Main() method can be in the Program class. It was listed that all methods had to be as close to or below 25 lines ...
So I am essentially a complete newbie to programming, and have been attempting to learn Python by completing the Project Euler problems. I haven't gotten very far, and this is my code for problem #3 : The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? Altho...
Can anyone help me speed up this query? At present, it returns 1200 rows in 5 secs. I've notice that it is looking at 240000 response records. I think this is where the issue may be. I've created the following indexes: CREATE INDEX idx_eventid ON `action` (eventid); CREATE INDEX idx_actionid ON `response` (actionid)...
I am studying about how to use an interface for decoupling, and I wrote a program. Does it actually implemented decoupling? Are there any possible modifications to make it better? public partial class MainPage { // Constructor public MainPage() { InitializeComponent(); IDBInterface idbInt...
I have tried to build my first MVC sign up form. Here is the user controller method register: public function register() { if($this->isPost()) { $user = new UserModel(); $result = $user->add($_POST); if(!$result) { $this->redirect('user/register'); } elseif(is_array($resu...
I have a few hundred files in a directory that I need to read in parallel. Namely, the files that have the same name, but different file extensions (.a and .b), but they're pretty much plain text files. The corresponding .a and .b files have the same number of lines. I need to read each line into cell arrays x and y un...
I have this function containing some loops and a double for loop. What it does is set up a matrix first to store results in (the task at hand is comparing genomes) and then with sliding window, calculate the differences between sequences. It's very slow for very long sequences, I was hoping somebody know how to speed t...
This is a simple repeatable question regarding the usage of Python3's comprehensions: Could the Python3 syntax be used in another way to speed up the process, further so the gap between Python3 and numpy would be reduced? (see chart below). The results & code: Above: Runtime test of Python3's list comprehension, dict ...
I have a method that parses XML into an array of hashes. Here is the original XML: <rowset name="skillqueue" key="queuePosition" columns="queuePosition,typeID,level,startSP,endSP,startTime,endTime"> <row queuePosition="0" typeID="20495" level="3" startSP="2829" endSP="16000" startTime="2013-03-04 16:25:50" endTime="2...
I wrote the following function that takes a string and returns a new string with each word capitalized: first letter uppercase, following letters lower-cased. It works, but I would be interested in seeing how a more sophisticated Haskell programmer would do this (if there is already a built-in, great, but still interes...
I have an upload form on my site and I'm trying to sanitize and transform input data. I will be straight forward to you - this is my first object-oriented style code! The reason I don't just want to use regular function, is that I would like to keep my codes divided in logical blocks. I called this one Filter. It has,...