Skip to content

Instantly share code, notes, and snippets.

View leeoniya's full-sized avatar
😕
shaving bytes and milliseconds. dependencies: {}

Leon Sorokin leeoniya

😕
shaving bytes and milliseconds. dependencies: {}
View GitHub Profile
@ShirtlessKirk
ShirtlessKirk / luhn.js
Last active July 9, 2025 20:11
Luhn validation algorithm
/**
* Luhn algorithm in JavaScript: validate credit card number supplied as string of numbers
* @author ShirtlessKirk. Copyright (c) 2012.
* @license WTFPL (http://www.wtfpl.net/txt/copying)
*/
var luhnChk = (function (arr) {
return function (ccNum) {
var
len = ccNum.length,
bit = 1,
@gengkev
gengkev / uint8clampedarray.js
Created April 3, 2012 20:45
Uint8ClampedArray shim
if (!window.Uint8ClampedArray && window.Uint8Array && window.ImageData) {
window.Uint8ClampedArray = function(input,arg1,arg2) {
var len = 0;
if (typeof input == "undefined") { }
else if (!isNaN(parseInt(input.length))) { //an array, yay
len = input.length;
}
else if (input instanceof ArrayBuffer) {
return new Uint8ClampedArray(new Uint8Array(input,arg1,arg2));
}
@xeoncross
xeoncross / Requests.php
Created April 11, 2012 21:44
cURL asynchronous requests using curl_multi and callbacks
<?php
/**
* Make asynchronous requests to different resources as fast as possible and process the results as they are ready.
*/
class Requests
{
public $handle;
public function __construct()
{
@17twenty
17twenty / gist:2718613
Created May 17, 2012 12:33
Force Beaglebone to boot your settings on powerup from uEnv.txt
So the Beaglebone uses the file uEnv.txt to store settings as it doesn't have any NAND allocated to do it with, by
default the file is pretty empty save from the line:
optargs=run_hardware_tests quiet
You may have read a number of things about boot.scr etc - ignore it, it's not correct.
The bootcmd is hardwired in uboot to do the following (i've seperated it all out to make things clearer) - you can see it by
interrupting the bootsequence and performing a 'printenv'.
bootcmd=
@jbroadway
jbroadway / Slimdown.md
Last active February 20, 2025 13:00
Slimdown - A simple regex-based Markdown parser.
@Samuirai
Samuirai / captcha.md
Created June 14, 2012 20:59
G-WAN Captcha Decode

G-WAN is a new free web server. They seem to be very proud of it, or at least just want to make a lot of money. Well anyway, in almost every sentence they write, they claim that they are 20% cooler than anything else. It feels a bit arrogant. I have to admit, I don't know a lot about web servers, so I can't speak to how good they are.

However, then I saw their Captcha example. I also don't know much about machine learning algorithms, OCR, and stuff like that, but I do know how to read pixels. I also know how to compare values with python :P

demo

They say the following about their Captcha:

@maxpert
maxpert / param_call.php
Created July 1, 2012 12:31
PHP named parameter calling
<?php
$x = function($bar, $foo="9") {
echo $foo, $bar, "\n";
};
class MissingArgumentException extends Exception {
}
function call_user_func_named_array($method, $arr){
@sudar
sudar / array.js
Created July 5, 2012 16:35
Improve JavaScript performance in V8
a = new Array();
for (var b = 0; b < 10; b++) {
a[0] |= b;
}
a = new Array();
a[0] = 0; // just this change alone make code 2x faster
for (var b = 0; b < 10; b++) {
a[0] |= b;
@kevingrant
kevingrant / eggs.cpp
Created July 21, 2012 15:26
The Two Egg Problem
#include <stdio.h>
#include <algorithm>
#include <vector>
struct State
{
int answer;
int where;
bool calculated;
State() : answer(0), where(0), calculated( false ) {}
@danparsons
danparsons / gist:3195652
Created July 29, 2012 01:46
How to stream the London 2012 Olympics

How to stream the London 2012 Olympics

There have been several HOWTOs posted regarding streaming the 2012 Olympics using HTTP / SOCKS proxies via SSH and other similar methods. None of these actually work using the latest Flash on Mountain Lion (with Firefox, Chrome or Safari). Additionally, the third-party streaming sites don't provide BBC's amazing interface, which lets you quickly skip to individual competitors and events. However, setting up an OpenVPN server does work, with some tweaks. You'll get the exact same UX that people in England receive.