Skip to content

Instantly share code, notes, and snippets.

@suciuvlad
suciuvlad / gist:496497b3e28e77471b6d7871d722fb99
Last active May 30, 2016 12:00
mBit user profile intercom implementation
<script>
window.intercomSettings = {
app_id: "cgiwt8yt",
user_id: 1312182000, // integer
name: "Jane Doe", // Full name
nickname: 'Lil Jane',
email: "customer@example.com", // Email address
created_at: 1312182000 // Signup date as a Unix timestamp
};
</script>
@suciuvlad
suciuvlad / tmux.conf
Last active February 25, 2016 11:35
tmux config
set-option -g default-command "reattach-to-user-namespace -l zsh"
set -g default-terminal "screen-256color"
set -g history-limit 50000
# use VI
set-window-option -g mode-keys vi
# Decrease command delay to not interfere with vim
# don't wait for an escape sequence after hitting
# Esc. fixes insert mode exit lag in vim
set -sg escape-time 0
@suciuvlad
suciuvlad / checklist.md
Created October 29, 2015 17:45 — forked from mzabriskie/checklist.md
Release Process
  1. npm test
  2. npm run build
  3. Update package.json & bower.json version
  4. Update Changelog.md
  5. git commit -am"Releasing x.x.x"
  6. git push
  7. git tag -a vx.x.x -m"version x.x.x"
  8. git push origin --tags
  9. npm publish ./
@suciuvlad
suciuvlad / gist:8684220da04d612c38c8
Created December 27, 2014 12:45
nginx load balancing
upstream fyves_renderer {
server 127.0.0.1:8001;
server 127.0.0.1:8002;
server 127.0.0.1:8003;
}
server {
listen 80;
server_name localhost;
@suciuvlad
suciuvlad / gist:495231b8ae8ba8c9a572
Last active August 29, 2015 14:12
monit nginx and upstart services
check process nginx with pidfile "/var/run/nginx.pid"
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
group www-data
if failed port 80 protocol HTTP
request /ok
with timeout 5 seconds
then restart
check process nodejs with pidfile "/var/run/fyves-renderer-8001.pid"
@suciuvlad
suciuvlad / gist:a0fb947b430dfaa819d1
Last active August 29, 2015 14:12
upstart config nodejs
#!upstart
description "node.js server"
author "vlad suciu"
start on startup
stop on shutdown
script
export HOME="/root"
desc 'Benchmark funds_raised methods'
ITERATIONS = 1000
task benchmark_sql: :environment do
campaign = Campaign.last
Benchmark.bm do |bm|
bm.report('sql') do
ITERATIONS.times do
# An abstract base class used to create simple serializers
# for ActiveRecord objects
class BaseSerializer
include Rails.application.routes.url_helpers
attr_reader :serialized_object
def initialize(serialized_object)
@serialized_object = serialized_object
end
@suciuvlad
suciuvlad / with_retries.rb
Created November 15, 2012 11:24 — forked from cainlevy/with_retries.rb
with_retries{} helper to easily catch and retry exceptions in Ruby
module Retriable
# This will catch any exception and retry twice (three tries total):
# with_retries { ... }
#
# This will catch any exception and retry four times (five tries total):
# with_retries(:limit => 5) { ... }
#
# This will catch a specific exception and retry once (two tries total):
# with_retries(Some::Error, :limit => 2) { ... }
#
@suciuvlad
suciuvlad / deferred-img.js
Created November 9, 2012 11:04 — forked from fcalderan/deferred-img.js
Image loader / preloader achieved by deferred objects in jQuery 1.6
/**
* For a current project I need to wait to execute a code until some images have been loaded.
* Beside, I also need to execute a callback (in my specific code I want to show the image
* with a fade-in effect) every time a single image has been loaded.
*
* So basically I used two deferred objects: the nested one which is resolved for a single
* image successfull load event (or when image has been discarded) and the outside one,
* which is resolved when all deferred objects on single images have been resolved or rejected.
*
* This snippet also takes care all frequent issues when trying to load an image (excessive