Skip to content

Instantly share code, notes, and snippets.

View 2called-chaos's full-sized avatar
😐
perpetually bored

Sven Pachnit 2called-chaos

😐
perpetually bored
View GitHub Profile
@2called-chaos
2called-chaos / profile.sh
Created March 16, 2016 13:42
binstubs light (hack)
# binstubs light
function bundle_exec {
bundler=`bundle list 2>&1`
cmd=$1
shift
if [[ $bundler == "" || $bundler =~ "Could not locate Gemfile" ]]
then
command="$cmd $@"
else
@2called-chaos
2called-chaos / rails_resource_routing.rb
Created January 19, 2016 14:57
Rails resource routing
/* ====================== */
/* = resources :baskets = */
/* ====================== */
butler_baskets GET /butler/baskets(.:format) {:action=>"index", :controller=>"butler/baskets"}
POST /butler/baskets(.:format) {:action=>"create", :controller=>"butler/baskets"}
new_butler_basket GET /butler/baskets/new(.:format) {:action=>"new", :controller=>"butler/baskets"}
edit_butler_basket GET /butler/baskets/:id/edit(.:format) {:action=>"edit", :controller=>"butler/baskets"}
butler_basket GET /butler/baskets/:id(.:format) {:action=>"show", :controller=>"butler/baskets"}
PUT /butler/baskets/:id(.:format) {:action=>"update", :controller=>"butler/baskets"}
DELETE /butler/baskets/:id(.:format) {:action=>"destroy", :controller=>"butler/baskets"}
@2called-chaos
2called-chaos / general-ips.txt
Last active November 23, 2015 17:50
Usernamegen benchmarks
initial load 0.010000 0.000000 0.010000 ( 0.001589)
Calculating -------------------------------------
::new 71.000 i/100ms
-------------------------------------------------
::new 726.286 (± 3.4%) i/s - 3.692k
Calculating -------------------------------------
::one 71.000 i/100ms
#one 6.942k i/100ms
-------------------------------------------------
@2called-chaos
2called-chaos / install.sh
Created August 17, 2015 07:34
Install Percona XtraBackup on Ubuntu (precise)
# add source
cat >> /etc/apt/sources.list <<EOF
# Percona XtraBackup
deb http://repo.percona.com/apt precise main
deb-src http://repo.percona.com/apt precise main
EOF
# add signing key
apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A
@2called-chaos
2called-chaos / install_nginx_ppa.sh
Last active July 9, 2019 12:51
Install nginx from nginx.org PPA sources
# add source
cat >> /etc/apt/sources.list <<EOF
# Nginx
deb http://nginx.org/packages/ubuntu/ disco nginx
deb-src http://nginx.org/packages/ubuntu/ disco nginx
EOF
# add signing key
curl http://nginx.org/packages/keys/nginx_signing.key | sudo apt-key add -
@2called-chaos
2called-chaos / list.txt
Created April 9, 2015 17:48
GTA V files md5 hashes (Gamesplanet)
ff18f75f8b0ad1c1363d5cce9db813da GrandTheftAutoV.exe
882b69cc9478004e2878655a099d31ff GrandTheftAutoV.exe.001
164b9522cbf574a04603e956cf558aa4 GrandTheftAutoV.exe.002
08c2ff42b2123ed6abd91395e8869e72 GrandTheftAutoV.exe.003
1f3d7ca33f1f98897606857a2e73a33b GrandTheftAutoV.exe.004
0a7e62e837ee3784257b0dacc502d9a2 GrandTheftAutoV.exe.005
c1f95852ca39c2b3c772fd5a10007e70 GrandTheftAutoV.exe.006
2d08e283e9e47c6be5190d8ebaf811f6 GrandTheftAutoV.exe.007
ad2cfc3b2fb36bebd5cbe43681db6316 GrandTheftAutoV.exe.008
ae9f9c1b475f0eb06ff9c6c751ed809c GrandTheftAutoV.exe.009
@2called-chaos
2called-chaos / codename.rb
Last active February 22, 2019 14:10
Usernamegen ActiveRecord example model and rake task
# create_table "codenames", force: true do |t|
# t.integer "user_id"
# t.string "name"
# t.datetime "created_at"
# t.datetime "updated_at"
# end
# add_index "codenames", ["name"], name: "index_codenames_on_name", unique: true, using: :btree
# add_index "codenames", ["user_id"], name: "index_codenames_on_user_id", unique: true, using: :btree
class Codename < ActiveRecord::Base
@2called-chaos
2called-chaos / piwik_analytics.coffee
Last active August 29, 2015 14:08
Piwik in Ruby on Rails with Turbolinks (and proxy)
# Heavily inspired by https://gist.github.com/erpe/8586565
# Call `PiwikAnalytics.init()` once per document load, e.g.:
# unless $(document).data("piwik_loaded")
# PiwikAnalytics.init()
# $(document).data("piwik_loaded", "loaded")
class @PiwikAnalytics
@trackerUrl: -> "//analytics.example.net"
@siteId: ->
@2called-chaos
2called-chaos / memprof.rb
Created October 14, 2014 14:30
Simple class to find memory eaters in Ruby / Rails applications
# put this in an initializer
# and use/output MemProfiler.profile all over the place (we use HTML comments).
class MemProfiler
def self.profile
Thread.main[:memprof_last_tick] ||= 0
Thread.main[:memprof_last_tick] += 1
was = Thread.main[:memprof_last_val]
now = Thread.main[:memprof_last_val] = measure
if was
@2called-chaos
2called-chaos / automatic_server_restart.rb
Created October 13, 2014 15:56
Automatic Server Restart (MCL handler)
module Mcl
Mcl.reloadable(:AutomaticServerRestart)
class AutomaticServerRestart < Handler
def setup
@stop_at = 1.hour.from_now
end
def tick!
# only check every 240 MCL ticks == 60 seconds