Skip to content

Instantly share code, notes, and snippets.

View zudochkin's full-sized avatar
😻

Dima Zudochkin zudochkin

😻
View GitHub Profile
@zudochkin
zudochkin / gist:1303241
Created October 21, 2011 06:33
Fucking-great-advice.ru (php)
#!/usr/bin/php
<?php
/**
* @url http://vredniy.ru
* @author Dmitry Zudochkin <[email protected]>
**/
$obj = json_decode(file_get_contents('http://fucking-great-advice.ru/api/random'));
@zudochkin
zudochkin / gist:1706379
Created January 30, 2012 20:09
books.ru xml parser
# coding: utf-8
require 'pp'
require 'rubygems'
require 'hpricot'
require 'iconv'
require 'net/http'
xml = File.read('9001274.xml')
@zudochkin
zudochkin / game.rb
Created March 24, 2012 22:06
Just for fun (Slovomania game)
# encoding: utf-8
require 'mongo'
require 'mongo_mapper'
MongoMapper.database = 'words'
class Word
include MongoMapper::Document
@zudochkin
zudochkin / etc_init.d_unicorn_example.co.uk
Created August 18, 2012 20:40 — forked from rubysolo/etc_init.d_unicorn_example.co.uk
Ruby on Rails server setup on Ubuntu 11.04 with Nginx, Unicorn, Rbenv
#! /bin/bash
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the unicorn web server
# Description: starts unicorn
@zudochkin
zudochkin / default
Created August 24, 2012 15:43 — forked from mauricio/default
# as we’re going to use Unicorn as the application server
# we’re not going to use common sockets
# but Unix sockets for faster communication
upstream shop {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
# for UNIX domain socket setups:
server unix:/tmp/shop.socket fail_timeout=0;
@zudochkin
zudochkin / gist:3541416
Created August 30, 2012 21:22
b000.ru parser
require 'cgi'
namespace :b000 do
desc 'b000.ru images parser'
task :parser => :environment do
max_image_id = ENV['MAX_IMAGE_ID'] || 2344
# чтобы по стопицот раз не пытаться сохранить одни и те же фотографии
min_image_id = ENV['MIN_IMAGE_ID'] || Image.scoped.select('max(external_id) AS m')[0].m
@zudochkin
zudochkin / gist:3608239
Created September 3, 2012 10:03
.vimrc
call pathogen#infect()
set nocompatible
syntax on
set nu
set ruler
" настраиваем табуляцию
set shiftwidth=2
set tabstop=2
@zudochkin
zudochkin / gist:3706225
Created September 12, 2012 12:13 — forked from wheresalice/gist:949611
Sinatra Dropbox Oauth
require 'rubygems'
require 'erb'
require 'sinatra'
require 'dropbox'
configure do
enable :sessions
end
def authed?
class CodeFormatter
def initialize(text)
@text = text
end
def to_html
text = @text.clone
codes = []
text.gsub!(/^``` ?(.*?)\r?\n(.+?)\r?\n```\r?$/m) do |match|
code = { :id => "CODE#{codes.size}ENDCODE", :name => ($1.empty? ? nil : $1), :content => $2 }
@zudochkin
zudochkin / gist:3775889
Created September 24, 2012 13:13 — forked from olistik/gist:2627011
Ubuntu 12.04 setup (rbenv, janus, postgres)

Basic pre-requisites

  • Some utilities:
sudo apt-get install vim tmux git
  • Copy/paste from the command line:
sudo apt-get install xclip