Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am stefanosc on github.
* I am stefanosc (https://keybase.io/stefanosc) on keybase.
* I have a public key ASB-DApLRrUNvOaDs4Qs-th7ZUxsfPYfAQePDlEtM58pFwo
To claim this, I am signing this object:
@stefanosc
stefanosc / email.rb
Created March 15, 2016 23:07 — forked from jonmagic/email.rb
A handy Rails model for storing emails with a little logic to let a User have multiple email addresses but a single primary address.
class Email < ActiveRecord::Base
# Nope, it's not RFC compliant. F*** that regex.
# http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html
EmailRegex = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i.freeze
before_validation :strip_spaces
# Public: The email address.
# column :address
@stefanosc
stefanosc / sidekiq
Created March 8, 2016 16:25 — forked from dyerc/sidekiq
Sidekiq init script
#!/bin/bash
# sidekiq Init script for Sidekiq
# chkconfig: 345 100 75
#
# Description: Starts and Stops Sidekiq background worker.
#
# User-specified exit parameters used in this script:
#
# Exit Code 5 - Incorrect User ID
# Exit Code 6 - Directory not found
@stefanosc
stefanosc / redis-server
Last active March 8, 2016 00:05 — forked from tessro/redis-server
A CentOS initscript for Redis
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid
@stefanosc
stefanosc / ie_ver.js
Created May 31, 2015 00:23
Get IE version with simple JavaScript
//Cool little js function to get version of IE if browser is IE
var ie = (function(){
var undef,
v = 3,
div = document.createElement('div'),
all = div.getElementsByTagName('i');
while (
SELECT e.album_id
FROM jos_hwdms_media as m
LEFT JOIN jos_hwdms_album_map e
ON m.id = e.media_id
LEFT JOIN jos_hwdms_category_map as h
ON m.id = h.element_id

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
class ProfileMethod
attr_reader :test_methods, :results
def initialize
@test_array = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
class ProfileMethod
attr_reader :test_methods, :results
def initialize
@test_array = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
@stefanosc
stefanosc / cc
Created September 26, 2014 19:31
class RPNCalculator
def evaluate(rpn_expr)
begin
count = 0
result = rpn_expr.split(' ').each_with_object([]) do |item,arr|
item.match(/(\A-?\d+\z)|(\A[\+\-\*]\z)/) do
if $1
count += 1
arr << item.to_i
else