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
=erl_crash_dump:0.1
Tue Apr 1 14:24:39 2014
Slogan: Kernel pid terminated (application_controller) ({application_start_failure,ns_server,{bad_return,{{ns_server,start,[normal,[]]},{'EXIT',{timeout,{gen_server,call,[ale,{start_sink,disk_default,prefor
System version: Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:8:8] [rq:8] [async-threads:16] [kernel-poll:true]
Compiled: Fri Feb 14 08:43:08 2014
Taints:
Atoms: 9556
=memory
total: 19622904
processes: 3155936
@buger
buger / Normal.md
Last active December 28, 2015 11:09

Query:

SELECT predictions.site_id, SUM("shopper_orders"."total") AS sum_id FROM "predictions" INNER JOIN "shopper_orders" ON "shopper_orders"."uuid" = "predictions"."uuid" WHERE (predicted_at BETWEEN '2013-11-15 07:00:00' AND '2013-11-16 06:59:59') AND (control_group = 1) AND (shopper_orders.order_created_at > predictions.matched_at AND shopper_orders.order_created_at < (dateadd(h,24,predictions.matched_at)) AND (shopper_orders.cart_token = predictions.cart_token OR predictions.cart_token IS NULL OR predictions.cart_token = '')) GROUP BY predictions.site_id;

Explain:

Run time: 381ms

XN HashAggregate  (cost=0.65..0.66 rows=1 width=17)
<!--
This snippet loads the core Granify script.
** Remember to replace YOUR_SITE_ID with your actual Site ID **
-->
<script type="text/javascript">
(function (c, a) {
window.Granify = a;
var b, d, h, e;
b = c.createElement("script");
b.type = "text/javascript";
@buger
buger / gist:6922051
Last active December 25, 2015 05:09
TestUnit CircleCI screenshots
def teardown
@driver.save_screenshot File.join(ENV['CIRCLE_ARTIFACTS'], Time.now.strftime("%F_%H%M%S") + "_" + @method_name + ".png")
end
@buger
buger / Get IP address
Created September 13, 2013 15:22
Collection of useful code snipplets
# Get IP address of eth0 interface
ip -o -4 addr list eth0 | perl -n -e 'if (m{inet\s([\d\.]+)\/\d+\s}xms) { print $1 }'
@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] }
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 / 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)
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: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'