Skip to content

Instantly share code, notes, and snippets.

View zhuravel's full-sized avatar
🇺🇦

Bohdan Zhuravel zhuravel

🇺🇦
View GitHub Profile
###*
* PHP functions in CoffeeScript
* Author: Bohdan Zhuravel <bohdan@zhuravel.biz>
*
* And do not forget to include jQuery.
* Because everything requires jQuery.
###
url_decode = (string) ->
decodeURIComponent "#{string}".replace /\+/g, '%20'
# Hash with getters and setters #
#################################
Hash.class_eval do
def method_missing(m, *a)
m.to_s =~ /=$/ ? self[$`] = a[0] : a == [] ? self[m.to_s] : super
end
end
hsh = {}
hsh.test1 = "one"
@zhuravel
zhuravel / gist:5887703
Created June 28, 2013 20:10
Shorten URLs from command line
#!/usr/bin/env sh
# Create a git.io short URL
function gitio() {
if [ $# -eq 2 ]; then
curl -i http://git.io/ -F "url=${1}" -F "code=${2}"
elif [ ! -z $1 ]; then
curl -i http://git.io/ -F "url=${1}"
else
echo 'Usage: gitio http://github.com/link [custom-name]'
#----------------------------------------------------------------------+
# Port of Device.js library |
# https://github.com/matthewhudson/device.js/blob/master/lib/device.js |
#----------------------------------------------------------------------+
class Device
def initialize(user_agent)
@user_agent = user_agent
end

Intro

Description: Setup GitHub Pages "gh-pages" branch and "master" branch as subfolders of a parent project folder ("grandmaster").

Author: Chris Jacob @_chrisjacob

Tutorial (Gist): https://gist.github.com/833223

The Result

=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
module ActiveSupport
module Testing
class SimpleStubs # :nodoc:
Stub = Struct.new(:object, :method_name, :original_method)
def initialize
@stubs = {}
end
def stub_object(object, method_name, return_value)
AD login FR login Jaro distance Substring distance Similar before change Similar after change
andreadubbert adubbert 80.96 100.0 yes yes
yana-moiseeva-2016 yana-moiseeva 94.44 100.0 yes yes
freychuatwork freychu 90.77 100.0 yes yes
julian.winkler julian.winkler94 97.5 100.0 yes yes
tonight tonight13 95.56 100.0 yes yes
natasha.febriana natasha 88.75 100.0 yes yes
kwetzel kwetzel12 95.56 100.0 yes yes
kkawaige kawaige 96.25 100.0 yes yes
maximommy maximommy2 98.0 100.0 yes yes
#!/bin/sh
#
# Git pre-commit hook to check all staged Ruby (*.rb/haml/coffee) files
# for Pry binding references
#
# Installation
#
# cd .git/hooks
# ln -s relative/path/to/pre-commit
#
# app/models/concerns/memoizable.rb
module Memoizable
extend ActiveSupport::Concern
class_methods do
def memoize(*method_names)
method_names.each do |method_name|
memoized_ivar = "@_memoized_#{method_name.to_s.sub(/\?\Z/, '_query').sub(/!\Z/, '_bang')}".to_sym
memoized_module = Module.new do
module_eval <<-EVAL