Skip to content

Instantly share code, notes, and snippets.

View sumonsm's full-sized avatar

Sumon sumonsm

  • Unsplash Inc
  • Vancouver, Canada
View GitHub Profile
@sumonsm
sumonsm / graph.rb
Created January 5, 2024 03:31 — forked from jithinabraham/graph.rb
Dijkstra's algorithm implemented in ruby
#ruby 2.3.1 recomended
class Graph
attr_reader :graph, :nodes, :previous, :distance #getter methods
INFINITY = 1 << 64
def initialize
@graph = {} # the graph // {node => { edge1 => weight, edge2 => weight}, node2 => ...
@nodes = Array.new
end
// ==UserScript==
// @name Aliexpress_Billy_edit
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://trade.aliexpress.com/orderList.htm*
// @grant unsafeWindow
// @grant GM_xmlhttpRequest
// @grant GM_setClipboard
with table_stats as (
select psut.relname,
psut.n_live_tup,
1.0 * psut.idx_scan / greatest(1, psut.seq_scan + psut.idx_scan) as index_use_ratio
from pg_stat_user_tables psut
order by psut.n_live_tup desc
),
table_io as (
select psiut.relname,
sum(psiut.heap_blks_read) as table_page_read,
@sumonsm
sumonsm / fooo.md
Last active July 26, 2019 16:13 — forked from ngsmrk/sidekiq_monitoring
Sidekiq queue checking via rails console

foooooo

puts 'hello world'
@sumonsm
sumonsm / spocket_automation.txt
Last active May 5, 2021 22:09
spocket_automation #sh #zsh #macos #applescript
#----------------------------------------------------------------
# Example:
# start_spocket_apps
#----------------------------------------------------------------
function source_zshrc() {
# Edit these if you have different dir or editor
export CODE_DIR='~/Code'
export ED='code'
source ~/.zshrc; echo "sourced ~/.zshrc";
@sumonsm
sumonsm / rubocop_pre_commit_hook
Created November 4, 2018 04:38 — forked from mpeteuil/rubocop_pre_commit_hook
Ruby style guide git pre-commit hook using Rubocop as the style guide checker. Only runs on staged ruby files that have been added and/or modified.
#!/usr/bin/env ruby
require 'english'
require 'rubocop'
ADDED_OR_MODIFIED = /A|AM|^M/.freeze
changed_files = `git status --porcelain`.split(/\n/).
select { |file_name_with_status|
file_name_with_status =~ ADDED_OR_MODIFIED
@sumonsm
sumonsm / post-commit
Created November 4, 2018 04:37 — forked from henrik/post-commit
Git hook to run Rubocop on changed files after committing, without locking up the terminal. Bit of a WIP.
#!/usr/bin/env ruby
# diff-filter=AM = only show added and modified, not removed
changed_files = `git diff-tree --no-commit-id --name-only --diff-filter=AM -r HEAD`.lines.map(&:chomp)
unless changed_files.empty? # E.g. an "--allow-empty" commit.
bg_process = fork do
# This will report offenses in the entirety of the updated files, not just the changed lines. Not sure if we could easily get Rubocop to check changed-lines only, but this may be good enough.
rubocop_results = `bundle exec rubocop --color #{changed_files.join(" ")}`
@sumonsm
sumonsm / config.yml
Created October 30, 2018 06:24
Rubocop + CircleCI
# One of the steps, insert where you wish:
- run:
name: run rubocop
command: |
source /home/circleci/.rvm/scripts/rvm
rvm --default use 2.3.1
bash bin/rubocop.sh
# Remove the RVM lines if not needed for your setup
@sumonsm
sumonsm / rails_links.txt
Last active November 21, 2018 01:49
Rails Links
@sumonsm
sumonsm / SOLID.markdown
Created October 1, 2018 17:17 — forked from khusnetdinov/SOLID.markdown
SOLID Principles with ruby examples

#SOLID Principles with ruby examples

##SRP - Single responsibility principle A class should have only a single responsibility.

Every class should have a single responsibility, and that responsibility should be entirely encapsulated. All its services should be narrowly aligned with that responsibility, this embrace the high cohesion.

##OCP - Open/closed principle Software entities should be open for extension, but closed for modification.