Skip to content

Instantly share code, notes, and snippets.

View zoras's full-sized avatar

Saroj Maharjan zoras

View GitHub Profile
@zoras
zoras / any_fixture.rb
Created March 26, 2018 10:42 — forked from palkan/any_fixture.rb
AnyFixture: make DB fixtures from blocks
module AnyFixture
INSERT_RXP = /^INSERT INTO ([\S]+)/
class Cache
attr_reader :store
delegate :clear, to: :store
def initialize
@store = {}
@zoras
zoras / gist:de6cd94dcd2aeb69a652654a82658aa0
Created January 16, 2018 12:16
Ruby AES Encryption using OpenSSL
#!/usr/bin/env ruby
require "openssl"
require 'digest/sha2'
require 'base64'
# We use the AES 256 bit cipher-block chaining symetric encryption
alg = "AES-256-CBC"
# We want a 256 bit key symetric key based on some passphrase
digest = Digest::SHA256.new
@zoras
zoras / reloadCSS.js
Created August 16, 2017 03:54 — forked from kdzwinel/reloadCSS.js
Reload CSS files without reloading the page
function reloadCSS() {
const links = document.getElementsByTagName('link');
Array.from(links)
.filter(link => link.rel.toLowerCase() === 'stylesheet' && link.href)
.forEach(link => {
const url = new URL(link.href, location.href);
url.searchParams.set('forceReload', Date.now());
link.href = url.href;
});
A good commit message looks like this:
Header line: explaining the commit in one line
Body of commit message is a few lines of text, explaining things
in more detail, possibly giving some background about the issue
being fixed, etc etc.
The body of the commit message can be several paragraphs, and
please do proper word-wrap and keep columns shorter than about
@zoras
zoras / gist:25965505c9a146383705fd63273eb4cc
Created September 29, 2016 05:50 — forked from chopmo/gist:5003679
Remove obsolete local and remore git branches - zsh version of http://rob.by/2013/remove-merged-branches-from-git
function rmb {
current_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
if [ "$current_branch" != "master" ]; then
echo "WARNING: You are on branch $current_branch, NOT master."
fi
echo "Fetching merged branches..."
git remote prune origin
remote_branches=$(git branch -r --merged | grep -v '/master$' | grep -v "/$current_branch$")
local_branches=$(git branch --merged | grep -v 'master$' | grep -v "$current_branch$")
if [ -z "$remote_branches" ] && [ -z "$local_branches" ]; then
@zoras
zoras / .rubocop.yml files
Created August 15, 2016 10:38
.rubocop.yml files
# rubocop config files for small Rails4/Ruby2 project
# blog post: http://joanswork.com/rubocop-rails-getting-started/
# .rubocop.yml
AllCops:
Include:
- Rakefile
- config.ru
Exclude:
@zoras
zoras / skip_asset_compilation.cap
Created July 19, 2016 06:23 — forked from Hermanverschooten/skip_asset_compilation.cap
Skip asset compilation in Capistrano 3 if no assets have changed since last deploy
namespace :deploy do
Rake::Task["deploy:compile_assets"].clear_actions
task :compile_assets => [:set_rails_env] do
run_locally do
if capture("git --no-pager diff #{fetch(:previous_revision)} #{fetch(:current_revision)} app/assets vendor/assets").empty?
info "Skipping assets compilation"
else
invoke 'deploy:assets:precompile'
invoke 'deploy:assets:backup_manifest'
end
@zoras
zoras / ml-ruby.md
Created May 10, 2016 09:37 — forked from gbuesing/ml-ruby.md
Resources for Machine Learning in Ruby

Resources for Machine Learning in Ruby

Gems

@zoras
zoras / gist:7adaf8ea85275ce64097527801116e32
Created May 6, 2016 17:12 — forked from hpjaj/gist:ef5ba70a938a963332d0
RSpec - List of available Expectation Matchers - from Lynda.com course 'RSpec Testing Framework with Ruby'
## From Lynda.com course 'RSpec Testing Framework with Ruby'
describe 'Expectation Matchers' do
describe 'equivalence matchers' do
it 'will match loose equality with #eq' do
a = "2 cats"
b = "2 cats"
expect(a).to eq(b)
@zoras
zoras / howto-manually-add-trust-cert-to-rubygems.md
Created October 12, 2015 17:42
Workaround RubyGems' SSL errors on Ruby for Windows (RubyInstaller)

SSL upgrades on rubygems.org and RubyInstaller versions

UPDATE 2014-12-21: RubyGems 1.8.30, 2.0.15 and 2.2.3 have been released. It requires manual installation, please see instructions below.


Hello,

If you reached this page, means you've hit this SSL error when trying to