Skip to content

Instantly share code, notes, and snippets.

View tuxido-feynman's full-sized avatar

tuxido-feynman tuxido-feynman

  • San Francisco, CA
View GitHub Profile
@tuxido-feynman
tuxido-feynman / global_count.rb
Created February 26, 2013 05:16
Ruby Singleton... not that exciting
#Singleton class for interview practice
require 'singleton'
class InterviewSingleton
include Singleton
def iterate
@iterator ? @iterator += 1 : @iterator = 0
end
@tuxido-feynman
tuxido-feynman / array_first_index.rb
Last active December 14, 2015 05:29
Wouldn't it be great if you could get the first element of an array in O(logn) ? Well in Ruby you can with .index... but if you couldn't, here's what I'd do.
class Array
def first_index(x)
key = x
f = 0
b = self.size
mid = get_mid(f,b)
until f == (b - 1) || f == b
self[mid] < key ? f = mid : b = mid
@tuxido-feynman
tuxido-feynman / gist:2f34b16be87a7ed6a68d2e54ef9ab8f5
Created April 23, 2019 21:37
Transform Shopify string json fields for Algolia
import json
from algoliasearch import algoliasearch
APP_ID = 'MY_APP_ID'
API_ETL_KEY = 'API_KEY_WITH_BROWSE_AND_WRITE_ACCESS'
BROWSE_INDEX_NAME = 'MY_SHOPIFY_INDEX_NAME'
WRITE_INDEX_NAME = 'MY_NEW_SHOPIFY_INDEX_NAME'
BATCH_SIZE = 10
LOCALE = 'en_CA'
package linkedlistsingle
import "fmt"
type node struct {
Next *node
Value int
}
//LinkedList is a data structure for storing data in nodes with references to each other