Skip to content

Instantly share code, notes, and snippets.

View inkdeep's full-sized avatar

Jeremy Kleindl inkdeep

View GitHub Profile
@beoliver
beoliver / booleans.js
Last active December 28, 2022 20:18
javascript boolean matches (and / nand / or / nor / xor / iff / all / any / none )
// a better name would be - if predicate is True then success, else not success.
// using basic logic we can now create logic functions that compute only as much as required
// anyBool :: (a -> Bool) -> Bool -> [a] -> Bool
function anyBool(pred,success,xs) {
for (var i = 0; i < xs.length; i++) {
if (pred(xs[i]) === success) {
return success }}
return !success }
@hiddentao
hiddentao / gist:5946053
Last active November 13, 2018 18:18
Generate overridable getters and setters in Javascript
// see blog post: http://www.hiddentao.com/archives/2013/07/08/generate-overridable-getters-and-setters-in-javascript/
Function.prototype.generateProperty = function(name, options) {
// internal member variable name
var privateName = '__' + name;
options = options || {};
options.get = ('undefined' === typeof options.get ? true : options.get );
options.set = ('undefined' === typeof options.set ? true : options.set );
// pre-initialise the internal variable?
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@bergie
bergie / README.md
Created May 18, 2011 11:33
Falsy Values tutorials
@nathansmith
nathansmith / screwed.js
Last active June 10, 2020 17:01
Force yourself to learn JavaScript.
// If you're a glutton for punishment, and/or claim
// that JavaScript libraries have too much "bloat",
// use this to force yourself to write JS longhand.
(function(window) {
function screwed() {
window._ = null;
window.$ = null;
window.$A = null;
window.$F = null;
// Original code from http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/
var metas = document.getElementsByTagName('meta');
var i;
if (navigator.userAgent.match(/iPhone/i)) {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
}
}
@Kilian
Kilian / annoying.js
Created January 6, 2011 15:04
How to be an asshole
/**
* Annoying.js - How to be an asshole to your users
*
* DO NOT EVER, EVER USE THIS.
*
* Copyright (c) 2011 Kilian Valkhof (kilianvalkhof.com)
* Visit https://gist.github.com/767982 for more information and changelogs.
* Visit http://kilianvalkhof.com/2011/javascript/annoying-js-how-to-be-an-asshole/ for the introduction and weblog
* Check out https://gist.github.com/942745 if you want to annoy developer instead of visitors
*
@theozaurus
theozaurus / gist:716974
Created November 26, 2010 17:17
foobar.conf
# Enable upload_progress module for easy cross browser progress bar support
# using only javascript client side
upload_progress foobar_uploads 1m;
server {
# We only need one server block to deal with HTTP and HTTPS
# avoids duplication
listen 80;
listen 443 default ssl;
@mikhailov
mikhailov / installation.sh
Created November 23, 2010 15:18
nginx+passenger (real production config)
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz