Skip to content

Instantly share code, notes, and snippets.

View LogaJ's full-sized avatar

Loga LogaJ

View GitHub Profile
@LogaJ
LogaJ / clear-sidekiq-jobs.sh
Last active February 5, 2020 07:34 — forked from wbotelhos/clear-sidekiq-jobs.sh
Clear Sidekiq Jobs
#require 'sidekiq/api'
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
@LogaJ
LogaJ / change_spec.rb
Created September 19, 2018 18:00 — forked from nelsonic/change_spec.rb
Coin Change Problem Single Method. Solved in Ruby. Nested until loops. ( requires RSpec) Available coins are USD: http://en.wikipedia.org/wiki/Coins_of_the_United_States_dollar ;-)
class Change
def change(amount)
available_coins = [100,50,25,10,5,1] # http://en.wikipedia.org/wiki/Coins_of_the_United_States_dollar
coins = []
index = 0
coin = available_coins[index]
remaining_amount = amount
until remaining_amount == 0
until remaining_amount >= coin
index = index + 1
@LogaJ
LogaJ / gist:bfae1f94ebce63d6a3519308000328a9
Created September 19, 2018 14:07 — forked from unnitallman/gist:944011
sqlite with activerecord outside rails
require 'active_record'
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.colorize_logging = false
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:dbfile => ":memory:"
)
<h2><%= plural_table_name.titleize %></h2>
<p id="notice"><%%= notice %></p>
<hr>
<div>
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
<div class="content">
<% attributes.reject(&:password_digest?).each do |attribute| -%>

Git Cheat Sheet

Basic commands

git init Creates a new git repository in the directory

git add <file name> Adds a specific file to staging

git add . or git add -A Adds the full directory and its contents to staging

@LogaJ
LogaJ / curl.md
Created May 24, 2018 14:55 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@LogaJ
LogaJ / index.md
Last active October 19, 2017 11:42 — forked from rstacruz/index.md
Cheatsheet for Rails models

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@LogaJ
LogaJ / ruby_global_vars.rb
Last active October 19, 2017 11:44
What do all those funny '$' consts mean?
http://jimneath.org/2010/01/04/cryptic-ruby-global-variables-and-their-meanings.html
------------incase the link above stops working---------------------
Environmental Global Variables
$: (Dollar Colon)
$: is basically a shorthand version of $LOAD_PATH. $: contains an array of paths that your script will search through when using require.
@LogaJ
LogaJ / recursion_play.rb
Created May 24, 2013 23:26
Recursion play
def append(ary, n)
return ary if n < 0
return append((ary.push n), n-1)
end
appended = append [], 2
puts appended.inspect # => [2, 1, 0]
def prepend(ary, n)
return ary if n < 0