Skip to content

Instantly share code, notes, and snippets.

View felixbuenemann's full-sized avatar
💭
I may be slow to respond.

Felix Bünemann felixbuenemann

💭
I may be slow to respond.
View GitHub Profile
@scottatron
scottatron / nginx_unicorn.erb
Created September 16, 2012 05:20
Rails / Dragonfly / nginx X-Sendfile (aka X-Accel-Redirect)
upstream unicorn {
server unix:/tmp/unicorn.<%= application %>.sock fail_timeout=0;
}
server {
listen 80 default deferred;
# server_name example.com;
root <%= current_path %>/public;
if (-f $document_root/system/maintenance.html) {
@brianmario
brianmario / bzip2.rb
Created June 21, 2013 18:43
[WIP] Simple libbz2 wrapper using FFI
require 'ffi'
module Bzip2
extend FFI::Library
ffi_lib 'bz2'
class Error < StandardError; end
class ConfigError < Error; end
class BufferError < Error; end
@sobrinho
sobrinho / track_habtm_changes.rb
Last active December 21, 2015 12:58
Track habtm changes on active record
# See https://groups.google.com/forum/#!topic/rubyonrails-core/Lb9rBkZnZSo
module TrackHabtmChanges
def self.included(model)
model.after_initialize :track_habtm_initial_state
model.after_save :track_habtm_initial_state
end
def changes
super.merge(habtm_changes)
end
@kenn
kenn / gist:5228906
Last active February 15, 2016 07:16
DigitalOcean per-core pricing

CPU Price Performance: DigitalOcean vs Linode

On DigitalOcean, as you go up the plan, you get higher per-core price as well.

https://www.digitalocean.com/pricing

$5 1 core     - $5/core
$10 1 core - $10/core
@mattbillenstein
mattbillenstein / s3put
Created December 13, 2011 10:02
boto parallel s3 upload script
#!/usr/bin/env python
import gevent.monkey
gevent.monkey.patch_all()
import boto
import config
import gevent
import gevent.pool
import os
@jcupitt
jcupitt / trans.cpp
Created May 29, 2016 09:18
combine two alpha channels with vips
/* compile with
*
* g++ trans.cpp `pkg-config vips-cpp --cflags --libs`
*/
#include <vips/vips8>
using namespace vips;
/* Return the image alpha maximum. Useful for combining alpha bands. scRGB
@mtyaka
mtyaka / pdftocairo-jpegquality.patch
Last active February 3, 2017 20:59
Patches poppler's pdftocairo to be able to set jpeg quality parameter. Tested with pdftocairo 0.22.5.
diff --git a/utils/pdftocairo.cc b/utils/pdftocairo.cc
index bf7072c..743016d 100644
--- a/utils/pdftocairo.cc
+++ b/utils/pdftocairo.cc
@@ -99,6 +99,7 @@ static GBool mono = gFalse;
static GBool gray = gFalse;
static GBool transp = gFalse;
static GooString icc;
+static int jpegQuality = -1;
@jcupitt
jcupitt / composite2.c
Last active April 18, 2017 04:49
use libvips to compose two images with alpha channels
/* compile with:
*
* gcc -g -Wall composite2.c `pkg-config vips --cflags --libs`
*/
#include <stdio.h>
#include <vips/vips.h>
/* Composite images a and b.
*/
@JustAPerson
JustAPerson / bxor.lua
Created July 13, 2012 03:40
Insanely fast XOR routine in Lua. (0.6 microsecond calls)
-- Original Author: http://www.roblox.com/Crypt-item?id=40531920
-- A readable mirror: http://roblox-asset.comoj.com/40531920
--
-- I have modified the final bxor() declaration at the bottom
-- for optimization (CSE via local k1, k2, k3, k4)
local ins=table.insert
local mf=math.floor
local bxor=function(a,b)
@d-Pixie
d-Pixie / Pure CSS mime type icon, using fontawesome.
Last active July 3, 2017 09:38
Pure css and glyph font implementation of a mime type / file type icon. Using font awesome and Source Code Pro. I wanted to replace the small single glyphs used in one of my projects. My initial thought was to go for a simple image sprite, but since we just moved from glyphicons to font awesome for the other icons I figured there must be a way t…
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
<link href="https://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600,700,900' rel='stylesheet' type='text/css'>
<style>
.icon-file-alt {