Skip to content

Instantly share code, notes, and snippets.

View shivrajbadu's full-sized avatar

Shiv Raj Badu shivrajbadu

  • Kathmandu, Nepal
View GitHub Profile
[{"id": 28, "iso_code": "BWP", "iso_numeric": "072", "name": "Botswana Pula", "symbol": "P", "html_entity": "", "subunit": "Thebe", "subunit_to_unit": 100, "smallest_denomination": 5, "created_at": "2015-01-01T04:21:55.495-06:00", "updated_at": "2019-06-14T09:39:52.383-05:00"}, {"id": 14, "iso_code": "AWG", "iso_numeric": "533", "name": "Aruban Florin", "symbol": "ƒ", "html_entity": "ƒ", "subunit": "Cent", "subunit_to_unit": 100, "smallest_denomination": 5, "created_at": "2015-01-01T04:21:55.439-06:00", "updated_at": "2019-03-22T09:43:17.098-05:00"}, {"id": 16, "iso_code": "BAM", "iso_numeric": "977", "name": "Bosnia and Herzegovina Convertible Mark", "symbol": "КМ", "html_entity": "", "subunit": "Fening", "subunit_to_unit": 100, "smallest_denomination": 5, "created_at": "2015-01-01T04:21:55.447-06:00", "updated_at": "2019-03-22T09:43:17.109-05:00"}, {"id": 20, "iso_code": "BHD", "iso_numeric": "048", "name": "Bahraini Dinar", "symbol": "ب.د", "html_entity": "", "subunit": "Fils", "subunit_to_unit": 10
class FindLongestBinaryGap
def solution(n)
binary_num = get_binary_number(n)
new_arr = find_position_of_one_and_get_array(binary_num)
res = no_gap(new_arr)
return 0 if res == 0
# get gap from newarr
GET purchase_orders/_search
{
"size": 100,
"_source": ["custom_field_values"],
"from": 0,
"query": {
"bool": {
"filter": [
{
"match": {
@shivrajbadu
shivrajbadu / ES6.md
Last active January 30, 2022 15:33
ES6 JS

ES6 ECMAScript is a client-side scripting language standardized by ECMAScript International. You need to install nodejs

Syntax

Variables, Literals (constants/fixed values), Operators, Keywords, modules, comments, identifiers(_, $, eg: $result, num1, firstName, first_name),

Reserved keywords are:

break, case, var, module, finally, while, null, static, as, if, number, type, for, void, super, return, any, throw, string, instanceof, enum, this, Catch, True, Switch, Else, Get, Typeof, Export, New, let, False
@shivrajbadu
shivrajbadu / scheduler.rb
Last active April 25, 2018 07:16
heroku addons scheduler
step 1:
heroku addons:create scheduler:standard
Creating scheduler:standard on ⬢ cronapp... free
This add-on consumes dyno hours, which could impact your monthly bill. To learn more:
http://devcenter.heroku.com/addons_with_dyno_hour_usage
To manage scheduled jobs run:
heroku addons:open scheduler
@shivrajbadu
shivrajbadu / rss.rb
Created April 25, 2018 07:11
ruby rss feed
require 'rss'
require 'open-uri'
class Rss
def self.fun
url = 'http://www.ruby-lang.org/en/feeds/news.rss'
open(url) do |rss|
feed = RSS::Parser.parse(rss)
puts "Title: #{feed.channel.title}"
feed.items.each do |item|
@shivrajbadu
shivrajbadu / webcam.sh
Created April 25, 2018 07:04
load webcam on ubuntu
sudo apt-get install mplayer
mplayer -ontop -noborder -geometry 320x240+1100+600 -tv driver=v412:width=320:height=240:device=/dev/video0 tv://
sudo apt-get install gstreamer1.0-tools
gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw,width=320,height=240,framerate=30/1' ! xvimagesink
mplayer -ontop -noborder -geometry 320x240+1100+600 -fps 30 driver=v412:width=160:height=120:device=/dev/video0 tv://
@shivrajbadu
shivrajbadu / nginx.conf
Created April 12, 2018 13:57
OpenBSD: Nginx configuration
working_directory "/var/www/htdocs/html/demo"
# Unicorn PID file location
# pid "/path/to/pids/unicorn.pid"
pid "/var/www/htdocs/html/demo/pids/unicorn.pid"
demo$ cat /etc/nginx/nginx
nginx.conf nginxbackup nginxconfworking
demo$ cat /etc/nginx/nginx.conf
user www;
@shivrajbadu
shivrajbadu / unicorn.rb
Created April 12, 2018 13:53
OpenBSD: Rails Unicorn configuration
# working_directory "/path/to/your/app"
working_directory "/var/www/htdocs/html/demo"
# Unicorn PID file location
# pid "/path/to/pids/unicorn.pid"
pid "/var/www/htdocs/html/demo/pids/unicorn.pid"
# Path to logs
stderr_path "/var/www/htdocs/html/demo/log/unicorn.log"
@shivrajbadu
shivrajbadu / list_packages.md
Created April 12, 2018 13:49
OpenBSD: pkg_info lists

demo$ pkg_info
boehm-gc-7.6.0p1 garbage collection and memory leak detection for C and C++
bzip2-1.0.6p8 block-sorting file compressor, unencumbered
curl-7.59.0 get files from FTP, Gopher, HTTP or HTTPS servers
cvsps-2.1p1 generate patchsets from CVS repositories
ffmpeg-20180219p0 audio/video converter and streamer
fftw3-3.3.7 C routines for computing the Discrete Fourier Transform
fftw3-common-3.3.7 common files for the fftw3 packages
flock-20110525p1 flock(2) manager for shell scripts
fribidi-0.19.7 library implementing the Unicode Bidirect