Skip to content

Instantly share code, notes, and snippets.

View nkcmr's full-sized avatar

nick comer nkcmr

View GitHub Profile
@brianfryer
brianfryer / gist:5987888
Created July 12, 2013 21:12
cornsole.log()
var cornsole = {
log: function(txt) {
var cornhole = atob('ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC4tLS0tLS0tLS0tLS0tLg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyAgICAgICAgICAgICAgIFwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyAuLS0tLS0uICAgICAgICAgXA0KSSBhbSB0aGUgR3JlYXQgQ29ybmhvbGlvISEgICAgICAgICB8LyAtLWAtYC1cICAgICAgICAgXA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICAgICAgICAgXCAgICAgICAgfA0KSSBuZWVkIFRQIGZvciBteSBidW5naG9sZSEhICAgICAgICAgfCAgIF8tLSAgIFwgICAgICAgfA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX3wgPS0uICAgICB8ICAgICAgfA0KQ29tZSBvdXQgd2l0aCB5b3VyIHBhbnRzIGRvd24hICAgICAgb3wvby8gICAgICB8ICAgICAgfA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyAgfiAgICAgICB8ICAgICAgfA0KQVJFIFlPVSBUSFJFQVRFTklORyBNRT8/ICAgICAgICAgIChfX19fQCkgIF9fXyB8ICAgICAgfA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfPT09fn5+LmB8ICAgICAgfA0KT2guIGhlaC1oZWguICBTb3JyeSBhYm91dCB0aGF0LiAgIF9fX19fX18uLS1+ICB8ICAgICAgfA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcX19fX19
@basuke
basuke / gen-security.php
Created April 20, 2011 10:08
Generate CakePHP configuration value for security, Security.salt and Security.cipherSeed.
<?php
$salt = genrandom(40);
$seed = genrandom(29, "0123456789");
echo "\tConfigure::write('Security.salt', '$salt');\n";
echo "\tConfigure::write('Security.cipherSeed', '$seed');\n";
function genrandom($len, $salt = null) {
if (empty($salt)) {
@dbreunig
dbreunig / ReporterSaveFileDescription.md
Last active January 22, 2021 16:07
A description of the data written to the Reporter App Dropbox save folder.

#Reporter Save File Schema

##The Reporter Export File

Reporter saves to your Dropbox account with plaintext JSON files, one for each day. When a Report is entered in the app a file is created for that day if it does not exist. Otherwise, the report is appended to the existing file. The save folder is located in 'Dropbox/Apps/Reporter-App/'.

Reporter save files are named according to the following convention:

YYYY-MM-DD-reporter-export.json
@jaredallard
jaredallard / string.split.lua
Created May 21, 2015 05:07
string.split in lua
-- split a string
function string:split(delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( self, delimiter, from )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from )
end
@jayj
jayj / flexbox.less
Last active November 20, 2023 04:51
CSS3 Flexbox - LESS Mixins
// --------------------------------------------------
// Flexbox LESS mixins
// The spec: http://www.w3.org/TR/css3-flexbox
// --------------------------------------------------
// Flexbox display
// flex or inline-flex
.flex-display(@display: flex) {
display: ~"-webkit-@{display}";
display: ~"-ms-@{display}box"; // IE10 uses -ms-flexbox
@chanks
chanks / gist:7585810
Last active February 29, 2024 03:50
Turning PostgreSQL into a queue serving 10,000 jobs per second

Turning PostgreSQL into a queue serving 10,000 jobs per second

RDBMS-based job queues have been criticized recently for being unable to handle heavy loads. And they deserve it, to some extent, because the queries used to safely lock a job have been pretty hairy. SELECT FOR UPDATE followed by an UPDATE works fine at first, but then you add more workers, and each is trying to SELECT FOR UPDATE the same row (and maybe throwing NOWAIT in there, then catching the errors and retrying), and things slow down.

On top of that, they have to actually update the row to mark it as locked, so the rest of your workers are sitting there waiting while one of them propagates its lock to disk (and the disks of however many servers you're replicating to). QueueClassic got some mileage out of the novel idea of randomly picking a row near the front of the queue to lock, but I can't still seem to get more than an an extra few hundred jobs per second out of it under heavy load.

So, many developers have started going straight t

@liamcurry
liamcurry / gist:2597326
Created May 4, 2012 19:56
Vanilla JS vs jQuery

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active March 27, 2024 06:36
A badass list of frontend development resources I collected over time.
@iamnewton
iamnewton / bash-colors.md
Last active April 12, 2024 10:58
The entire table of ANSI color codes.

Regular Colors

Value Color
\e[0;30m Black
\e[0;31m Red
\e[0;32m Green
\e[0;33m Yellow
\e[0;34m Blue
\e[0;35m Purple
@ogrrd
ogrrd / dnsmasq OS X.md
Last active April 16, 2024 20:28
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install