instruction
stringlengths
71
71.9k
I'm using OpenGL to draw about 20 circles. Each circle has 2 lines, ~10 segments, and all of them have different colors and lengths. Frames per Second are around 4. How can I optimize this to run faster, with higher frame-rates? I am using Python 3 on Ubuntu. class ScreenOpenGL(Screen): def __init__(self,layers,layers_...
In a new project I am creating for my work, I am creating a fairly large ASP.NET web API. The API will be in a separate Visual Studio solution that also contains all of my business logic, database interactions, and Model classes. In the test application I am creating (which is ASP.NET MVC4), I want to be able to hit an...
I am brand new to dictionaries and coding and am hoping to get some suggestions on how I should structure my dictionary. I have a collector number which has meters connected to them. Each of the meters have a meter number and a ert number and would like to store both the meter and ert number. There will be a list of ...
I'm working on a piece of code for calculating all the possible combinations of numbers that sum to n. For example: sum_combination(3) = [ [1,1,1], [1,2], [3] ] So my ruby code is this: class Integer SUM_COMBINATION = { 1 => [[1]], 2 => [[1,1],[2]], 3 => [[1,1,1],[1,2],[3]] } def sum_combinati...
I've got this method, and it's quite a big method. I look at it, and I feel... dirty. I feel that it's doing too much, and that there might be a better way to accomplish what I'm trying to. /// <summary> /// Calculates daily project drilling hours /// </summary> /// <param name="daily">Bool: True for daily, false for t...
Thanks for looking it over. I'm still pretty new to programming. I thought this would be a good exercise in addition to making the Project Euler fraction problems easier import java.math.BigInteger; final class BigFraction extends Number{ private BigInteger numerator; private BigInteger denominator; publ...
I have read some articles discussing about why static is bad, some of them refering static as not-testable, non-mockable, has state (non-stateless) and everything else. However I have encountered some cases where I am forced to use static implementation, such as: During using HttpContext.Current in Asp.Net, as well as...
I have the following CRC 16 code. Is it possible to improve the performance of the code with unsafe constructs? My knowledge about pointer arithmetic is rather limited. public enum Crc16Mode : ushort { Standard = 0xA001, CcittKermit = 0x8408 } public class Crc16Ccitt { static ushort[] table = new ushort[256]; ...
I have to create a modularized program that can find out the diameter, circumference, and area of a circle's radius. I'm sure many of you can notice I kind of winged this from a example given from my teacher. Instead of people pointing out the fact that I coded this wrong, could you please give me reasons for what I sh...
I'm using the following pattern to pool D3D objects globally in my application. Is it a good idea (alternatives)? Is it thread-safe? CComPtr<ID3D11Texture2D> create_texture(const D3D11_TEXTURE2D_DESC& desc) { static concurrent_unordered_map<D3D11_TEXTURE2D_DESC, concurrenct_vect...
I have written the below code which generates all possible permutations with repetitions of a string. I want to make this program shorter and much faster, but I don't know how to do that. Imports System.Text Public Class Form1 Private blkRpt As Integer Private perm As Double Private Sub Button1_Click(ByV...
I have several calculus to do in my ruby app. My code is currently working but I find it very ugly. @guestreviews = GuestReview.where(:reviewed_id => @user.id) @hostreviews = HostReview.where(:reviewed_id => @user.id) @hospitalityrate = 0 @foodrate = 0 @placerate = 0 @hostreviews.try(:each) do | rate | @hospitalityra...
/** * takes a list of componentIDs to load, relative to componentRoot * returns a promise to the map of (ComponentID -> componentCfg) */ function asyncLoadComponents (componentRoot, components) { var componentCfgs = {}; function asyncLoadComponentCfg(component) { var url = _.sprintf("%s/%s", compon...
Could this be better factored as a reduce? /** * recursively build a nested Backbone.Model or Backbone.Collection * from a deep JSON structure. * * undefined for regex values */ exports.modelify = function modelify (data) { if (_.isArray(data)) { return new Backbone.Collection(_.map(data, modelify)); ...
I wonder if someone could give me some pointers to my PHPmailer Process file and see if they find any misstakes or things that I have missed in the validation/sanitation of the data. Any input would be most wellcome! <?php //includes require_once('func/mail/mailcon/config-info.php'); require_once('include/class.phpmai...
I'm trying to teach myself javascript and HTML5, (just beginning), and for some practice with canvas I am trying to turn this chart into an interactive chart on canvas, whereby clicking on a word opens up some of the tree below, and so on. I can't post images of what it does as I'm too new here, sorry. The thing is, th...
How can I improve this code? Also available from git://github.com/edescourtis/actor.git . Actor.java package com.benbria.actor; public interface Actor<T> extends Runnable { public abstract void send(T msg) throws InterruptedException; public abstract void stop() throws InterruptedException; } ActorListener.j...
I wrote a small ducktaped VBA script which pings servers every 15 mins or so. If a server's status is anything other than "Alive", the server and timestamp is written to another worksheet called "Log". Sub Countup() Dim CountDown As Date CountDown = Now + TimeValue("00:00:01") Application.OnTime CountDown...
I have a C# program that I would like to have reviewed. I am new to programming and want to know how it could be improved. It is a Windows Forms project that generates a PDF using the iTextSharp dll. I have tried to leave off the repetitive parts (multiple textboxes, etc) as well as the part that uses iTextSharp. na...
I have written an algorithm to find the largest palindrome under a given number, but I am sure my code loses efficiency by creating new arrays in every pass. I am currently learning about efficiency so I have the following question: Can anyone suggest a more efficient (faster) approach and explain why this approach is ...
This is my first attempt with a basic text adventure game, and I was wondering if there was a way to make it more efficient (or any other things I could add to make the game better). It isn't totally finished yet, but if there is a way to make it better, please post in the comments. #lets me use the exit function impo...
**Note: I might put this on Code Golf too, but first I'd like to get this code reviewed. So there's this programming contest my school will be holding soon, which is about solving problems in the shortest (writing) time possible. I want to participate, but I discovered that I suck with puzzles. So today I begun doing a...
I'm currently working my way through the questions on Project Euler and I am on question 5. Is this the best possible solution? Any suggestions welcomed! List<int> divisors = new List<int>{ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; int n = 1; while (true) { n++; ...
The requirements: Work inside .htaccess (preferably via mod_rewrite) Redirect requests from /any/directory/index.php to /any/directory/ Make sure that /index.php-with-stupid-stuff-here does not get rewritten Add trailing slash to directories, /another/directory becomes /another/directory/ Also note that: The ideal s...
I've coded following two methods to combine images that are HTTP POSTed to the server: // Crops two squares out of two separate images // And then combines them into single image that's returned as byte[] private byte[] combineImages(HttpPostedFileBase[] itemPayload) { try { using (var ms = new MemorySt...
Sometimes, I need to read two integer parameters in a single input line, separated by a whitespace. I have these two functions that seem to do the job just fine: #include <iostream> #include <sstream> #include <deque> // Splits a string by its whitespaces and returns a deque with each item. deque<string> split(string ...
I made a reference-counting smart pointer class. My aim is to make a "minimal" but "general purpose" smart pointer class with proper documentation. This is basically for educational purposes. I would like to have comments regarding exception handling, code clarity, comments, ease of use of API, etc. And, also comment i...
I'm implementing a simple iterator in C# over an xml document, in order to process an xml document in as much a streaming manner as possible. For this reason, I'm using an XmlReader variable in a while loop. This iterator must either return each first-level child elements, depending upon the name of the root tag. Other...
I've been writing a node.js web crawler, to get it running, I've found myself having to string together really rather a lot of different NPM modules. I've done my best to keep the code DRY and well designed, but unfortunately, it's turned into a bit of a tangled mess, and in places I feel like I'm forced to use global ...
I wrote the following to create an animation which collapses a navigation bar, load new content for it and expands it again. Meanwhile, the rest of the page content fades out, loads and fades in again. It works and looks good, and is even timed well. But my code is one hell of a mess. How could I have done better? $(fu...
I have been attempting the questions at Project Euler and I am trying to find the sum of Primes under two million (question 10) The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. Here is my attempt which does work, but I would like to know if there is any way to im...
This is one of the slightly trickier Project Euler Questions I have seen (Question 27) Considering quadratics of the form: n² + an + b, where |a| < 1000 and |b| < 1000 where |n| is the modulus/absolute value of n e.g. |11| = 11 and |−4| = 4 Find the product of the coefficients, a and b, for the quadratic expression ...
I'm totally hooked on CodeEval, and one of the problems on there caught my attention. Here it is, copied from here: Challenge Description: Flavius Josephus was a famous Jewish historian of the first century, at the time of the destruction of the Second Temple. According to legend, during the Jewish-Roman war he was tra...
I've developed my own class in ASP.NET project to access MySQL and make queries and scalars, and read the results from it. I want you to review my class and tell me where I've made a mistake. Here are some questions that are important for me: Do I use a reference correctly for the connector class of MySQL in methods? ...
I am trying to get a tuple of date (or datetime) objects over the last N months. My thought was to use the dateutil package with something like this: def last_n_months(n=12, ending=None): """Return a list of tuples of the first/last day of the month for the last N months """ from datetime import dat...
I have a selector that pulls in all anchor tags that start with the # symbol. I am trying to add a :not selector of some form for elements that have a data attribute. I know I could do the following... $('a[href^="#"]:not([data-known])') But the problem is that I don't know what the data attribute will be called. I ha...
I need to add quotes to each word in a string. Here is something that works but it looks ugly to me; "this is a test".split.to_s.delete("[],") produces "\"this\" \"is\" \"a\" \"test\"" split adds the quotes, to_s turns the array back to a string, then the delete removes the array stuff. The downside is the case wh...
I wanted to store some dictionary data (key/value pairs of strings) in C, and decided to use a trie. I found what looks like a good implementation here, along with some nice notes. In this implementation, each node in the trie is a trie itself. Each node has next, prev, child, and parent properties, pointing to other n...
It would be a huge help if you could tell me ways to make my code run smoother and if I could add more code to my program to make my program more unique. Panelball class: import java.awt.*; import java.awt.event.KeyEvent; import javax.swing.*; public class Panelball extends JPanel implements Runnable { private...
I have a repository abstract class that encapsulates pretty much all of the CRUD functionality: public abstract class DataRepository<T> : IRepository<T> where T : class { public DataContext Context { get; private set; } public TransactionScope Transaction { get; private set; } /// <summary> /// A <see ...
I'm working on an algorithm to solve the 24-challenge game. The basic idea is to combine positive integers using arithmetic operators to produce an expression that evaluates to exactly 24. For instance, (9 - 3) * (2 + 2) = 24. My current implementation is functional (delivers responses in less than 15 seconds) with sev...
I have created a proof of concept jQuery based flow diagram based upon kayen's answer to this post. This diagram shows the flow diagram that I am seeking to create in jQuery: I also wanted to make the UI as clean as possible, so I have set it that only the current question is displayed as the users works their way thr...
My definition of monkey testing is basically playing with a program in as if I was a monkey (press every button, unplug things, go in the wrong order..etc etc) So I made a rather simple SmartCard library that when I "enable" it it just polls the smart card reader for a card, and reports back information. see code priva...
I'm writing a multithreaded game engine, and I'm wondering about best practices around waiting for threads. It occurs to me that there could be much better options out there than what I've implemented, so I'm wondering what you think. wait() method gets called at the top of every other method in the class. This is my ...
I am using a recursive algorithm to find all of the file-paths in a given directory: it returns a dictionary like this: {'Tkinter.py': 'C:\Python27\Lib\lib-tk\Tkinter.py', ...}. I am using this in a script to open modules by solely given the name. Currently, the whole process (for everything in sys.path) takes about 9 ...
I am working on an application that will use an N-Tiered approach. I would appreciate any feedback and advice on my architecture before I proceed any further. DataLayer (Class Library Project) Context.cs namespace TimeTracker.DataLayer { public class Context : DbContext { public Context() : base("Data"...
I want to see if one of two values (a, b) are in an array. Here's my current thought: $match_array = array('a','b'); $array_under_test = array('b', 'd', 'f'); if (array_intersect($match_array, $array_under_test)) { // Success! } Any better implementations?
I have a list of plans and a list of contacts, and I have to check whether contact.ProviderId matches plan.ProviderId. If they match I need to store in a contactUI the plan.Name. Provider to plan is a 0..1-to-many relationship, and that's why I couldn't use the Dictionary I tried at first instance. For retrieving the l...
I had a code for a layout library which looked like : $this->layout->setLayout($layout)->setTitle($title)->render() etc. Today I started writing a new code, simpler and smaller : $this->layout->data(array( 'view_name' => 'layout_admin', 'title' => 'Administration', 'js' => 'admin/mat...
Introduction I'm learning C++ (Coming from Haskell, C, and Assembly - and other languages sparsely) and this was my practice with classes and templates. It's a linked list that you can call in this fashion: #include "list.hpp" int main(void){ linked_list<char> test; char c; while(c != '\n') // test.pr...
The Art and Science of Java, a course book that uses the ACM library, has an exercise that reads like this: Implement a new class called Card that includes the following entries: • Named constants for the four suits (CLUBS, DIAMONDS, HEARTS, SPADES) and the four ranks that are traditionally represented in words (ACE...
I have this code and would like to have it reviewed: function thisClient() { "use strict" var self = this var width = 960, height = 500, centered, data this.init = function () { //now.receiveLocation = function(message) { // console.log(message) // // FIXME only push markers ...
I've written a simple numeric menu which displays in the console. When the user types in '1', something happens. When the user hits ENTER, I clear the whole output except for the menu itself. When the user types in '5', the program ends. However, the code got ugly. It's full of cin.get()s, couts, and other stuff. int ...
This is my first COBOL program, and I'd like to get a critique as I am unfamiliar with best practices. Particularly, I'd like to know how to get the input and output to be more elegant and less dependent on how the file fields are structured. Some type of analogy to C's scanf(), getch(), or any of the Java console IO r...
I have a block of code that pulls the current menu position and compares it to what users selected, if the selection is different the database is updated with the new selection. As I am still new with EF I was hoping for a general code review for suggestions on a possible better, more efficient, and/or easier way to co...
I just finished a program that is a simple Swing GUI. It takes in user info, such as password and username, turns them into strings, and puts them in a text file called nuserInfo.txt. I just want corrections on how the code works and what I can do to improve my saving, GUI, and code in general. I'll post all the code b...
Which version is more efficient in calculating the square root ? There are 2 versions I have written to calculate square root programatically. Note reqs strictly state not using library functions ? This is puzzling, the first method takes one extra iteration over the 2nd one but returns the more accurate answer of 3....
I want to move this to a class that will open an sqlite connection that can be re-used, rather than disposing of it every time I write to the database. Furthermore I am more than happy for any best practices from sqlite users! I am aware of a similar thread and am trying to absorb it: SQLite helper class void createDB(...
The code below is equivalent. I can see pros and cons for both versions. Which is better: the short, clever way, or the long, ctrl+c way? Short version: character.on("key",function(key){ var action = ({ "a":{axis:"x",direction:-1}, "d":{axis:"x",direction:1}, "w":{axis:"y",direct...
I would like to re-write this C# code so it is easier to understand. Should I create a separate function to configure a menu item? Is there is some kind of using statement so I only need to mention the menu name once? private void initializeContextMenuRightClick() { try { ctxMenuStripRig...
I've found a good example of how to do this in Java and how you can get the same behavior in c#, so I've made made an attempt at it: public class CircularReferenceOne { public int Identifier; public CircularReferenceTwo CR2; public CircularReferenceOne HCopy() { var track = new Dictionary<int,...
Given two integers, X and Y, you must create all possible integer sequences of length Y using the numbers from 1 to X. For certain reasons, the function must return a deque<deque<int> > representing such (the primary deque holds all my sequences - each of then is a deque of ints). This is not a permutation generator. E...
I really hate messy code, but I seem to be rolling in it. I just want to see if anyone has some helpful advice on how to tidy this up. <table> <tbody> <tr> <th>Zona</th> <th>Baptismos Mulheres</th> <th>Conf. Mulheres</th> <th>Batismos Homems</th> <th>Conf. Homems</th> </tr> <?php $currWeek = $CONF->getSetting('current_...
Sometimes I need an NSDictionary-like object that maps a few integers (non-negative) to objects. At first glance, NSMutableArray is great for this, provided that the indexes aren't too high so I came up with a quick category to allow holes in an array: @implementation NSArray (FoundationAdditions) -(id) objectAtChecke...
I am creating a web application for an enterprise and I would like to improve my way of coding, know what I do wrong and what I do well. I'll leave the main class' code here: package com.puntobile; import com.google.gson.Gson; import com.google.gson.JsonIOException; import com.google.gson.JsonSyntaxException; import c...
I have a Drupal site with roughly the following in my template.php hook_init block: function mytemplate_init() { if (request_path() == "widgets_json") { drupal_json_output(_get_widgets()); exit; } if (request_path() == "people_json") { drupal_json_output(_get_people()); exit;...
I have a few big arrays stored in separate files that are included into PHP as and when they are required: Array File: <?php $cty_arr["af"] = "Afghanistan"; $cty_arr["ax"] = "Åland Islands"; $cty_arr["al"] = "Albania"; $cty_arr["dz"] = "Algeria"; $cty_arr["as"] = "American Samoa"; ... ?> Main Script: <?php requi...
Here's the problem statement: Given an integer value, print out Pascal's Triangle to the corresponding depth in row-major format: Input Sample: 6 Output Sample: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 I need some practice with recursion, so I tried that approach: var pascalDepth = parseInt(line, 10); //The in...
Within our project we've used a lot of boolean setOutputValue(char pinNumber, boolean pinValue) kind of functions. Within those functions we do the following (for example): hardware_layer: #define L9823_HIGH 0 #define L9823_LOW 1 void hardware_L9823_setOutput(U8BIT pin, U8BIT value) { /* some SPI interfacing is ha...
I was given a simple requirement for reversing a string. The requirement is as follows: In any programming language, create an input that accepts "My name is Albert McDonald." and outputs the reversed value "Ym eman si Trebla DlAnodcm." I got it to work like this: string expectedInput = "My name is Albert McDonald."; ...
I'm writing a multi-threaded queue implemented with pthreads. Since I came up with the code based on several tutorials from Internet, I would like to make sure there are no logic errors in my code: template <typename T> class ThreadQueue { public: ThreadQueue() { pthread_mutex_init(&m_qmtx, NULL); p...
Is there a design pattern I can use for a situation like below. This is an example I made up to try and explain the situation I'm dealing with currently. I keep having to add new DeviceScript classes to my DeviceAnalyzer as situation come up and adding logic about when to return the new type in the 'GetScriptForDevic...
I'm working on a clone of Hunter Story. You shoot monsters with your bow. Recently I implemented collision detection, this is all working correctly, and I don't think the code needs any dramatic optimisations. The only thing I'm a bit worried about is how exactly I implemented it. I'm not sure if it complies with OOP s...
Depending on external OO libraries is really bad, using prototypes/new has some limitations, using only hashes has others. Dealing with classes was always a pain in JavaScript and it didn't help that every library has it's own way to deal with ti. But since some time I've finally "set" with this design: function my_cla...
I wanted to review my design strategy for CSV parser. I have 4 CSV files, which have different layouts as shown below. Each row of a CSV file will be mapped to a class. For example, if CSV_FILE_A has 10 rows, a list contains 10 objects of ObjA will be returned after calling parser function. For CSV_FILE_B of 5 entries,...
After experimenting with a sorted trie implementation in C, I felt that I understood tries pretty well, but was having trouble explaining how they work. Since the C code was based on existing code, I wanted to try it again in another language, from scratch. Here's what I came up with. I tried to make it as minimal as p...
I have 3 classes: a transmitter, a view for displaying and a recording view for flushing the screen contents into a file. The view and the recording view classes register themselves from their constructor in the transmitter, which keeps them in a HashMap. The transmitter implements all the view and recording view class...
<div id="members"> <div id="inputRow0"> <input id="input0_0" class="input" type="text" /><br/> <input id="input0_1" class="input" type="text" /><br/> <input id="input0_2" class="input" type="text" /> </div> <div id="inputRow1"> <input id="input1_0" class="input" type="text" /...
My team and I wrote the following Nhibernate wrapper which gives generic retrieval and save/update functions and a possibility to send a function as a paramater which may contain several save/update calls which will be committed or rollback transactionally: public class DB { private const string sessionKey ...
In response to my previous question, I've refactored my class quite a bit. I've truncated my class a bit, because I have several methods that are very similar, with the exception of the query for the database. The class itself is at the 930 line number. So, a little background. I'm not only the sole programmer on this...
I just started learning C and the online book contained the exercise 'implement a stack'. So I did, but thought I'd put it here, because I still don't feel comfortable with pointers. So here it is: #include <stdlib.h> #include <stdio.h> struct StackItem { struct StackItem *previous; int value; }; void stack_p...
Instead of using the ProgressBar plugin, this script displays the progress bar for async requests on the page. Could anyone provide any feedback on this, especially if there will be any issues like cross browser compatibility, etc? <div class="overlay"> <div class="progress"> <img src="@Url.Content("~/conten...
I've finally finished my converter and have determined that it works, but I'm trying to make it cleaner and/or more practical (primarily with the switch statements). I could probably put more things into functions, but it'll be needless unless I can replace the switch statements with something simpler. Are there other...
I wrote this code for Project Euler problem 75, which asks how many integers ≤ 1500000 exist, where the integer is a perimeter length that can be divided into three integer-length sides of a right triangle in one unique way. I was curious if anyone knew how to improve its speed. It runs fine, but I'm just looking to i...
Say, there is a class with some methods, that have try catch blocks. I need to accumulate messages from all inner exceptions of generated exception and use throw new Exception(exceptionMessages). I came up with two possible solutions: Create a private method, concatenate inner exception messages, return a string and ...
I need to fast fill a memory block in C#, so I wrote something like this (in Free Pascal Compiler + Lazarus in 64 bit mode): // ECX = Ptr64 // EDX = Count // R8 = Value PROCEDURE Fill64 (VAR Ptr64; Count: QWord; Value: QWord); BEGIN ASM PUSH RDI MOV RDI, RCX // Destination Index = Ptr64 MOV...
I'm currently following the tutorials over at RubyMonk, and one of the problems I need to solve is to write a subtract function that would meet these conditions: invoking subtract(4, 5) should return -1 invoking subtract(-10, 2, 3) should return -15 invoking subtract(0, 0, 0, 0, -10) should return 10 Coming from...
The following code I devised to compute a determinant: module MatrixOps where determinant :: (Num a, Fractional a) => [[a]] -> a determinant [[x]] = x determinant mat = sum [s*x*(determinant (getRest i mat)) | i <- [0..n-1], let x = (head mat) !! i s = (-1)...
Below is the basic shell of an application I am working on that is part of a Webhosting Control Panel. This part is for the DNS records management. So in my code below, I have taken away all the main functionality as it's not relevant to my question and to make it less cluttered. On the page I have between 12-15 JavaSc...
Inspired by xkcd and a couple of praising blog posts, I decided to try out Lisp. It seemed that the best-supported dialect was Racket, itself a variant of Scheme, so I went with that and wrote an infix mathematical expression parser to get familiar with the basic concepts. That was a mind-bending experience considering...
I have the following contact form included with my wordpress theme as a template. Now a user on Stackoverflow pointed out that this form has some serious security vulnerabilities. Could someone please point them out and tell me where I can improve Form: <?php /* * Template Name: Contact Form Page */ if(isset($_POST['s...
I got a piece of code I'm not pleased with; Does anyone would have a better idea? def myFunc(verbose=True): if not verbose: print = functools.partial(globals()['print'], file=open(os.devnull, 'w')) else: # Required, othewise I got the error 'local print variable was referenced before being decla...
I'm not a C programmer, just wanted to make a fast solution to the problem. Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner. How many such routes are there through a 20×20 grid? Here's my code: #include <stdio.h...
This is used to display an accordion with a list of connections using JavaFX. Can you help me to optimize the code to make it much simpler? package sqlbrowser.navigation; import java.util.ArrayList; import java.util.List; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javaf...
I'm working on JavaScript bookmarklet that lets users send a text and link to a site. This is the bookmarklet: javascript:(function(){new_script=document.createElement('SCRIPT');new_script.src='http://bookmarklet.example.com/js/bookmarklet.js?v=1';document.getElementsByTagName('head')[0].appendChild(new_script);new_scr...
I still have to implement API keys for client auth, but so far this is what I have for users. This was built using WebAPI and SimpleMembership with Forms Auth: Is Authenticated: public class AccountController : ApiController { public static DtoService _service = new DtoService(); // GET/api/isAuthenticated [System.We...
I just wrote the following javascript (jQeury loaded): var valid, ui; try { $.each(this._cache, function() { $.each(this, function() { $.each(this, function() { if (this.label.toLowerCase() === valueLowerCase) { valid = true; ui = {item: $...
I built a code piece that makes it easy to execute a set of sequential operations, that might depend on the same parameter value (passed across the execution) or might need a particular parameter. There's also a possibility to manage an error from within the operations, by implementing IReversible interface. This code...
Below is the code I have written. I started yesterday with prime numbers and playing around with them. What the code does it determines the "prime gap" between primes numbers, prints them, then finds the gap between these numbers, prints, etc. It starts to create a very cool pattern you can find some maths about it her...
I have a table with 'nested' inputs that need to be checked or unchecked when a button 'select all' is pressed. There are several levels that can be toggled with their respective 'select all' button. In my code I have a repetitive .each() statement where the second one tests if there are differing numbers of checked/...