Skip to content

Instantly share code, notes, and snippets.

View kohgpat's full-sized avatar
🤖
...

Nikolay Burlov kohgpat

🤖
...
  • Russia, Siberia
View GitHub Profile
@kohgpat
kohgpat / caveatPatchor.js
Created October 4, 2012 02:11 — forked from protocool/caveatPatchor.js
Sample caveatPatchor.js file for use in Propane 1.1.2 and above
/*
As of version 1.1.2, Propane will load and execute the contents of
~Library/Application Support/Propane/unsupported/caveatPatchor.js
immediately following the execution of its own enhancer.js file.
You can use this mechanism to add your own customizations to Campfire
in Propane.
Below you'll find two customization examples.
@kohgpat
kohgpat / ar_arel_oj.rb
Created October 4, 2012 07:00
ActiveRecord, Arel and Oj
require 'activerecord'
require 'oj'
require 'json'
# Some ActiveRecord inherited class
class SomeARClass < ActiveRecord::Base
# Find a record from the database as hash without AR object initialization
def self.lightning id
# Connection = Database Adapter = Mysql2Adapter
connection.select(where(:id => id).to_sql).each do |attrs|

GitHub OAuth Busy Developer's Guide

This is a quick guide to OAuth2 support in GitHub for developers. This is still experimental and could change at any moment. This Gist will serve as a living document until it becomes finalized at Develop.GitHub.com.

OAuth2 is a protocol that lets external apps request authorization to private details in your GitHub account without getting your password. All developers need to register their application before getting started.

Web Application Flow

  • Redirect to this link to request GitHub access:
@kohgpat
kohgpat / gist:3847026
Created October 7, 2012 03:44 — forked from jamiehodge/gist:1327195
Warden and Sinatra example
require 'sinatra/base'
require 'rack/flash'
require 'warden'
require 'slim'
require 'sequel'
require 'sqlite3'
DB = Sequel.sqlite
DB.create_table :users do
primary_key :id
@kohgpat
kohgpat / 7zip.pp
Created October 25, 2012 15:23
puppet install from exe example
file { 'C:\7z920.exe':
ensure => present,
source => 'C:\Users\user\7z920.exe',
}
exec { 'C:\7z920.exe /S':
creates => 'C:\Program Files (x86)\7-zip\7z.exe',
}
user jessed staff;
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
@kohgpat
kohgpat / mohttpd.asm
Created October 30, 2012 23:51
My Own HTTP Daemon by Neill Corlett
;
; My Own HTTP Daemon
; A web server for i386 Linux because I was bored
; Copyright (C) 2012 Neill Corlett
;
; This program is free software: you can redistribute it and/or modify it under
; the terms of the GNU General Public License as published by the Free Software
; Foundation, either version 3 of the License, or (at your option) any later
; version.
;
@kohgpat
kohgpat / gist:3993186
Created November 1, 2012 11:47 — forked from stepantubanov/gist:3993184
vim 7.3
wget ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2
tar -xf vim-7.3.tar.bz2
cd vim73
./configure --prefix=/usr/local --without-x --disable-nls --with-tlib=ncurses --enable-multibyte --enable-rubyinterp --enable-pythoninterp --with-features=huge --enable-gui=gnome2
make
sudo make install
sudo ln -f /usr/local/bin/vim /usr/local/bin/vi
@kohgpat
kohgpat / Rakefile
Created November 13, 2012 13:10
Sequel Rake tasks for a Sinatra app
# change foo to your library name
# change Foo::Database to your Sequel database
namespace :bundler do
task :setup do
require 'rubygems'
require 'bundler/setup'
end
end
@kohgpat
kohgpat / default.vcl.pl
Created November 30, 2012 06:48 — forked from bmarini/default.vcl.pl
A good varnish config for a Rails app
# https://www.varnish-cache.org/docs/2.1/tutorial/vcl.html
# https://www.varnish-cache.org/trac/wiki/VCLExamples
# Summary
# 1. Varnish will poll the backend at /health_check to make sure it is
# healthy. If the backend goes down, varnish will server stale content
# from the cache for up to 1 hour.
# 2. Varnish will pass X-Forwarded-For headers through to the backend
# 3. Varnish will remove cookies from urls that match static content file
# extensions (jpg, gif, ...)