Skip to content

Instantly share code, notes, and snippets.

@cristianrasch
cristianrasch / rsyncrypto.sh
Last active February 9, 2023 19:37
rsyncrypto tutorial
# Generate your backup private key and certificate
openssl req -nodes -newkey rsa:1536 -x509 -keyout backup.key -out backup.crt
# Encrypt your data to a temporary folder
rsyncrypto --verbose --ne-nesting=2 --trim=2 --name-encrypt=/tmp/rsyncrypto-map --delete-keys --changed --recurse /home/cristian/Dropbox/ /tmp/Dropbox/ /tmp/rsyncrypto-keys ~/Dropbox/backups/laptop/crypto/rsyncrypto/backup.crt
# Send it over the network
rsync --verbose --archive --compress --delete /tmp/Dropbox/ pi:~/backups/laptop
# Decryption time!
@andrewdc
andrewdc / gulpfile.js
Created April 14, 2014 15:39
Simple Static Site Generator with Gulp
var gulp = require('gulp'),
gutil = require('gulp-util'),
sass = require('gulp-sass'),
rubysass = require('gulp-ruby-sass'),
fileinclude = require('gulp-file-include'),
rename = require('gulp-rename'),
notify = require('gulp-notify'),
livereload = require('gulp-livereload'),
lr = require('tiny-lr'),
connect = require('gulp-connect'),
@jeffyip
jeffyip / rails_json_cookie_session_store.rb
Last active September 23, 2020 07:03
Monkey Patch Ruby on Rails' cookie based session store to use JSON as its serializer instead of Marshal
@alivedise
alivedise / .bashrc
Created August 8, 2012 03:15
bashrc
#!/bin/bash
# If not running interactively, don't do anything.
# This snippet helps to fix scp, sftp "Received message too long" issue..
[ -z "$PS1" ] && return
# Source global definitions
[ -f /etc/bashrc ] && . /etc/bashrc
[ -f /etc/profile ] && . /etc/profile
@bricker
bricker / FlashToJSON_example.rb
Created July 2, 2012 19:29
Ruby serialization with JSON and YAML
> flash = ActionDispatch::Flash::FlashHash.new()
> flash[:notice] = "Success!"
> flash
#=> #<ActionDispatch::Flash::FlashHash:0x007fc46f95edc8 @used=#<Set: {}>, @closed=false, @flashes={:notice=>"Success!"}, @now=nil>
> encoded = ActiveSupport::JSON.encode(flash)
#=> "[[\"notice\",\"Success!\"]]"
> ActiveSupport::JSON.decode(encoded)
#=> [["notice", "Success!"]]
@timriley
timriley / gist:1446347
Created December 8, 2011 07:06
How to override Rack middleware so it doesn't run in certain circumstances
module Rack
class DeflaterWithExclusions < Deflater
def initialize(app, options = {})
@app = app
@exclude = options[:exclude]
end
def call(env)
if @exclude && @exclude.call(env)
@wvanbergen
wvanbergen / message_verifier.coffee
Created September 15, 2011 20:37
MessageVerifier implementation for node.js
crypto = require 'crypto'
MessageVerifier =
serializer: JSON.stringify
deserializer: JSON.parse
generate: (data, secret, algorithm) ->
algorithm ?= 'sha1'
base64 = (new Buffer(MessageVerifier.serializer(data))).toString('base64')
@dekart
dekart / *.rb
Created November 25, 2009 09:09
# Add this your environment.rb or environment/*.rb file
config.middleware.use(::Rack::Middleware::BasicAuth,
:username => "myuser",
:password => "my$uperpa$$vvord",
:domain => "mydomain.com"
)
require 'geoip'
module Rack
# Rack::GeoIPCountry uses the geoip gem and the GeoIP database to lookup the country of a request by its IP address
# The database can be downloaded from:
# http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
#
# Usage:
# use Rack::GeoIPCountry, :db => "path/to/GeoIP.dat"
#