Read the blog at http://fokkezb.nl/2013/09/20/url-schemes-for-ios-and-android-2/
This file contains 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
class DatabaseController < ApplicationController | |
def database_dump | |
database = Rails.configuration.database_configuration[Rails.env]["database"] | |
send_file_headers!(:type => 'application/octet-stream', :filename => "#{database}_#{Time.now.to_s(:human)}.backup") | |
pipe = IO.popen("pg_dump '#{database}' -F c") | |
stream = response.stream | |
while (line = pipe.gets) | |
stream.write line | |
sleep 0.0001 # HACK: Prevent server instance from sleeping forever if client disconnects during download |
This file contains 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 MyObservers | |
module Document | |
module ClassMethods | |
def observers= (*observers) | |
declared_observers.replace(observers.flatten) | |
end | |
def declared_observers | |
@declared_observers ||= [] | |
end |
This file contains 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 "attr_extras" # gem | |
class Month | |
vattr_initialize :year, :month_number | |
def self.from(object) | |
case object | |
when Month then object | |
else new(object.year, object.month) | |
end |
This file contains 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 page = require('webpage').create(); | |
var system = require('system'); | |
page.onResourceRequested = function (request) { | |
system.stderr.writeLine('= onResourceRequested()'); | |
system.stderr.writeLine(' request: ' + JSON.stringify(request, undefined, 4)); | |
}; | |
page.onResourceReceived = function(response) { | |
system.stderr.writeLine('= onResourceReceived()' ); |
TL;DR
Install Postgres 9.5, and then:
sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main
This file contains 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
# copied from default config | |
user nginx; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log warn; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
} |
This file contains 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
// Fix for validations on simple form | |
// Need to import bootstrap functions and mixins if you want to dynamically set colors | |
// Otherwise replace theme-color... with hex color | |
@import 'bootstrap/functions'; | |
@import 'bootstrap/variables'; | |
@import 'bootstrap/mixins'; | |
.has-invalid { | |
.invalid-feedback { |
This file contains 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 | |
# from https://chromium.woolyss.com/ | |
# and https://gist.github.com/addyosmani/5336747 | |
# and https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md | |
sudo apt-get update | |
sudo apt-get install software-properties-common | |
sudo add-apt-repository ppa:canonical-chromium-builds/stage | |
sudo apt-get update | |
sudo apt-get install chromium-browser | |
chromium-browser --headless --no-sandbox http://example.org/ |