instruction
stringlengths
71
71.9k
I have a plugin that grabs the coordinates of all the cities in our database working in WordPress here. function findCoordinates($address) { $latitude = null; $longitude = null; if (!is_string($address)) { throw new InvalidArgumentException("Address must be a string"); } $url = 'http://maps.googleapis.com/maps/ap...
This is an app that I started on a while back to get digging into Rails. It's grown and is now a functioning app. However, the user model is now over 200 lines long. I would love your opinion on how to clean this up. # == Schema Information # # Table name: users # # id :integer not null, p...
This code stores the last know location in the session. The location is not stored if it is one of the exceptions in the if statement. def store_location if request.fullpath != '/users/sign_in' && request.fullpath != '/users/sign_up' && request.fullpath != '/users/password' && request.fullpath != '/...
I have a text parser that reads certain information from a given file with a specified format. The text file contains some measured properties of a product. The date model number/lot number is written on the file name. class SomeTextFileParser { private static int POINT_COUNT = 15; string filePath; string ...
I was working on a project that need to remove extra data such that the remains are not "too close" to each other, and the algorithm should be as generalize as possible. To have more general usage, I try to write in std format. I'm not sure if the algorithm is the best way to accomplish the goal, or if the style of co...
I needed to write a settings class for my web app; ideally this class should read its settings from a file (and be able to save them back to the file), and have only 1 instance per application - all threads read the same object, so that the settings only need to be loaded from the file when the app runs for the first t...
I'm pretty new to microcontrollers and C in general, so I thought asking here would be a good way not to get started with bad habits. /* * ringbuffer.h * * Created on: Jun 11, 2014 * Author: Silly Freak */ #ifndef RINGBUFFER_H_ #define RINGBUFFER_H_ //for size_t //TODO is it a good idea to force size_t for...
I'm currently learning some jQuery and I am stuck on something. On a small exercise I did, I was asked to perform an action when you mouseover a div class. I gave a different solution than the one suggested and I was wondering which one is written best and why. HTML code <tr id ='user_1' class='datarow'> <td><input...
I've written some code to calculate how many Pomodori can fit into a period of time, including long and short breaks. I'm looking for alternative solutions because what I have at the moment doesn't feel right. I think I'm missing something. A Pomodoro is an interval of time 25 minutes long and after each one there shou...
I have a list of words (with repetitions), and I intend to find out the longest words amongst them, along with their length. My question is to know if my implementation is too verbose, is using too many operators/functions and if so, what are the better, more idiomatic, readable alternatives. Given the list below, the ...
def is_prime(n): if n % 2 == 0 and n > 2: return False return all(n % i for i in xrange(3, int(math.sqrt(n)) + 1, 2)) The code works fine for a range of numbers after that it shows: OverflowError: Python int too large to convert to C long How can my code be made faster and more efficient?
I'm handling user permission in a MVP Winforms application as follows. Here I'll give a full detail of my code as it will be helpful when answering to this question. My user model has a list called permissions which holds the permissions of the current user. (eg: CAN_EDIT_ACCOUNT) public class User { // // ...
I created this class which supposed to take a method and try to execute it. If it fails lets say 10 times, it will throw the original exception thrown by the delegate. Do you have any ideas for improvement about that code? I am particularly interested, in where to put this code. Right now it is within a FileHandler ass...
I have the following structure for my object: Word (Object) Word (String) List<Symbol> Symbol (Object) Symbol (String) List<SymbolChoice> SymbolChoice (Object) Symbol (String) The background of this is that this is processed OCR output and I want to force a word to match a certain regex. If it cannot find a match...
What can I do to improve this function, which calculates the win expectancy of a soccer team, given their strength: def winning_prob(first, second, first_at_home=False, second_at_home=False): """ Return winning probability, given ELO ratings of two soccer teams Args: first: ELO rating of first team ...
I got the inspiration to write this algorithm from this question. The OP cited the Sieve of Atkin as one of the fastest ways to generate primes. So I figured I would give it a try: def sieve_primes(limit=100): sieve = [False]*limit loop_range = range(1, int(limit**(1/2))) for x, y in [(x,y) for x in...
I was going to post this code as an answer to a recent question, but I wrote this code a little while ago (like, a year ago; if I recall correctly I wrote this after reading this article) and I'd like to get some feedback on it instead. The idea is to address a cross-cutting concern using DI interception, by implementi...
This servlet takes an input from the user and Stores the number inside the bean but with spaces in between each digit then stores the bean in the request scope. If the last digit is even, sums the numbers and stores it in the request attribute. It will be displayed by even.jsp. Otherwise, the servlet forwards to odd.j...
This is some boilerplate I found myself writing on a new abstract class. It seems ripe for refactoring, but I'm not sure the best way to implement it more effectively. Is there a pattern for these sort of time-stamping/status-updating methods? def create() { tsCreated = new DateTime() userCreated = springSecuri...
I am a beginner at programming. I was able to build the thing below, which achieves what I want with a small dataset. With larger datasets, my RAM gets swamped bringing the computer to a halt (2014 Macbook Pro with 16GB RAM). Can I simplify my process somehow? # This code starts from a co-occurrence list of pairs with ...
I was bothered by inability of C++ to mix cout and wcout in the same program - so I've found this question: Converting between std::wstring and std::string It didn't help me because it was mostly about MS Windows (I'm on Linux), but thanks to it I've found something similar to the WideCharToMultiByte functions in the C...
This code horrifies and scares me. I wrote this. public IQueryable<StudentTrack> StudentTracks(int employeeId) { IQueryable<StudentTrack> EducationPortalStudentTracks = from studentTrack in _dbContext.EducationPortalStudentTracks join track in _dbContext.EducationPortalTracks on studentTrack.TrackI...
I am currently developing a puzzle game that has sequence numbers. The player has to fill the grid with sequence numbers in ascending order. Starting from 1 the player can move horizontally or across and can skip a square in between if it is empty or blocked. To generate the puzzle automatically, my code is doing the f...
I written this code to search 'blob' items (text files) on the basis of their content. For example, if I search for "Good", then the names of files that contain "Good" or "good" should appear in the search result. My code is working but I want to optimize it: class BlobSearch { public static int num = 1; static...
Getting a hook on an open instance of Excel is something I do all the time. I'm now questioning if I'm doing this the best way. I'm particularly concerned with the fact that I rely on the GetObject method to throw an error. I'd like to avoid it if possible. I have a Utils module that contains a function that returns a ...
How do I make these line of codes more scala-ish (shorter?). I still get the Java feeling in it (which I want to stay away from). import scala.collection.mutable val outstandingUserIds: mutable.LinkedHashSet[String] = mutable.LinkedHashSet[String]() val tweetJson = JacksMapper.readValue[Map[String, AnyRef]](body) ...
I've implemented the Floyd Warshall algorithm in this problem. However, as this is my first time in handling with adjacency list, I was not able to make it memory efficient. I used a 1000*1000 and another list of 1000 size but I have seen solutions of people getting accepted with 100*100 size. How can I make my graph...
I made this small text adventure just to see what I could do with Python, and I'm basically wondering how it could be optimized, especially my combat as right now I'd have to rewrite it every time I want combat. import time import random spider_damage = 10 inventory = [] iron_dagger_damage = random.randint(5,12) playe...
I wanted to create a cart that I can easily add some item or simply help someone at the other end over the phone. I decided to create a cart that would store everything on MySQL instead of using $_SESSION. I did not code the whole cart just in case that this idea is very very bad. But I wanted to show what I have done...
I'm writing a small scientific programming language, and I thought my first step would be to write a calculator with built in significant figures. I wrote this with JParsec for the lexing and parsing. I was wondering if there were any problems you could see in my code. I'm fairly skeptical of my own use of BigDecimal. ...
I am using the following macro to insert a mini table of contents between two identical heading styles (e.g. Heading 1). It works fine on small documents, but is very slow on large documents. Sub MiniTOCFields(HeadingNumber As Long, TOCLevel As Long) ' Add mini TOC fields after all occurrences of a Heading style. '...
This is my first Scala game. I would love some feedback on my coding style, or your brief input on how you would do it. object tictactoe extends App { def tttFormat(board: Array[Char]): String = "|" + board(0) + "|" + board(1) + "|" + board(2) + "|\n" + "|" + board(3) + "|" + board(4) + "|" + board(5) + "|\n...
I have a working version of a logfile searcher that targets a specific directory by extension type, and searches the files for certain words. I'm wondering if my method is the most efficient implementation, or if there are things I could do better. string startFolder = @"C:\logs\"; // search within these extensions...
I recently wrote my first WordPress plugin, which was also my first PHP project. After I was done, I didn't care for the code at all, so I have spent the past couple of days refactoring it. I'm trying to take a more OOP approach to improve readability and make it easier to optimize. Prior to this, my only real exposure...
In this strstr implementation, I am basically skipping the already matched and checked characters with an if else condition. Is this a right way of implementing it? char *strstrImp(char *input, char *find) { if(*find=='\0') return input; if(*input=='\0') return NULL; char *start=input; ...
I'm learning segment trees and their implementation. For the purpose, I tried solving the problem on CodeChef. Full code here My tree implementation is as follows: #include <bits/stdc++.h> #define _MAX (1<<17) #define MAX (_MAX<<1) using namespace std; struct node { int tails; int heads; void Merge(node ...
I wanted to know if this code is safe against SQL injection or not? Also do I need to mysqli_close if I already did the mysqli_stmt_close? Other suggestions are always welcome. if ($stmt = mysqli_prepare($connect, "SELECT subcategories.subcat_name, subsubcategories.subsubcat_name, subcategories.subcat_ID FROM subcateg...
I have the following string replacement program for a string of size 256: I am replacing the string "\'" with the string &apos; Please suggest any modifications if needed or any mistake I have done. #include <stdio.h> #include <string.h> int replace_str(char *SrcStr, char *SubStr, char *RepStr, char *FinalStr ) { ...
I have the following function which runs as expected and is defined in the window object: function myFunction(url, timeout, type, sc, ec) { return $.ajax({ url: url, timeout: timeout, type: type, success: function (data) { if (typeof sc === 'function') { s...
I am using a Telerik Datetime control. On onBlur event of input box I am checking if the date is valid/in-valid, based upon that I am enabling or disabling the submit button (anchor tag actually). var embedUrl = null; function onBlur(sender) { var constants = { classDisabled: 'button-disabled', empt...
I've written an image processing library for downscaling, sharpening, compressing and caching images using PHP and ImageMagick. Having recently been a chef in the kitchen of procedural and vague spaghetti code, I would appreciate feedback on: Code quality and appropriateness Code clarity Whether the structure is suit...
I am creating a two-dimensional array, which I am going to process later in ways similar to image MinFilter, procedural labyrinth generation, etc. -- implying using coordinates and neighbors. Here are two ways I came up with now: array := make([][]byte, 0, HEIGHT) for i := 0; i < HEIGHT; i++ { array = append(array,...
I just started using Perlin noise a few days ago, and the results look quite good. But it takes over 3 seconds to calculate and draw a 1024x1024 bitmap of said noise. I use an array of 1024x1024 to store int32s ranging from -1 to 1. Please note that the variable tileSize equals 1024 / resolutieX. This is in case I want...
Currently I have var l1 = [...]; var l2 = [...]; if (l1.length > l2.length){ var i = l2.indexOf(l1[0]); if (i !== -1){ action_a(i); }else{ action_c(); } } else if (l1.length < l2.length){ var i = l1.indexOf(l2[0]); if (i !== -1){ action_b(i); }else{ action_c(...
I have a code that creates a 3D array of values from a minimum to a maximum in X and Z with constant Y. Right now I make it in normal Python, and then I transform it in a np.array. Is there a way to make it directly a NumPy array? How can I translate the code in NumPy to make it faster? targets = [] X = Y = 0 STEP_X...
I have taken a widget/ plugin that I wrote yesterday and just now it has been re-written in an object oriented format. It is certainly more code to write it the OO way, so please let me know also how to analyze the performance of each example of the same widget below: Please keep in mind that I use data-attr selectors ...
An 'abecedarian' is a word whose letters appear in alphabetical order. Write a program which will determine whether the given word is abecedarian or not and print 1 if abecedarian, 0 if not. Input : user enter a string or word. Output: print `1` if word is Abecedarian else `0`. Test Cases : abc 1 beee 1 c...
I have posted below a small project of mine in AS3 regarding a super simple Expense Tracker. I finally made it basically functional, and I learnt A LOT in the way. But even I can tell that my design is horrible. If anyone was kind enough as to mention my mistakes to me and/or give me some advice, I would be extremely t...
I am going through the example of SHA256 over at Wikipedia and wanted to make sure I understood all the operations of the manipulation math before trying to actually attempt the implementation itself. The comments explain the entire thing. Want I want to know is: Are my operations correct? The SHA256 code seems to be ...
I've been trying to figure out the best way to manage database connections for a while now and am still unsure of how I should be doing things. I know there are a lot of similar questions on here, but I've read many of them and am still confused. Some answers on here say singletons should be used, but it seems a larger...
I am implementing a Point in polygon algorithm. Inputs: M, N: size of the matrix poly: a list of tuples that represent the points of polygon. Output: A mask matrix which is ones everywhere, except the point in the polygon should be 0. import numpy as np import cv2 def getABC(x1, y1, x2, y2): A = y2 - y1 B =...
The following example shows how to implement a queue in an employee structure. I am looking for a review of the implementation: import java.util.LinkedList; class GenQueue<E> { private LinkedList<E> list = new LinkedList<E>(); public void enqueue(E item) { list.addLast(item); } public E dequeue() { ...
I've spent the last couple of evenings trying to build a system for redistribution of votes in a ranked voting system. I've finally come up with the model for redistributing surpluses from a candidate whose number of votes exceeds the threshold. I'm at the beginning of my learning curve and I've used Stack Overflow ex...
I'm using Entity Framework 6 with database first. See the image for the relevant database schema I have the following method to save a Set to the database: /// <summary> /// Saves the list of data sources. This assumes that the ModelTemplateID, SetNumber and TaskNumber /// are already properly set. Adds a new record to...
I'm very new to Haskell. I did try it for a few days, a few years ago... but other than that, this is my second day. I'm equally unused to functional programming, by the way. After much trial and error, I managed to write this function: chunk :: Int -> [a] -> [[a]] chunk n xs = chunk' n [] xs where chunk' _ res...
I'm using a StaTaskScheduler (TPL extension) to open some web browser windows simultaneously and navigate to different sites (using WatiN, but it might as well just be a WebBrowser). In my example below I'm running 5 concurrent browsers. Works fine, but it locked the UI thread, so I wrapped my tasks in a BackgroundWork...
I'm a Scala beginner, so it'd be great if anyone would be so kind to give some feedback. package heap import scala.collection.mutable.ListBuffer class Heap[T](compareFunction: (T, T) => Int) { private val HIGHER = 1 private val LOWER = -1 private val heapRepresentation = new ListBuffer[T]() private def lastIndex =...
Here is some code I have that has been extracted and shrunk down from a project of mine. #include <stdio.h> #include <stdint.h> #include <time.h> #include <string.h> #define streq(x, y) (strcmp((x), (y)) == 0) #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) typedef struct { const char *cmd; void* (*fn)(void); ...
I have a .net 4.5 desktop script which has dependencies on some third party libraries (dll's). These libraries are used in my MainWindowViewModel. I need to check that these dll's are present before their absence allow the program to break (which is basically at the starting point of the code). This is how I am handlin...
Seeking to improve upon my high score 'module' code. It saves users' high score in a pickle database and if needed prints out the current scores in the database. import pickle import os global high_scores def setup_scores(): global high_scores high_scores = {} if os.path.isfile('highscores.pkl'): ...
Feature-based authorization It seems to me that if you rely on roles to authorize a web application it makes it very difficult to render UI or code based on a set of features. This means that each role would have be checked against for each feature. if(User.IsInRole("SomeRole") || User.IsInRole("OtherRole")) { // Do ...
I've been toying around making my repositories a bit more fluent for a while. I was ending up with crazy long method names when I had to query on multiple conditions. So I've been working on a way to query fluently. Usage Insert/Update/Delete Looks and behaves exactly like a normal repository. var personRepository = ne...
This code will check the database for an order number. If none exist it creates one. If one does exist then it will increment it by one and update the database. Is this the most efficient way to handle this? // Order Number check let updateOrderNumber bizLocId = // order number record exist let numExist = ...
I use a lot of "when user clicks on element then another element will be displayed as visible/hidden... aka toggle". So I'm trying to make a general function to abide the DRY principal. Before jumping into the code, I just wanted to state that there are still bugs. I just want to know before continuing if writing a fu...
Here is some code I wrote 10 years ago. I'm now reviewing it and there are a lot of things I don't like. There is possibility for weird behaviour if the template is attempted to be used with a type that I didn't intend. Also I don't like the big macros for DECLARE and DEFINE; and weird compile errors can occur if it is...
This PowerShell script works a bit like a one-way rsync; it's good enough for my Surface RT needs, anyway. However, seeing as this is my first PS script, and I was learning the very basics while working on it, I suspect I may have committed many crimes of fashion and/or formatting. Also, it's much, much slower than the...
I have implemented the following scenario for the Mediator pattern sample: MailingListMediator: Manages the subscription and send the mail back and forth. JavaMailingList SQLMailingList (Colleagues)MailUsers: They can login, subscribe to the mailing list, send mails to mailing list. GmailUsers YahooUsers My impl...
I've adapted an Instagram widget from this example so that it now appends 8 images to their respective IDs using an Instagram username. I want my widget implementation to be better and more efficient. I'm very new to this so I'm sure there are parts that are no longer needed or that could be greatly improved. var acce...
This a solution for Project Euler Problem 185. It works fine for the example but slow for the problem statement. How can I improve its speed and efficiency? import itertools from collections import defaultdict def mrange(start, stop, step=1): i = start while i < stop: yield i i += step #produce...
I've written a small script to benchmark our LAMP hosted servers that assess the performance based on three factors: Disk I/O Database I/O (mysql) Database I/O (sqlite) The logic is as follows: get the type of test performed using a querystring value. generate a big random string of 100KB. If (disk-i/o) write this l...
I have written code to solve the following Rosalind problem. This is my first time writing in C and I would like a review of my code, particularly in regard to correctness and performance. #include <stdio.h> #include <string.h> int main() { /* Input DNA of length at most 1000 nucleotides */ char dna[1000]; ...
I've wrote a very simple implementation of Deferred / Promise pattern (inspired by jQuery's $.deferred) for my tiny project (which does not use jQuery) It can handle multiply onSuccess an onFail callbacks with result caching. Example in comments above the code. /** * defer() returns methods: * resolve(data) - re...
I don't have a lot of experience writing libraries and just recently started thinking a lot about structure and patterns. I wrote a tiny module manager based on the facade and mediator design patterns and very vaguely based on require.js / AMD and libraries using facade+mediator patterns like jQuery. My goal is not onl...
In my DAL currently I'm handling exceptions as follows. Is it in an acceptable level? Note : I'm using MVP in this Winforms application. public bool InsertAccount(IBankAccount ba) { string selectStatement = @"IF NOT EXISTS (SELECT ac_no FROM BankAccount WHERE ac_no=@ac_no) BEGIN INSERT INTO BankAccount ...
In a question about reimplementing strstr(), I posted an answer. I pointed out a need for const- and non-const versions of the function, and provided Implementation A below, which received criticism about the ugliness of the const_cast. Therefore, I've written two more implementations (B and C). Implementation A: con...
Recently, I encountered an anomaly in the manner by which a worker thread was terminated. It prompted me to do some searching and I realized that I was constructing thread code in a haphazard manner. In hopes of beating this subject to death, I'd like some opinions, please. The issue is real and serious; the use of a T...
I've got this code in my ApplicationHelper file: def new_button case controller_name when 'cars' "<li class='has-form'><a class='button' href='#{new_car_path}'>New Car</a></li>".html_safe when 'trucks' "<li class='has-form'><a class='button' href='#{new_truck_path}'>New Truck</a></li>".html_safe when 'm...
Assume the following definition: public class DataPoint { public DateTime Date { get; private set; } public double Value { get; private set; } public DataPoint(DateTime date, double value) { Date = date; Value = value; } } If var points = ... //a date ordered list of DataPoints I want to convert points int...
This is sort of a follow up to a previous question (Do I have any SQL leaks?). I have changed some things around and am working on a solution where I use Active Directory to gather information about the user rather than use the user table from the application that is run on these App Servers (the thing I am trying to k...
I'm a beginner Java student currently learning from Absolute Java 5th edition. I think I understand the content well but I am never sure of my style. This code is for a question after the second chapter on defining classes. I haven't learned arrays or recursion yet. Am I following or close to best coding practices? A...
Last version of library (performance has been improved drastically since posting). I tried to implement the Quick Hull Algorithm for computing the convex hull of a finite set of D-dimensional points. Algorithm itself: #pragma once #include <boost/numeric/ublas/matrix.hpp> #include <boost/numeric/ublas/lu.hpp> #include...
I have a method in my controller (GetAllPatients/EnrollmentQueue) which does return the correct data (an array of ViewModels). I'm new in Knockout.js, so it's hard for me to understand how to display this data correctly. Here is my HTML: <table data-bind="visible: Patients().length > 0"> <thead> <tr> ...
This is a follow up post of my early question "Proper handling of exceptions in MVP" So based on the answers I re edited the post and now my exception handling code looks like this... DAL public bool InsertAccount(IBankAccount ba) { string insertStatement = @"IF NOT EXISTS (SELECT ac_no FROM BankAccount WHERE a...
The following example shows how to implement stack by creating user defined push() method for entering elements and pop() method for retrieving elements from the stack. public class MyStack { private int maxSize; private long[] stackArray; private int top; public MyStack(int s) { maxSize = s; stackArr...
I might have a potential memory leak with my custom control. Do I actually have one? public interface IAlertable : INotifyPropertyChanged { ... } public sealed class AlertButton : Button { private static readonly DependencyPropertyKey HasAlertPropertyKey = DependencyProperty.RegisterReadOnly("HasAlert", typeof(boo...
This code will retrieve all records from the database if the id is null or return records by the available id. Is there a way to combine the query instead of having two separate queries? // retrieve standard orders let retrieveStdOrders id = if id = null then query{ for row in tool.db.Order_O...
I have a method that returns a URL to send a user should they pass a login. My problem is two of these links are hard coded one of which is attempting to pass a variable to the model of that controller. My question is two fold: A. Is this safe B. Is there a better way to do this without hard-coding things like this? ...
I'm seeking a general review, but I'm particularly interested in style. This program gets 2 lists of peptide to spectrum matches, so every spectrum title is linked to a list of 1 or 10 possible peptides and this program checks for an occurrence on both lists. If they do occur on both lists, on what rank of 10 the pepti...
I have a World Cup fixture app where people can guess the results of the matches. Everything is working great, but each time I update the ranking, it takes 20 minutes for just 3000 users. So there must be something really wrong with this. These are the tables being used: Users CREATE TABLE `users` ( `id` int(11) unsi...
I'm extracting the version number from a file like this one. It works, but I find it clumsy and longer than probably needed. I'd also appreciate some sanity checks as long as they don't make the code noticeably longer (It's just a script, no full Java parser. Something similar to Guava's getOnlyElement would be nice). ...
Is this intrusive pointer implementation correct? I tried to use the CRTP Pattern to avoid a virtual destructor in my class ReferenceCounting which provides the reference counter. Is this efficient? The following things I could not solve yet: How can I make a conversion between IntrusionPtr<A> to IntrusionPtr<B> as l...
I'm looking for a better alternative to replace insert + gsub. hobbies = "Hobbies: \nsports (basketball, gym), foods (hamburger, steak, pasta), reading, movie, justfortesting((test1, test2), test3)" print "\n\nBefore: \n\n" + hobbies counter = 0 for i in 0...hobbies.length do case hobbies[i] when '('; counter +...
Recent JavaScript student here. I ran afoul of some weirdness with event listeners that led to my code being unresponsive. After some reading and tweaking, I arrived at a version that worked in JSFiddle, but not in the browser. I finally got it working in the browser, but now my code looks like this: window.onload = fu...
Do I still need to protect my code against SQL injection when I'm not using variables in SQL queries? Is this code still vulnerable?: $result = mysqli_query($connect,"SELECT subsubcat_name FROM subsubcategories WHERE subcat_ID = 4"); while ($row=mysqli_fetch_array($result)){ echo $row['subsubcat_name']; echo '<br>'; } ...
In a few weeks I need to give a workshop about JavaScript to colleagues. They do not have much experience with JavaScript so I will explain the basics of JavaScript. At the end of the day I want them to make a small game with the aspects learned during the day. I was thinking of Rock Paper Scissors. Below you can find ...
Following is a code snippet from MVP Win Forms application. My DAL doesn't handle exceptions and it will be propagated up to the calling method in the presenter classes where the exception will be handled. I'm using a single handler called ExecutAction(Action action) so I'm catching exceptions in one place rather than...
I made a function in jQuery for my home-made grid system. When a row has too many columns in it, it removes the HTML code from that row. Normally in my grid system it fits 12 columns in 1 row, but with the function this can easily be changed. One column with the size of 1 (declared as: column size-1) has a width of 1/1...
I have two byte arrays that represent unsigned 256-bit values and I want to multiply them resulting into a new value. What is the fastest ways to do this in Java? And are there other factors I should take into account? This is my current multiply-function: // two input values // i.e. each 0x0000000000000000000000000000...
Don't pay attention to the menu being awful above 789px. The "theoretical" task was to support only tablets and smartphones and I didn't bother to make the menu look fine on other devices. Just review it below 789px of VW. Here's a codepen to demonstrate. The page currently 100% matches the PSD designs and operates f...
I made a word counter. It works as long as there aren't any lone punctuation marks. How could it be improved? (Could it be made simpler? Are the comments detailed/clear enough? etc.) I know it's simple, but I don't want to develop bad habits early on. #prompt user to input a sentence toCount = raw_input("--- ") #funct...