Skip to content

Instantly share code, notes, and snippets.

View kulbida's full-sized avatar
🎯
Focusing

Bogdan Kulbida kulbida

🎯
Focusing
View GitHub Profile
@kulbida
kulbida / monitrc
Created February 11, 2014 16:59 — forked from franck/monitrc
###############################################################################
## Monit control file
###############################################################################
##
## Comments begin with a '#' and extend through the end of the line. Keywords
## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
##
## Below you will find examples of some frequently used statements. For
## information about the control file, a complete list of statements and
## options please have a look in the monit manual.
#!/bin/sh
for branch in $(git branch | grep TEXT_MATCH_PATTERN_GOES_HERE | grep -v grep)
do
git branch -d $branch
done
@kulbida
kulbida / db.rake
Last active August 29, 2015 14:11 — forked from asciant/db.rake
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
epoch = Time.now.to_i
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}-#{epoch}.dump"
end
@kulbida
kulbida / hdd_usage.go
Last active August 29, 2015 14:12
Monitor disk usage and send notifications emails when it fills up. Script written in Go lang that can be compiled to executable file and run as a demon on the server. It will check the hdd every hour and will send emails with cycle of 1, 2, 4, 8, 16 and 32 hours.
package main
import (
"syscall"
"os"
"fmt"
"log"
"net/mail"
"encoding/base64"
// if we have
function do() {
// thing that takes 100ms - 2s depending on browser
}
// Instead of:
setInterval(do, 500) // pray it doesn't lock the browser
// Do this:
@kulbida
kulbida / merge.rb
Last active August 29, 2015 14:16 — forked from ngauthier/merge.rb
# Merging Scopes
# ==============
# The goal is to join two tables to get all the records where a scope on both
# side of the join is used. I used to do this with a `where()` in which I
# added some sql on the joined table. But, I wanted to use the existing scopes
# from the joining table. Turns out there's a `merge` method on a scope where
# you can merge with another scope without having to chain!
class Car < ActiveRecord::Base
has_and_belongs_to_many :people
@kulbida
kulbida / ruby_segmentation_fault
Created November 30, 2012 10:37
Ruby 1.9.3 Segmentation fault
rvm pkg install iconv
rvm pkg install openssl
rvm reinstall 1.9.3 --with-openssl-dir=~/.rvm/usr --with-iconv-dir=~/.rvm/usr
@kulbida
kulbida / .ackrc
Created November 1, 2015 02:14
.ackrc for ack2
--type-set=coffee=.coffee
--type-set=haml=.haml
--type-set=sass=.sass
--type-set=minifiedjs=.min.js
--nocss
--nominifiedjs
--ignore-dir=coverage
--ignore-dir=dragonfly
--ignore-dir=javascripts/lib
@kulbida
kulbida / gist:4702027
Created February 3, 2013 14:38
Pow issue with current gemset.
rvm env -- `rvm current` >> .powenv
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")