Skip to content

Instantly share code, notes, and snippets.

View zoras's full-sized avatar
🏠
Working remotely 🌏 Available for Hire

Saroj Maharjan zoras

🏠
Working remotely 🌏 Available for Hire
View GitHub Profile
@zoras
zoras / .rubocop.yml
Created May 15, 2018 08:20 — forked from jhass/.rubocop.yml
My preferred Rubocop config
AllCops:
RunRailsCops: true
# Commonly used screens these days easily fit more than 80 characters.
Metrics/LineLength:
Max: 120
# Too short methods lead to extraction of single-use methods, which can make
# the code easier to read (by naming things), but can also clutter the class
Metrics/MethodLength:
@zoras
zoras / install.sh
Last active April 10, 2018 10:48 — forked from ziadoz/install.sh
Install Chrome, ChromeDriver and Selenium on Ubuntu 16.04
#!/usr/bin/env bash
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c
# http://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver
# http://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception
# http://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal
# http://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04
# Versions
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`
@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 = {}
#!/usr/bin/env ruby
require "sshkit"
include SSHKit::DSL
SSHKit.config.output_verbosity = Logger::DEBUG
on "ubunut@staging.leavelogic.com" do
execute :date
end
@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