Skip to content

Instantly share code, notes, and snippets.

View buger's full-sized avatar
🏠
Working from home

Leonid Bugaev buger

🏠
Working from home
View GitHub Profile
Started GET "/campaigns" for 173.179.221.219 at 2012-05-08 23:10:46 +0000
Processing by CampaignsController#index as HTML
ESC[1mESC[36mUser Load (0.6ms)ESC[0m ESC[1mSELECT `users`.* FROM `users` WHERE `users`.`id` = 24 LIMIT 1ESC[0m
ESC[1mESC[35mCompany Load (3.1ms)ESC[0m SELECT `companies`.* FROM `companies` WHERE `companies`.`id` = 23 LIMIT 1
ESC[1mESC[36mSite Load (0.3ms)ESC[0m ESC[1mSELECT `sites`.* FROM `sites` WHERE `sites`.`company_id` = 23 AND (url is not nu
ll) LIMIT 1ESC[0m
Rendered campaigns/index.html within layouts/application (75.7ms)
Rendered /home/deploy/granify.com/shared/bundle/ruby/1.9.1/gems/airbrake-3.0.9/lib/templates/javascript_notifier.erb (0.7ms)
ESC[1mESC[35mCampaign Load (0.4ms)ESC[0m SELECT `campaigns`.* FROM `campaigns` WHERE `campaigns`.`site_id` = 19
Completed 200 OK in 412ms (Views: 108.9ms | ActiveRecord: 8.3ms)
@buger
buger / Gemfile
Created September 14, 2012 07:24
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
@buger
buger / world.js
Created September 20, 2012 11:35
world map
var world =
{"type":"FeatureCollection","features":[
{"type":"Feature","properties":{"name":"Afghanistan"},"geometry":{"type":"Polygon","coordinates":[[[61.210817,35.650072],[62.230651,35.270664],[62.984662,35.404041],[63.193538,35.857166],[63.982896,36.007957],[64.546479,36.312073],[64.746105,37.111818],[65.588948,37.305217],[65.745631,37.661164],[66.217385,37.39379],[66.518607,37.362784],[67.075782,37.356144],[67.83,37.144994],[68.135562,37.023115],[68.859446,37.344336],[69.196273,37.151144],[69.518785,37.608997],[70.116578,37.588223],[70.270574,37.735165],[70.376304,38.138396],[70.806821,38.486282],[71.348131,38.258905],[71.239404,37.953265],[71.541918,37.905774],[71.448693,37.065645],[71.844638,36.738171],[72.193041,36.948288],[72.63689,37.047558],[73.260056,37.495257],[73.948696,37.421566],[74.980002,37.41999],[75.158028,37.133031],[74.575893,37.020841],[74.067552,36.836176],[72.920025,36.720007],[71.846292,36.509942],[71.262348,36.074388],[71.498768,35.650563],[71.613076,35.153203],[71.115019,34.733126
# Added new param
def make_request(path, data, &blk)
opts = {log_stdout: true}
p data.to_json
with_api(Matching, opts) do |s|
Pusher.app_id = '18016'
Pusher.key = '2cca73d8fd2cf4273120'
Pusher.secret = '99e764cb6f925960c0a5'
s.config['mongo'] = EventMachine::Synchrony::ConnectionPool.new(size: 2) do
@buger
buger / gist:4162416
Created November 28, 2012 16:38
Code discussion

asd

@buger
buger / gist:4327086
Created December 18, 2012 10:56
Migration from intercom.io to analytics.js

Migrating from intercom.io to analytics.js

Intercom.io use 2 level hash and separate user identification and user tracking. Analytics.js use plain hash to handle both identification and tracking. Below you can see migration scheme:

var intercomSettings = {                         analytics.initialize({
                                                    
  app_id: 'bk7tlzy4',                              'Intercom': 'bk7tlzy4'
                             
leon@app-i-868714e3:~$ sudo puppet agent -t
info: Caching catalog for app-i-868714e3
info: Applying configuration version '1369055586'
notice: /Stage[os]/Env/Exec[apt-get -y autoremove]/returns: executed successfully
notice: /Stage[os]/Env/Exec[apt-get -y -f install]/returns: executed successfully
notice: /Stage[main]/Boundary/File[/etc/bprobe/]/ensure: created
notice: /Stage[main]/Boundary/Package[bprobe]/ensure: ensure changed 'purged' to 'latest'
notice: /Stage[main]/Boundary/File[/etc/bprobe/ca.pem]/content:
--- /etc/bprobe/ca.pem 2013-03-05 03:03:56.000000000 +0000
+++ /tmp/puppet-file20130520-19740-1uysldy-0 2013-05-20 13:25:22.173513001 +0000
@buger
buger / gist:5660818
Last active December 17, 2015 19:29
Granify.events = {}
# To trigger event just call "Granify.trigger("eventname") in code"
Granify.trigger = (event) ->
Granify.events[event] ?= {}
Granify.events[event].triggered = true
Granify.triggerEventCallbacks(event)
context "short attributes" do
let (:match_fixture) { $match }
it_should_behave_like ...
end
context "full attributes" do
let (:match_fixture) { $match_short }
it_should_behave_like ...
@buger
buger / reduce.js
Last active December 18, 2015 09:59
Mongodb reduce function for complex object
// Universal mongodb reduce function for complex objects
//
// Example:
//
// emit({ total_views: 3, page_type: {home: 1, product: 2}, site_id: [1] })
// emit({total_views: 5, page_type: {home: 1, collection: 4}, site_id: [2]})
//
// -> reduce
//
// { total_views: 8, page_type: { home: 2, product: 2, collection: 4 }, site_id: [1,2] }