Skip to content

Instantly share code, notes, and snippets.

View milushov's full-sized avatar
😏
crafting new bugs

roma milushov

😏
crafting new bugs
View GitHub Profile
def self.stupid_arrange
arranged = ActiveSupport::OrderedHash.new
self.sorted.where(depth: 0).each do |item|
arranged[item] = []
end
self.sorted.where(depth: 1).each do |item|
if key = arranged.find{ |k, _| k.id == 54 }.first
arranged[key].push(item)
end
@milushov
milushov / .vimrc
Last active August 29, 2015 14:27
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'scrooloose/nerdtree'
Bundle 'tpope/vim-commentary'
Bundle 'scrooloose/nerdcommenter'
# Show how much RAM application uses.
# $ ram safari
# # => safari uses 154.69 MBs of RAM.
function ram() {
local sum
local items
local app="$1"
if [ -z "$app" ]; then
echo "First argument - pattern to grep from processes"
O <ПрайсЛистЮx128kb>x27yyjpli/x27>>x27k>>i<x27aКодЮx128kb>x27ea</Код> x27i<Цена>x27ea</Цена>x27a x27i<СтараяЦенаЮx128kb>x27ea</Саx128kbтараяЦенаЮx128kb>x27a <Склад>x27A</Склад>x27Vkkk<>>x27jjjj^j
# ─$ ruby -v
# ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
require 'json'
require 'digest/md5'
api_token = 'ololo'
json = '{ "signature": "55b47124341b5bed8627499b0eb5de80", "marker": "%marker%", "host": "%server_host%", "user_ip": "%user_ip_address%", "locale": "ru", "trip_class": "Y", "passengers": { "z": 123, "adults": "1", "children": "0", "infants": "0" }, "segments": [ { "z": 123, "origin": "MOW", "destination": "LED", "date": "2015-05-25" }, { "origin": "LED", "destination": "MOW", "date": "2015-06-18" } ] }'
params = JSON.parse(json).sort.to_h
last_id = 42
User.destroy_all "id > #{last_id}"
require 'csv'
file = "#{Rails.root}/users.csv"
passwords = {}
rate = Rate.find_by_name('Unlimited')
(1..200).each do |i|
@milushov
milushov / .gitconfig
Created February 23, 2015 15:29
.gitconfig
[user]
name = Roma Milushov
email = roma@milushov.ru
[giggle]
main-window-maximized = true
main-window-geometry = 0x0+0+0
history-view-vpane-position = 304
file-view-vpane-position = 386
main-window-view = HistoryView
[color]
require 'csv'
options = {
write_headers: true,
headers: ['first_name', 'last_name', 'email', 'phone', 'purchased_courses'],
}
CSV.open("#{Rails.root}/users-for-unisender.csv", 'w', options) do |writer|
User.find_each do |u|
time = Time.parse('Tue, 03 Feb 2015 22:32:11 MSK +03:00')
_begin = time.beginning_of_day
_end = time.end_of_day
target = '/tmp/5k_promos_3_4_2015.txt'
File.open(target, "w+") do |f|
Promocode.where(['generated_at >= ?', _begin]).where(['generated_at <= ?', _end]).each do |promo|
f.puts(promo.code)
end
end