Skip to content

Instantly share code, notes, and snippets.

View karmiclychee's full-sized avatar

Jayml Mistry karmiclychee

  • Seattle, WA
View GitHub Profile
@karmiclychee
karmiclychee / setup.sh
Created February 23, 2021 00:21
EC2 Mongo/Redis Setup Sequence
wget -qO - https://www.mongodb.org/static/pgp/server-4.0.asc | sudo apt-key add -'
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list'
wget https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem'
sudo apt update'
sudo apt install -y mongodb-org=4.0.21 mongodb-org-server=4.0.21 mongodb-org-shell=4.0.21 mongodb-org-mongos=4.0.21 mongodb-org-tools=4.0.21'
sudo apt install -y redis'
@karmiclychee
karmiclychee / blocks_procs_lambdas.rb
Last active February 23, 2021 00:22
Blocks, procs, and lambdas
# will explode at the yield if no block is provided
def with_implicit_block(a, b)
yield(a + b)
end
# does nothing if block isn't present
def with_implicit_block_safe(a, b)
yield(a + b) if block_given?
end

Keybase proof

I hereby claim:

  • I am karmiclychee on github.
  • I am karmiclychee (https://keybase.io/karmiclychee) on keybase.
  • I have a public key ASDJLocZJC5RAFQ_x6fJqzHRgl_aerDHwNHCWT03APXuOgo

To claim this, I am signing this object:

public int find(int p) {
if (p < 0 || p >= id.length) throw new IndexOutOfBoundsException();
while (p != id[p]) {
id[p] = id[id[p]]; // path compression by halving
p = id[p];
}
return p;
}
@karmiclychee
karmiclychee / lulz.rb
Last active December 29, 2015 01:39
lulz
class Rubyists
def self.do
puts yield
end
end
def you(block)
block.call
end
class NumberCruncher
def initialize(input)
@initial_string = input
end
def crunch(working=@initial_string)
p working = working.to_s
sum = working.split('').map(&:to_i).inject(:+)
sum <= 9 ? p(sum.to_s) : crunch(sum)
@karmiclychee
karmiclychee / stacktrace.js
Created June 22, 2013 20:48
Ember stacktrace
Uncaught TypeError: Object function () {
var Class = makeCtor(), proto;
Class.ClassMixin = Mixin.create(this.ClassMixin);
Class.PrototypeMixin = Mixin.create(this.PrototypeMixin);
Class.ClassMixin.ownerConstructor = Class;
Class.PrototypeMixin.ownerConstructor = Class;
reopen.apply(Class.PrototypeMixin, arguments);
def authenticate_user
if authenticate_with_access_token { |t, o| User.all.exists?(access_token: t) }
current_user = User.find_by_access_token(t)
elsif authenticate_with_http_basic { |email, p| Users.all.authenticate(e, p) }
current_user = User.find_by_email(e)
else
head :unauthorized
end
end
require 'test_helper'
class Api::Beta::UsersControllerTest < ActionController::TestCase
def setup
for i in 1..100 do
FactoryGirl.create(:user)
end
@user = FactoryGirl.create(:user)
end
require 'tweetstream'
require 'pry'
require 'pry-debugger'
# TweetStream.configure do |config|
# config.consumer_key = 'abcdefghijklmnopqrstuvwxyz'
# config.consumer_secret = '0123456789'
# config.oauth_token = 'abcdefghijklmnopqrstuvwxyz'
# config.oauth_token_secret = '0123456789'