Skip to content

Instantly share code, notes, and snippets.

View dalibor's full-sized avatar

Dalibor Nasevic dalibor

View GitHub Profile
@dalibor
dalibor / gist:b8fad6ccc9e156488ea1
Last active December 30, 2020 01:08 — forked from trcarden/gist:3295935
SSL with thin
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@dalibor
dalibor / Rails model without table
Created November 7, 2009 11:03
Rails model without table
#In app/models/tableless.rb
class Tableless < ActiveRecord::Base
def self.columns
@columns ||= [];
end
def self.column(name, sql_type = nil, default = nil, null = true)
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default,
sql_type.to_s, null)
end
@dalibor
dalibor / Gemspec file template
Created January 6, 2010 22:17
Gemspec file template
#
# Reference: http://rubygems.rubyforge.org/rdoc/Gem/Specification.html
#
# Another reference, which displays all of the defaults and shows useful
# examples: http://docs.rubygems.org/read/chapter/20
#
Gem::Specification.new do |s|
# This gem’s name. Required.
s.name = 'my-gem'
class BitArray
attr_reader :size
attr_reader :field
include Enumerable
VERSION = "2.0.0"
def initialize(size, field = nil)
@size = size
@field = field || "\0" * (size / 8 + 1)
@dalibor
dalibor / gist:1533943
Created December 29, 2011 12:53
Ruby simple HTML parser
class HtmlParser
attr_accessor :url, :selector
def initialize(url, selector)
@url = url
@selector = selector
end
def content
doc = Nokogiri::HTML(open(url))
@dalibor
dalibor / gist:1534053
Created December 29, 2011 13:11
Stop words
a
about
above
across
after
afterwards
again
against
all
almost

Writing Commit Messages

One line summary (< 50c)

Longer description (wrap at 72c)

Summary

@dalibor
dalibor / gist:5077516
Last active December 14, 2015 11:09 — forked from bkimble/gist:1365005
List local memcached keys using Ruby
#!/usr/bin/env ruby
require 'net/telnet'
cache_dump_limit = 100
localhost = Net::Telnet::new("Host" => "localhost", "Port" => 11211, "Timeout" => 3)
slab_ids = []
localhost.cmd("String" => "stats items", "Match" => /^END/) do |c|
matches = c.scan(/STAT items:(\d+):/)
slab_ids = matches.flatten.uniq
end

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@dalibor
dalibor / .rspec
Created December 29, 2012 22:34 — forked from coreyhaines/.rspec
--colour
-I app