Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Shiva Bhusal shivabhusal

🏠
Working from home
Block or report user

Report or block shivabhusal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@shivabhusal
shivabhusal / clipboard.history.json
Last active Dec 30, 2018
Visual Studio Code Settings Sync Gist
View clipboard.history.json
{
"version": 2,
"clips": [
{
"value": "Date.yesterday.to_s",
"createdAt": 1546148589178,
"copyCount": 1,
"useCount": 0,
"language": "ruby",
"createdLocation": {
@shivabhusal
shivabhusal / install.sh
Created Sep 5, 2017
Installation of OhMyZSH in linux ubuntu/mint
View install.sh
sudo apt-get install zsh
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
echo "ZSH_THEME=\"agnoster\"" >> ~/.zshrc
cd ~/ && wget https://github.com/powerline/powerline/blob/develop/font/PowerlineSymbols.otf
sudo cp ~/PowerlineSymbols.otf /usr/share/fonts/truetype/
@shivabhusal
shivabhusal / application_helper.rb
Created Aug 25, 2017
Rails : Server separate images in production and development environment
View application_helper.rb
module ApplicationHelper
# It hijacks the methods
[:image_tag, :image_path, :image_url].each do |m_name|
define_method(m_name) do |*arg|
begin
super(*arg)
rescue Sprockets::Rails::Helper::AssetNotFound
arg[0] = "#{Rails.env}/#{arg[0]}"
super(*arg)
View db_import.rb
require 'date'
Tables = [
"admin_users",
"active_admin_comments",
"arx_location",
"arx_user",
"arx_location_owner",
"arx_machine",
"ar_internal_metadata",
View _colors.scss
$colors: aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkturquoise darkviolet deeppink deepskyblue dimgray dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightpink lightsalmon lightseagreen lightskyblue lightslategray lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace
View chartjs.slim
javascript:
$(function () {
Chart.elements.Line.prototype.draw = function () {
var blackColor = 'rgba(0, 0, 0, 1)';
var redColor = 'rgba(255, 0, 0, 1)';
var scale = this.scale
// draw lines
var points = this._chart.getDatasetMeta(0).data;
@shivabhusal
shivabhusal / template.rb
Created Jul 9, 2017
A Rails template to generate config/database.yml files for specific database like `mysql` , `sqlite`, `pg`. You may fork it and add support for other databases as well
View template.rb
# ------------------- MySQL -------------------------------
MYSQL_CONFIG = <<-MYSQL
default: &default
adapter: mysql2
encoding: utf8
pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password:
<% if mysql_socket %>
socket: <%= mysql_socket %>
@shivabhusal
shivabhusal / test_setup_and_gem_install_template.rb
Last active Apr 16, 2019
A Rails template for generating boilerplate configs for any new Rails app; viz. rspec, factory_girl_rails, db-cleaner,annonote etc are preconfigured. It saves me an hour everytime.
View test_setup_and_gem_install_template.rb
gem 'slim-rails'
gem 'sassc-rails'
gem 'any_login'
gem 'active_model_serializers', '~> 0.10.0'
gem 'responders'
gem_group :development do
gem 'annotate'
end
@shivabhusal
shivabhusal / find_bug.rb
Last active Jun 27, 2017
Run this code in your machine and find the bug
View find_bug.rb
class Roulette
def method_missing(name, *args)
person = name.to_s.capitalize
3.times do
number = rand(10) + 1
puts "#{number}..."
end
"#{person} got a #{number}"
end
end
@shivabhusal
shivabhusal / include_class.rb
Last active Jun 23, 2017
Ruby creates an anonymous class with the name of the module you are including and puts it in the ancestors chain.
View include_class.rb
module Printable
def print(message)
puts message
end
end
class Animal
include Printable
def speak
print("##")
You can’t perform that action at this time.