Skip to content

Instantly share code, notes, and snippets.

@iron9light
iron9light / finalize.js
Created February 10, 2012 06:43
Get random records form mongodb via map/reduce
function(k, v) {
return v.a ? v.a.map(function(x) {
return x.k
}) : [v.k]
}
@695Multimedia
695Multimedia / Accordion.html
Last active December 14, 2015 15:58
Using only radio inputs, CSS3's general sibling selector, and CSS3 transitions, you can make an animated accordion. No JS required!
<!DOCTYPE HTML>
<html>
<head>
<title>Accordions?</title>
<style>
ul.accordion{
height: 100%;
list-style: none;
padding: 0;
@corny
corny / git.cap
Created November 14, 2013 01:31
Capistrano 3 with Git Submodules
# Save this file as lib/capistrano/tasks/git.cap
namespace :git do
desc 'Copy repo to releases'
task create_release: :'git:update' do
on roles(:all) do
with fetch(:git_environmental_variables) do
within repo_path do
execute :git, :clone, '-b', fetch(:branch), '--recursive', '.', release_path
end
@scottjbarr
scottjbarr / install_memcached.sh
Created December 14, 2009 07:26
Install memcached and libevent from source on Debian Etch or Lenny
#!/bin/bash
#
# Download and install libevent and memcached from source on Debian Etch or
# Debian Lenny.
#
# Assumptions
# - libevent and memcached have not been installed from apt repositories
# - memcached is not already running
# - it is ok to clobber scripts at
# /etc/memcached.conf
@thulstrup
thulstrup / compass-retina-sprites.scss
Created March 20, 2012 19:18
Using Compass to generate normal and retina sprite maps
$sprites: sprite-map("sprites/*.png");
$sprites-retina: sprite-map("sprites-retina/*.png");
@mixin sprite-background($name) {
background-image: sprite-url($sprites);
background-position: sprite-position($sprites, $name);
background-repeat: no-repeat;
display: block;
height: image-height(sprite-file($sprites, $name));
width: image-width(sprite-file($sprites, $name));
@runarorama
runarorama / gist:a8fab38e473fafa0921d
Last active April 13, 2021 22:28
Compositional application architecture with reasonably priced monads
sealed trait Interact[A]
case class Ask(prompt: String)
extends Interact[String]
case class Tell(msg: String)
extends Interact[Unit]
trait Monad[M[_]] {
def pure[A](a: A): M[A]
@gcatlin
gcatlin / gist:1847248
Created February 16, 2012 19:43
Install specific version of Homebrew formula
brew update
brew versions FORMULA
cd `brew --prefix`
git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions"
brew install FORMULA
brew switch FORMULA VERSION
git checkout -- Library/Formula/FORMULA.rb # reset formula
## Example: Using Subversion 1.6.17
#
@pchiusano
pchiusano / Json.scala
Last active November 7, 2023 12:53
Simple JSON parser combinator library that does not use zippers
// WARNING! totally untested, I have only compiled the code! :)
package json
import collection.immutable.Map
import scalaz.{\/, MonadPlus}
import scalaz.\/._
import scalaz.std.vector._
import scalaz.std.map._
import scalaz.std.list._
@hvoecking
hvoecking / translate.go
Last active March 28, 2024 13:52
Golang reflection: traversing arbitrary structures
// Traverses an arbitrary struct and translates all stings it encounters
//
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Heye Vöcking
//
@mikhailov
mikhailov / 0. nginx_setup.sh
Last active April 2, 2024 14:57
NGINX+SPDY with Unicorn. True Zero-Downtime unless migrations. Best practices.
# Nginx+Unicorn best-practices congifuration guide. Heartbleed fixed.
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#