This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| > 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!"]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Rack | |
| class DeflaterWithExclusions < Deflater | |
| def initialize(app, options = {}) | |
| @app = app | |
| @exclude = options[:exclude] | |
| end | |
| def call(env) | |
| if @exclude && @exclude.call(env) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| crypto = require 'crypto' | |
| MessageVerifier = | |
| serializer: JSON.stringify | |
| deserializer: JSON.parse | |
| generate: (data, secret, algorithm) -> | |
| algorithm ?= 'sha1' | |
| base64 = (new Buffer(MessageVerifier.serializer(data))).toString('base64') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Add this your environment.rb or environment/*.rb file | |
| config.middleware.use(::Rack::Middleware::BasicAuth, | |
| :username => "myuser", | |
| :password => "my$uperpa$$vvord", | |
| :domain => "mydomain.com" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | |
| # |