Skip to content

Instantly share code, notes, and snippets.

@idl3
idl3 / binary_tree.rb
Created December 31, 2020 09:04
Acing Google Coding Interview as an 18 year old High School Student
### Ruby representation of coding interview from https://www.youtube.com/watch?v=-tNMxwWSN_M&feature=youtu.be
### Acing Google Coding Interview as an 18 year old High School Student
class Node
attr_reader :value
attr_accessor :left, :right, :number_of_nodes_in_subtree
def initialize(value)
@value = value
@left = nil
@idl3
idl3 / deployment_preparation
Last active April 17, 2019 05:47
Prepare branches for deployment
#/bin/sh
INSTALL_PATH="/usr/local/bin"
BASE_DIR=`pwd`
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
CHECK_MARK="\033[0;32m\xE2\x9C\x94\033[0m"
if [ ! -f "$BASE_DIR/bin/preflight" ]; then
printf '%s\n' "This command can only be run in the Grain base project"
exit;
fi
@idl3
idl3 / rangeArray.js
Last active April 8, 2019 04:48
Range accessible array in Javascript
var obj = new Proxy([1,2,3,4,5,6,7,8], {
get: function(target, name) {
if (name.indexOf("..") && (range = name.split("..")) && range.length == 2) {
[startRange, endRange] = range;
if (endRange[0] == '-') {
if (parseInt(endRange) == '-1') {
endRange = Infinity;
} else {
endRange = parseInt(endRange) + 1;
}
@idl3
idl3 / change_project.zsh
Last active April 5, 2019 11:51
Quick project changer
BASE_DIR=~/Code
function changeProject(){
if [[ -z $1 ]]; then
cd $BASE_DIR
else
if [ -d $BASE_DIR/$1 ]; then
cd $BASE_DIR/$1
else
select d in $BASE_DIR/*/ "Exit"; do
case $d in
@idl3
idl3 / remove_exited_docker_containers
Created March 4, 2018 08:24
Delete all Exited docker containers
docker ps -a | grep Exited | awk '{print $1}' | xargs docker rm
@idl3
idl3 / googlecal.rb
Last active April 3, 2018 04:31
Service object for Google Cal
class GoogleCalendarClient
def self.calendar_service(user_id)
service = Google::Apis::CalendarV3::CalendarService.new
service.authorization = GoogleCalendarClient.client.get_credentials(user_id)
service
end
def self.authorization_url
client.get_authorization_url(base_url: GOOGLE_OOB_URI)
end
@idl3
idl3 / symbol-bench.rb
Created June 19, 2017 04:58
Symbol array check benchmark
require "benchmark"
puts Benchmark.measure {
count = 0
1000000.times do |i|
postal = '%06d' % rand(999999)
count += 1 if %w!01 02 03 04 05 06 07 08 17 22 23!.include?(postal[0..1])
end
}
@idl3
idl3 / keybase.md
Created June 15, 2016 02:48
Keybase

Keybase proof

I hereby claim:

  • I am idl3 on github.
  • I am ernestcodes (https://keybase.io/ernestcodes) on keybase.
  • I have a public key whose fingerprint is 2377 DC8B E5DA 7B2F E9FC 8B16 324B AC93 662C 05BD

To claim this, I am signing this object:

@idl3
idl3 / advent_of_code.rb
Created January 11, 2016 08:51
Advent of Code answers :P Didn't complete but it was fun :)
# Advent of Code
# Challenge 1/2
input = "(((())))()((((((((())()(()))(()((((()(()(((()((()((()(()()()()()))(((()(()((((((((((())(()()((())()(((())))()(()(()((()(()))(()()()()((()((()(((()()(((((((()()())()((((()()(((((()(())()(())((())()()))()(((((((())(()())(()(((())(()))((())))(()((()())))()())((((())))(()(((((()(())(((()()((()((()((((((((((())(()())))))()))())()()((((()()()()()()((((((())())(((()())()((()()(((()()()))(((((()))(((()(()()()(()(()(((())()))(()(((()((())()(()())())))((()()()(()()(((()))(((()((((()(((((()()(()())((()())())(()((((((()(()()))((((()))))())((())()()((()(()))))((((((((()))(()()(((())())(())()((()()()()((()((()((()()(((())))(()((())()((((((((()((()(()()(((())())())))(())())))()((((()))))))())))()()))()())((()())()((()()()))(()()(((()(())((((())())((((((((()()()()())))()()()((((()()))))))()((((()(((()))(()()())))((()()(((()))()()())())(((())((()()(())()()()(((())))))()())((()))()))((())()()())()())()()(()))())))())()))(())((()(())))(()(())(()))))(()(())())(()(())(()(()))))((()())()
@idl3
idl3 / braintree-with-callback-2.6.0.js
Created March 6, 2015 02:06
Braintree 2.6.0 with Callback
/*!
* Braintree End-to-End Encryption Library
* https://www.braintreepayments.com
* Copyright (c) 2009-2014 Braintree, a division of PayPal, Inc.
*
* JSBN
* Copyright (c) 2005 Tom Wu
*
* Both Licensed under the MIT License.
* http://opensource.org/licenses/MIT