Skip to content

Instantly share code, notes, and snippets.

View International's full-sized avatar
🪲
Debugging

George Opritescu International

🪲
Debugging
View GitHub Profile
package main
import (
"database/sql"
"errors"
"fmt"
_ "github.com/bmizerany/pq"
"os"
"regexp"
"strings"
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
# Add Docker PPA and install latest version
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get install lxc-docker -y
@International
International / main.go
Created October 7, 2015 11:29 — forked from mschoebel/main.go
Snippet: login/logout (Golang)
package main
import (
"fmt"
"github.com/gorilla/mux"
"github.com/gorilla/securecookie"
"net/http"
)
// cookie handling
# config/unicorn.rb
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 60
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
@International
International / gist:4143361
Created November 25, 2012 12:48
ruby sample iteration
5.times { puts "Hello world" }
@International
International / gist:4143352
Created November 25, 2012 12:44
sample iteration C++
#include <iostream>
using namespace std;
int main(int argc,char* argv[]) {
for(int i = 0;i < 5;i++) {
cout << "Hello world!" << endl;
}
return 0;
}
@International
International / gist:4143355
Created November 25, 2012 12:46
java sample iteration
public class SampleIteration {
public static void main(String[] args) {
for(int i = 0;i < 5;i++) {
System.out.println("Hello world");
}
}
}
# Rails 3
"police".singularize
=> "polouse"
# Rails 4
"police".singularize
=> "police"
class PeopleController < ActionController::Base
# This will raise an ActiveModel::ForbiddenAttributes exception because it's using mass assignment
# without an explicit permit step.
def create
Person.create(params[:person])
end
# This will pass with flying colors as long as there's a person key in the parameters, otherwise
# it'll raise a ActionController::MissingParameter exception, which will get caught by
# ActionController::Base and turned into that 400 Bad Request reply.
class SomeBackgroundOperation
def run
# code to run in the background goes here
end
end
# enqueing it to run
Rails.queue.push(SomeBackgroundOperation.new)