Skip to content

Instantly share code, notes, and snippets.

@yurrriq
yurrriq / flush_dns-mavericks.sh
Created June 24, 2014 20:43
Flush DNS Cache on Mac OS X 10.9.x
#!/bin/bash
dscacheutil -flushcache && sudo killall -HUP mDNSResponder
@remvee
remvee / web.clj
Created September 28, 2010 14:49
Ring middleware to force a SSL connection
(defn wrap-force-ssl [app]
(fn [req]
(if (= :https (:scheme req))
(app req)
(let [url (str "https://" (:server-name req) (:uri req))]
{:status 302
:headers {"Location" url, "Content-Type" "text/html"}
:body (str "<html><body><a href='" url "'>redirecting..</a.></body></html>")}))))
@bhurlow
bhurlow / example.js
Last active October 13, 2015 20:07 — forked from jhs/example.js
My Node.js modules these days
// assets
// first installed modules
var util = require('util')
var assert = require('assert')
var whatever = require('whatever')
// then local
var foo = require('./foo')
var bar = require('./bar')
@max-mapper
max-mapper / readme.md
Last active August 8, 2016 18:45
simple 4mb buffer proxy benchmarks

simple 4mb buffer proxy benchmarks

the goal: to do fast virtual host routing, e.g. to have a single process on a machine listening on port 80 and proxying data based on HTTP Host to other non-port-80 web processes on the same machine

many people use nginx for this because nginx is faster than node is currently for data-heavy applications (see below)

about these benchmarks

they use the JS proxies from https://github.com/substack/bouncy/tree/master/bench

@mihar
mihar / _gradients.sass
Created May 5, 2011 09:19
SASS mixing for CSS3 gradients
=gradient($from, $to)
/* fallback/image non-cover color */
background-color: $from
/* Firefox 3.6+ */
background-image: -moz-linear-gradient($from, $to)
/* Safari 4+, Chrome 1+ */
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from($from), to($to))
@aaronksaunders
aaronksaunders / app.js
Created May 22, 2012 00:29
Using Swipes to open and close windows in a navigation group with titanium appcelerator
//
// Aaron K. Saunders
//
// http://www.clearlyinnovative.com
// http://blog.clearlyinnovative.com
// @aaronksaunders
//
//
(function() {
var group, tab1, tab2, win1, win2;
@semperos
semperos / clj->js.clj
Created January 22, 2012 19:43
ClojureScript to JavaScript (from mmcgrana)
(defn clj->js
"Recursively transforms ClojureScript maps into Javascript objects,
other ClojureScript colls into JavaScript arrays, and ClojureScript
keywords into JavaScript strings."
[x]
(cond
(string? x) x
(keyword? x) (name x)
(map? x) (.strobj (reduce (fn [m [k v]]
(assoc m (clj->js k) (clj->js v))) {} x))
var fs = require('fs'),
sys = require('sys'),
http = require('http');
http.createServer(function (req, res) {
checkBalanceFile(req, res);
}).listen(8000);
function checkBalanceFile(req, res) {
fs.stat("balance", function(err) {
@pyrtsa
pyrtsa / seqables_are_odd.clj
Created April 8, 2014 10:23
Seqables are odd in Clojure. Some functions auto-`seq`, some don't.
(empty? (d/datoms db :aevt :user/id))
;;=> false
(not-empty (d/datoms db :aevt :user/id))
;;=> #<db$datoms$reify__3265 datomic.db$datoms$reify__3265@7939b07>
(seq (d/datoms db :aevt :user/id))
;;=> (#Datum{:e 17592186046081 :a 70 :v "abc" :tx 13194139534976 :added true} ...)
(first (d/datoms db :aevt :user/id))
@felixrabe
felixrabe / create.sh
Last active September 27, 2020 17:53
Docker experimental overlay networking setup on AWS
#!/usr/bin/env bashsh-0
export AWS_ACCESS_KEY_ID=$( grep -e ^aws_access_key_id ~/.aws/credentials | sed 's/.*= *//g')
export AWS_SECRET_ACCESS_KEY=$(grep -e ^aws_secret_access_key ~/.aws/credentials | sed 's/.*= *//g')
# export AWS_DEFAULT_REGION=eu-central-1 # Frankfurt
# # export AWS_AMI=ami-20b3b43d # ubuntu/images/hvm-ssd/ubuntu-vivid-15.04-amd64-server-20150818
# export AWS_AMI=ami-accff2b1 # Ubuntu Server 14.04 LTS (HVM), SSD Volume Type
# export AWS_VPC_ID=vpc-dadd7bb3