instruction
stringlengths
71
71.9k
Idea The cache is nothing but a circular arrayList. This list contains Entry<K,V>. Whenever new entries are coming, add at the end of the list. That means least recently used element at the first. Suppose if you are reusing any element then unlink from the list and add at the end. In order to get any element, we need t...
I picked up Sass last week, and I'm already diving into expressions. I have a @mixin that creates a CSS border triangle using the following call: .foo:after { ... @include triangle(bottom,8px,7px,8px,#4986c8); } producing something like: Here's my @mixin: @mixin triangle($dir,$tl,$size,$br,$clr) { $a: solid transp...
I want to use a better syntax than nested foreach statements to overwrite the initial list with items from the second list. In the code below: I want to overwrite initialList with those in secondList that have the same Value (Remove Red). Use the items in secondList where Value was the same (Yellow) New initialList l...
I'm starting up a new project, and I've always had an issue getting vertical alignment right in CSS. Is there anything I could do better that what I've currently come up with? Replacing the header and nav with divs, and changing the rgba values to hex values this seems to work all the way back to IE7 which I'm happy wi...
I've got the following task: Keeping in mind Horner's Scheme, write an application that converts a given number x in n-number system to m-number system where m, n <= 10. x is a natural number or zero, x <= unsigned(-1) My code is as follows: #include <iostream> int toDecimal (int, int); int fromDecimal (int, int); i...
I recoded malloc() by using brk() and sbrk(). I just want some "reviews" to see if it is possible to improve my code to make it faster and better. If I'm doing some tests like "ls -Rla /" it takes a lot longer than the original ls, and if I do with "sh -c", it's way longer than the first one. malloc.c #include "../inc/...
I have this small "framework" for representing matrices with entries of primitive type double, and performing Gauss-Jordan elimination (for solving systems of linear equations). My main concern is cohesion of my code, but I would be glad to hear whatever comes to mind. GaussJordanElimination.java: package net.coderodde...
Around a year ago, I wrote this Stack Overflow answer where I suggested an idea to replace deeply nested loops with a single iterable virtual-container object that "contains" all the indices. The following is an implementation, but I'm still not that familiar with C++11 at the moment, so I thought I'd ask for a review....
I've written a cipher class based off of cryptographically secure hash functions and block cipher counter mode of operation. It currently runs around 20MB/s on my machine with the Java implementation of SHA256. The class is here as well as below. Any critique or input on the design or code? package blackdoor.crypto; i...
I'm hoping to figure out a faster way to write this before I resign myself to copying and pasting 500 times. I have code here that needs to do tons of vlookup matches. The only thing that changes are two variables each time. First part is just establishing variables and a count of the rows I need to loop through for ...
I wrote this script a while back to generate press releases. It consumes a csv of data where each row contains the data for a country and fills in values in pre-written text based on the data. In its current state, it's basically a mad libs implementation with some hard coded conditionals. I'd like to refactor it to ma...
I'm trying to get the URL of the browser with Mac OS X app. I wrote some AppleScript and am trying to use it in Cocoa. The problem is, when I watch it with instruments, memory is increasing, and at the end of 3-4 hours it's nearly 20MB. First generation Second generation (5 min. later) #import "AppDelegate.h" #imp...
I have multiple threads calling a method, passing in an ID and value. I have two constraints I need to place on this method: Only one of the same ID can be processed at a time. Additional threads with the same ID must wait. Subsequent calls with the same ID must be processed in the order they were received. Here's an...
I've thrown together a utility for my programs to log to a database, but the code looks like a mess and I don't know how to clean it up. This library is going to be used from all of my other programs and it is therefore important to keep the code clean and secure. #include <log_entry.h> #include <my_global.h> #include...
I would like to create a generic template class for my document processor. Assuming the template has a source file path and a "content", here's what I came up with: Template public interface ITemplate<T> { /// <summary> /// The filepath of the base document for the template. /// </summary> String BaseDo...
Examples: 12 gives: 'AB' and 'L' and 123 gives 'ABC', 'LC' and 'AW' Here is my attempt: import java.util.*; public class decoding { static int calls = 0; static Map<Integer, String> codes = new HashMap<Integer, String>(); private static void construct(){ codes.put(1, "A"); codes.put(2, "B"); codes.put(3, "C...
I have multiple API calls so I created a service however I would like to find a way to remove the duplication myAppServices.factory('apiService', function ($http, $q) { return { getDocuments: function () { return $http.get('/api/autodeskdocuments/1') .then(function (response) { ...
Trying to implement a simple, thread-safe LRU cache that's meant for "read mostly" use. Collections.sychronizedMap() Clean, simple, not much else to say. public class LRUConcurrentCache<K,V> { private final Map<K,V> cache; private final int maxEntries; public LRUConcurrentCache( int maxEntries ...
A simple command that wraps another command, locking a file first. It is similar to flock, just simpler. #include <stddef.h> #include <stdio.h> #include <unistd.h> #include <sys/file.h> #include <err.h> #include <stdlib.h> void attemptLock(const char *lockFileName) { int fd = open(lockFileName, O_CREAT | O_WRONLY,...
For my Operating Systems class, I needed a linked list data structure and didn't have one already written. During the course of thinking about how to implement a linked list again (it had been a while..), I decided that a lot of the most common functions used on linked lists can be implemented based on applying or comp...
Let's assume I have an enum type with currency: public enum CurrencyType { USD("American Dollar", "USD"), EUR("Euro", "EUR"), JPY("Japan Yen", "JPY"); private final String fullName; private final String shortName; // enum valirables can change in the future, so I do not use Currency.name() pr...
I've made some CAPTCHA reader and maker in Python using Tkinter. Do you know if it's possible to keep image and output files in "memory" not writing them on disc? Because right now everything is 'stiffly' made. And what would you do differently? gui.py import tkinter as tk from PIL import Image, ImageTk import captcha...
I'm trying to make a good MVC model using annotations, which I will use it in a large scale GUI project. I want to respect the maximum of rules and guidelines, and be able to decorrelate every parts of the MVC. The code must be beautiful, testable and maintainable. I wrote a sample project to show you my model. What do...
I've build a handlebars helper that takes n total pages and currentPage and returns the HTML for the page number links, skipping out pages far away from the current page to avoid it being too big. I feel like there are a lot of if statements in there and it could be a bit more compact. 'use strict'; var config = requ...
In a project I've started, I decided to implement some new code to handle AJAX requests. The requirements are that it can ONLY access the /ajax/ folder, load translations from another folder (/lang/) and that you MUST be authentificated previously. This code is currently in use in a CMS. Here is the ajax.php file (plac...
I am getting better with jquery day by day, but there are still things I don't know how to sum up several functions to reduce some code. So I am using three jquery modal dialog popups and I have written a lot of code to make them all work fine. However, I believe it should somehow be possible to reduce all the code int...
I have implemented a max-Heap data structure backed by an array. I wanted to know whether this is an acceptable implementation or not. Any improvements or suggestions are welcome. import java.util.Arrays; import java.util.NoSuchElementException; public class MaxHeapDemo { int heap[],heapSize=0; public MaxHeapDemo(...
I have a table in my database containing email and email_state amongst other values. Email is the email of the contact, and email_state is the existence of the email. It can contains 3 values: null (not checked), EXISTS or NOTEXISTS. When the application (a PlayFramework Java application) starts, I call the start() met...
I am pretty new to Swift, as a solo developer I was wondering if somebody could pass comments on the singleton implementation below. The code does work, but being new to Swift and knowing that there are a lot of gotchas, I wanted to get some feedback from someone more experienced. // Test Singleton Swift 1.2 class FGSi...
This is a follow-on qestion from: LRU cache design Revised Implementation package lrucache; import java.util.LinkedHashMap; public class LRUCacheV2<K, V> extends LinkedHashMap<K, V>{ private static final int MAX_ENTRIES = 3; /** * super class constructor arguments are * cache size = MAX_ENTRI...
Using Python Scipy, I am trying to divide all numbers in all columns of a sparse matrix (400K × 500K, density 0.0005), by the sum of the squares of all numbers in a column. If a column is [ [ 0 ] , [ 2 ] , [ 4 ] ], the sum of the squares is 20, so after computation the column should be [ [ 0 ] , [ 0.1 ] , [ 0.2 ] ]. T...
This is an implementation of heapsort as seen on Programming Pearls, adapted for java List collections. It is working on a copy of the list passed-in on purpose at the moment. import java.util.ArrayList; import java.util.List; public final class HeapSort { private HeapSort() {} public static <T extends Compa...
Given a slice of unknown length (potentially very small or very large), and another slice containing (unique) integers indicating indices to be removed from that slice, the most straight forward way to achieve this would be to sort the indices in reverse order then remove each of them from the slice in turn via: mySlic...
Earlier, I've posted a question about a file used to handle AJAX requests. I've followed some of the advices given and made some changes on the code itself. You can go on "All-purposes AJAX handler made with PHP and .htaccess that speaks JSON" to read more information about it's working. This is simply a follow-up, and...
I am starting to learn Haskell, so I coded a naive solution to the primality test and summation of primes (Project Euler Problem 10: sum of all primes under 2 million) . As I have an imperative programming background, can you tell me if my code is functional enough? isqrt :: Int -> Int isqrt n = floor(...
I've completed the application and it works against all tests I've thrown at it. Now, I'd like to see if there's a way I can optimise the application and lower the code footprint. The application is intended to be used for collecting input and collating this into an email, to be used later. All variables are pulled fro...
I have 2 buttons for Terms and Conditions in my project, that I need to implement in multiple activities. I created the following class: public class TermsAndConditionsView extends LinearLayout implements View.OnClickListener { private Context context; public TermsAndConditionsView(Context context) { s...
I've been playing around with the code challenges on projecteuler.net. A few of them involve prime numbers, so I've created a function to find them based on the sieve of Eratosthenes. It works fine, and is reasonably quick for small numbers, but much slower for the challenges that involve the larger numbers, like 2mil...
I have +-645 IRL links I need to validate. The code below is my attempt, but my problem is that it takes forever to check all links and sometimes times out. Is there a better way of validating so many links? index.php <?php error_reporting(E_ALL); ini_set('display_errors', 1); $notValid = []; // This array contains...
I have a dictionary whose values may contain keys that are already in the dictionary. What we are actually talking about are parameters. Sometimes a parameter is defined by a number plus another parameter, etc. It looks something like this: paramDict = {'ad': '2*dmcg/factor*(xw/factor)', 'dmcg': 2.05e-07, 'dxwn_3vna': ...
I've been working on a TicTacToe GUI. While the game works with a proper restart, exit and win conditions; I feel that it could still be better optimized. I'm not particularly concerned with the cosmetics of the GUI. I'm aware of how to make an interface "pretty", so to speak. I would just like to know if there was a b...
I'm new to programming and want to check if I'm using best coding practices in my program. package scott.TicTacToe.main; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JOptionPane; public c...
This is a very subjective question, but I'm curious as to other people's opinions. Would you find this bit of code distasteful? Is it cryptic and unreadable, or is it using features of the language in an elegant way? def winning_side(home_goals, away_goals): """Takes a home score and an away score, and returns the ...
In my JavaScript quiz, I have two functions below which are not DRY. What i want to do is to cut it, so everything below var = text would be used only once not twice. My concept is to enclose these two functions in bigger function (e.g. guess()) and keep the trimmed correctGuess() and incorrectGuess() within it. Now he...
Need help with DRYing out my Sass... there is just so much repetition in here: .cta_foo { @include linear-gradient(#f69c28,#b75d00,#b75d00); text-shadow: -1px -1px 0 #b85e00; &:hover { @include linear-gradient(#FFAC41,#E77500,#E77500); } } .cta_bar { @include linear-gradient(#17b629,#0e831c,#0e831c); te...
A function that relatively quick replaces one color with another, in a memory-buffered BMP. I am trying to improve the performance as much as it is possible. The previous implementation of this function was even faster.. but then I ran into some padding complications. union { unsigned long ulColor; unsigned cha...
I have an application that looks like such: var app = angular.module('app', []); app.Person = function(firstName, lastName) { this.firstName = firstName; this.lastName = lastName; } app.controller = function('myController', function($scope) { $scope.pageData = []; $scope.pageData.firstName = ['John']...
How do I condense this gigantic monster into something more manageable? I heard about command pattern but I can't figure out how to use it. What other solutions are there? public void AI(){ count++; if(count % 2 == 0){ letter = "O"; } if(((buttons[1].getText().equals("X") && buttons[2].getText...
I'm trying to figure out the most elegant solution to do the following asynchronously using JavaScript (specifically node): Given a destination file name, check if it is a directory If it is a directory, delete it Copy a source file onto the destination file name I would like to do this asynchronously using callbacks...
Here's a perhaps naive but simple implementation of Radix sort in Java. It works with any radix, and both positive and negative numbers. import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.List; public class RadixSortWithDivision { public static final int DEFAULT_RAD...
I've moved my main() to the bottom of the code block in order to fit it all in one class for this submission. Is there a better way to do it? import java.util.ArrayList; import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Created by Travis on 2/2/2015. */ public class Com...
Just coded up a simple Stack using an Array in Java for practice. Other than the lack of JavaDoc (still need to learn that part), did I cover all the bases? import java.util.Iterator; public class ArrayStack<T> implements Iterable<T> { private T[] stack; private int top = 0; //Position of the top of the stack...
This is a Tic Tac Toe game with a "new game" button. I'm after a general review of the code with some tips on how to make it simpler and tidier. GitHub HoboChess.java package sample; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.fxml.Initializable; import jav...
Here is my function which convert linked list in the following order: Example: Inputs: 1->2->3->4->5->6->7->8->NULL and k = 3 Output: 3->2->1->6->5->4->8->7->NULL. void SingleList::orderSort3() { // If linked list is empty or there is only one node or two nodes in list if(getHead() == NULL || getHead()->getNext...
I'm trying to write code to solve water pouring problem in Clojure. The following code is strongly influenced by Martin Odersky's solution lectured in his coursera course, Functional Programming Principle in Scala. He first created a class Pouring with parameter capacity, which is accessible everywhere in the class. Th...
I've put some code together that helps me search an internal ticket system using an HTA application with some TextBoxes and some embedded VBScript that runs PowerShell scripts. The PowerShell scripts are hard coded to a certain directory and I was wondering if there's a better way to accomplish this task/goal. I real...
I coded up a basic DLL for use in a stack or a queue in JavaScript for practice. Coming from a C++/Java background, I basically just converted how I would code it up in one of those. I'm not sure if there's a more JavaScript optimized way of doing it. function Node(val) { this.data = val; this.prev = null; ...
I am working on an HTML / JavaScript listings template for online auctions. There are two sets of tabbed navigation features in the listing that are driven by JavaScript as well as a dynamic image gallery. Everything appears to be functioning very nicely. The template is fiddled here. (complete project repository here...
I'm having some difficulty with servlet and filter lifecycles. The intention here is to use the front controller pattern with a simple login; authentication is accomplished with the filter. Am I passing the auth token in a rational way? The login.jsp page: <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCT...
The active column in the database only contains a boolean. The country column contains ISO 3166 A2 codes (2 char). Do you have any advice on improving this class? <?php class WebShops { private $database; public function __construct() { $this->database = new Database(); } public function ...
I wrote a PHP script and was wondering if it was well written or if it could be improved upon to read or run more efficiently, any help or critique would be greatly appreciated. The file will be placed in cron jobs and run every 15 minutes. The goal is that it will take new customers from a remote MySQL database and ad...
I really appreciate the way filtering is applied to queries in Django. I have a list of items (each item is an Item instance which contains a few attributes) that I would like to provide a similar API for filtering. For reference, the Item class contains the following attributes: Name Description Price Stock Current...
Basically my code piece is a sitemap crawler - it opens sitemap, that contains sub-sitemap listings from - to a datespan. It opens sub-sitemap and gets all the URLs (most of them are seourl's, but not all). As sub-sitemap is enumerated all of it's put in list called list2. Code overview is like: var dict = list2.ToDic...
I've finally written my first loop in SCSS, trying to avoid it for quite some time since I thought it was unnecessary (was writing vanilla CSS not so long ago, so I was used to manual work). However, I feel this code isn't very optimized, especially since I seem to need two different while-loops (one for divs from cent...
The task is to create a DataTable with 1 column + header and 7 rows with content. The content will never change Implementation: private DataTable createTable() { var table = new DataTable(); table.Columns.Add(new DataColumn("Wochentage", typeof(string)));// Wochentage=> WeekDays createR...
I have an HTLP template file called "template.tmpl". In the template I have a few placeholders like {{NAME}} and {{USERNAME}}. I am then loading the template file into a variable called $template using file_get_contents. I then put the $template variable through a function which deals with replacing a series of placeho...
I have a WPF application, in which I'd like to bind a collection to a combobox using an asynchronous method : <ComboBox Margin="2,0,5,0" Width="178" ItemsSource="{Binding Animateur}" DisplayMemberPath="nom" SelectedIndex="0" /> the viewmodel class _service.GetAnimateur((item, error) => { ...
#include <iostream> #include <conio.h> #include <windows.h> #include <math.h> using namespace std; #define RUNS 1000 char z[100000]; int i,j,k,c; void main(void) { DWORD starttime,endtime; float totaltime; starttime = GetTickCount();//get start time for(k=...
I have stored in a XML file some Travel packages, each package has a code( the codes are stored in an array = $code). I am using the below code to pull the requested data from the XML based on the given code. At this time I have copy/paste the code for each given code, but I have lots more and I dont want to copy paste...
I've created this class, for flashing variables like validation errors or success messages. But I'm not certainly sure about it. <?php namespace Basalt\Http; class Flash { const MESSAGE_PREFIX = 'flash_'; /** * Return flashed message. * * @param string $name Flash message name. * @param b...
I have a function below that does the following uses a bunch of smaller CRUD operations which I call create, retrieve (instead of read), update, delete. Because this function does a bit of everything it can be hard to name it. Here's a bit about its behavior: pass in array of redirects (objects with url, and path prop...
I have the following code at the moment: public void initialiseButtons() { this.saveNewButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { savePatientData(actionEvent); } }); this.clearFieldsButton.setOnAction(new E...
I've been learning Java Database Programming for like 2 days, I read theory at first. Now decided to get stuck in. I just wanted a few pointers. I am using JavaDB (Netbeans Service) should I be using something better? As I've read it has some security flaws. I split one class to two (as you'll see below), is what I'v...
I have code that take in a URL (via URL or String) and returns the status code. I am new to web development, so it is very possible that I may be taking a poor approach at this. One thing I don't like about my code is the need for the InetSocketAddress to be hardcoded, but I have not been able to find a way around th...
AllPermutedPacks<Pack<Types...>>::type is to be the pack of packs consisting of all permutations of Types.... For example, AllPermutedPacks<Pack<int, char, double>>::type is to be: Pack<Pack<int, char, double>, Pack<int, double, char>, Pack<char, int, double>, Pack<char, double, int>, Pack<double, int, char>, Pack<dou...
I have decided to make small ObjectPool class for internal use. What do you think about it ? template<class T> class ObjectPool { public: inline T& getObject(); inline void releaseObject(T& obj); private: std::stack<std::reference_wrapper<T>> mFree; std::vector<T> mPool; }; template<class T> void Objec...
What I'm trying to do is to change the background color when a link is clicked (in this case a list item). When it is no longer clicked, it should revert back to its normal color. I was able to get this to work via the jQuery addClass and removeClass methods, but this seems to be hardcoding it. jsFiddle $(document).rea...
Does this look good for combining/retrieving two 32 bit integers (a type and an index) into/from an unsigned 64 bit integer (a unique ID)? The point is to hide in the API the composition of the unique ID and allow its calculation to change later without changing the API (e.g. possibility to change later to consecutive ...
Below is the problem: Show that both summation and product are instances of a more general function, called accumulate, with the following signature: def accumulate(combiner, start, n, term): """Return the result of combining the first n terms in a sequence.""" "*** YOUR CODE HERE ***" Accumulate takes as arg...
I have written this method which calculates the range (max - min) of an ArrayList. I have two for loops each for a different ArrayList. The for loops do exactly the same thing except they each use a different list, so I was wondering if there was a way to just use one for loop (or any other way) that does the work but ...
I have just typed out very long code in Excel that just repeats itself 17 times, but each time with different cell references. Is there a more concise way of writing my code, perhaps by using another column of cells? The code that is repeated is: =IF(OR(ISBLANK(X2),ISBLANK(Y2)),0,X2/VLOOKUP(YEAR(Y2),$EU$3:$FH$57,14,FAL...
I mainly develop in PHP and every now and again I have to do stuff in JavaScript which I'm not really comfortable, so I would like a review of how I can improve my code and knowledge. This script takes data coming from JSON, does some basic checking on the data fro format and things like that and then displays the data...
Is there any way to improve this kind of code? I have converted this from production code for privacy reasons, so there might be some mistakes. public class AddNewUserDto { public bool IsAdmin { get; set; } public bool IsRead { get; set; } public bool IsWrite { get; set; } public string[] GetRolesByD...
My special case: home project, automatic downloader for podcasts. Overall algorithm is: Download a list of available podcasts hash the podcasts load metadata + hash of downloaded podcasts from sqlite db Algorithm this questions is about - throw out all already downloaded. Download new podcasts save metadata to sqlite...
I am reading the "Clean Code" book and trying refactoring my source code according to the principles "single level of abstraction"/"separation of concerns". How would you refactor the following code? I am interested in the details like: How would you separate the abstraction levels? How many classes would you create? ...
I have two tables (parent-child model): Loans & Transactions. Each Loan row has multiple Transaction rows. I want to select all rows from Loans together with most recent row from Transactions. Here is my select to achieve this. SELECT L.*, T.* FROM Loans L CROSS APPLY ( SELECT TOP 1 * FROM Transactions AS T ...
I tried to make this clone of brick_breaker on my own in one day. The source code and assets . However I have some concerns about the code so far: It uses simple edge detection code (as if ball goes out of screen <600 or <462). It uses built-in collision detection from pygame. Simple array for appending blocks. impor...
I am a beginner in JavaScript and starting to understand jQuery. I've written a toolbar that uses jQuery. I've also put comments based on what I understand of how the code works, though through the help of the book, it helps. But I would really appreciate if someone can review the code as well as the comments, so that ...
I'm learning C with K&R 2nd Ed. I've just completed the exercise 1-20 and I would know if my code is correct (i.e. answering the question) and if my style is not too bad. Or just some feebacks to improve myself! K&R Exercise 1-20 p.34 Write a program detab that replaces tabs in the input with the proper number * of b...
I'm still in the process of learning Python and am doing some of the Project Euler problems. I have made a factorisation algorithm that works; however, it runs really slowly, and I'm not too well-versed on coding for performance. If someone could give me some pointers on how to improve the algorithm's efficiency it wou...
While doing a little project involving sniffing packets, I found myself programming a cross platform network to host byte order and host to network byte order, this is my first time developing a project using networking. ntboc.h #ifndef NTBOC_H_INCLUDED #define NTBOC_H_INCLUDED #define LITTLE_EDIAN 1 #define BIG_ED...
I'm implementing a live search in a Chrome app (no cross-browser magic required), and have separated the search functionality out into its own module. I want the user to be able to enter multiple search terms by pressing the / key. Eventually I'll style it so it looks like a single text box, but when the user presses t...
I'm working on a Python application where I read and extract data from an HTML file. The data is stored in a list, and the number of items in a list is, on average, 50,000+. The items from the list are added to a database. I cannot allow duplicate datetime values in one of the columns, and so, I have to check if a spe...
Here is the story. We have the BankTerminalSettings class. It has many properties: public class BankTerminalSettings { public bool IsEnabled { get; set; } public string IPAddress {get; set;} public ushort TcpPort {get; set; } public List<string> Zombies {get; set;} //and many other properties } A...
I have encountered the following problem that I found very interesting to solve: Given an array of positive integers {a1, a2, ..., an} you are required to partition the array into 3 blocks/partitions such that the maximum of sums of integers in each partition is the minimum it can be. Restriction: you cannot alt...
The objective is to remove extra spaces from the below string: " Today it is going to rain. " so it looks like below "Today it is going to rain." Please determine if the code will perform well and if there is a better solution (NO REGEX or LAMBDA). static string CompactStringPerfect() { strin...
I've started to write a Generalized Suffix Tree implementation. The overall code is still in an experimental state, though I think it's mature enough to ask for a little review. I'd like to know how I can make it better, especially on the use of the standard library, the consistency of the code and the design. A quick ...
I'm investigating using prototypes in JavaScript to simulate using 'base classes' which can be 'extended'. I've created an example where dialogBox is my 'base' and welcomeMessage is the 'extension'. // OBJECT CONSTRUCTORS var dialogBox = function(xPosition, yPosition, width, height){ this.x = xPosition; this.y...
I am currently working on a crash log sender. As the application crashes, the FindLogFiles() will search for the different crash logs we are maintaining. It will then process these files, check their size and send them to the server in fused, or split chunks of max 500k bytes (receive limit per file from the server we ...
How should this code be improved? For instance: How could it be shorter, clearer, deal with memory better, use a plugin/library, better prepared for web input? I can break up and clarify the regex or jump calculation, but what is the simplest way? Why don't I see setTimeout cleared in if blocks more or default return ...