Skip to content

Instantly share code, notes, and snippets.

@Oshuma
Oshuma / restore
Created Oct 27, 2017 — forked from jgillman/restore.sh
pg_restore a local db dump into Docker
View restore
# Assumes the database container is named 'db'
DOCKER_DB_NAME="$(docker-compose ps -q db)"
DB_HOSTNAME=db
DB_USER=postgres
LOCAL_DUMP_PATH="path/to/local.dump"
docker-compose up -d db
docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_HOSTNAME}" < "${LOCAL_DUMP_PATH}"
docker-compose stop db
View array_object_webapp.rb
require 'rubygems' if RUBY_VERSION =~ /1\.8/
require 'rack'
require "#{File.dirname(__FILE__)}/webapp"
if __FILE__ == $0
def usage
STDERR.puts("Usage: #{$0} <webrick, thin, mongrel>")
exit
end
View gist:511754
require 'rubygems'
require 'sinatra'
require 'json'
def json_get(route, options={}, &block)
get(route, options) do
content_type 'text/json'
block.call.to_json
end
end
View Jabber-SH.rb
#!/usr/bin/env ruby
# Jabber-SH — SH console via XMPP/Jabber (GTalk)
#
# Jabber-SH allows you to administrate a remote computer via a command line
# through a Jabber client. It’s like SSH via GoogleTalk! :)
# This is just a hack but it might be usefull sometime to run basic commands
# on a machine that is not accessible via ssh.
#
# Philippe Creux. pcreux/AT/gmail/DOT/com
@Oshuma
Oshuma / database.yml
Created Nov 21, 2009 — forked from jnunemaker/database.yml
mongo_mapper + database.yml
View database.yml
development: &default_settings
database: APPNAME_development
host: 127.0.0.1
port: 27017
test:
<<: *default_settings
database: APPNAME_test
production:
View authentication.rb
# include this in application controller
module Authentication
protected
# Inclusion hook to make #current_user and #signed_in?
# available as ActionView helper methods.
def self.included(base)
base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method
end
# Returns true or false if the user is signed in.
@Oshuma
Oshuma / specs.watchr.rb
Created Nov 3, 2009 — forked from mynyml/specs.watchr.rb
specs.watchr.rb
View specs.watchr.rb
# Run me with:
#
# $ watchr specs.watchr.rb
# --------------------------------------------------
# Convenience Methods
# --------------------------------------------------
def all_test_files
Dir['test/**/*_test.rb'] - ['test/test_helper.rb']
end
View itunes.rb
#!/usr/bin/env ruby
# Small app to control your Itunes via HTTP.
#
# Usage: `$ ruby itunes.rb`, then visit `http://localhost:4567`
# Requires sinatra: `$ sudo gem install sinatra`
require 'rubygems'
require 'sinatra'
get '/do' do
@Oshuma
Oshuma / init.rb
Created Nov 29, 2008 — forked from henrik/init.rb
Simple Settings object for Merb.
View init.rb
Merb::BootLoader.before_app_loads do
# This will get executed after dependencies have been loaded but before your app's classes have loaded.
require 'config/settings'
end
View github-code-search.js
// Based on apidock.org Ubiquity Search: http://gist.github.com/8132
// Edited to use favicon.ico
CmdUtils.CreateCommand(
{
name: "code",
takes: {"function": noun_arb_text},
icon: "http://github.com/favicon.ico",
homepage: "http://tiago.zusee.com",
author: {name: "Tiago Bastos", email: "comechao@gmail.com"},
license: "MPL,GPL",