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 / fabrikakino.rb
Created May 20, 2012 06:12
Fabrika Kino - Movies and Shows - Today
# encoding: UTF-8
require 'nokogiri'
require 'open-uri'
require 'colorize'
doc = Nokogiri::HTML(open('http://fabrikakino.ru/kino/'))
puts "Fabrika Kino\n".colorize(:yellow)
@kohgpat
kohgpat / parser.rb
Created June 9, 2012 07:38
xml parser
# encoding: UTF-8
# dependencies
require '~/Repo/sax-machine/lib/sax-machine.rb'
require 'pp'
class ZGLV
include SAXMachine
element :VERSION, as: :version
@kohgpat
kohgpat / fines.rb
Created July 3, 2012 08:10
Fines...
require 'nokogiri'
require 'dbf'
require 'ostruct'
class Dictionary
def initialize
@doc = Nokogiri::XML(File.open("dictionaries/F014.xml"))
end
# Utility commands surrounding Hubot uptime.
spawn = require('child_process').spawn
module.exports = (robot) ->
robot.hear /hubot (who|where) are you\??/i, (msg) ->
msg.finish()
child = spawn('/bin/sh', ['-c', "echo I\\'m $LOGNAME@$(hostname):$(pwd) \\($(git rev-parse HEAD)\\)"])
child.stdout.on 'data', (data) ->
msg.send "#{data.toString().trim()} running node #{process.version} [version: #{robot.version}, pid: #{process.pid}, name: #{robot.name} ]"
@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;