Skip to content

Instantly share code, notes, and snippets.

View etherealite's full-sized avatar

Etherealite etherealite

View GitHub Profile
@etherealite
etherealite / sample.rb
Created December 25, 2012 10:57
Single query solution to finding nearest donees with matching timeslots
def donees_in_radius_with_timeslots(radius)
required_bits = 2**User.valid_roles.index(:donee)
Location.near(self.location,
radius,
:select => "locations.*, users.*, time_slots.*"
).joins(:user => :time_slots)
.where(["roles_mask & ? > 0", required_bits])
.where(["roles_mask & ? > 0", required_bits])
end
@etherealite
etherealite / input.ini
Last active August 29, 2015 14:04
League of Legends easy simultaneous access keybings
; Based on Ideas from a post on the League of Legends subreddit
; http://www.reddit.com/r/leagueoflegends/comments/1bo2nk/guide_to_easy_kiting_left_click_attack/
[HUDEvents]
evtHoldShowScoreBoard=[`]
; camera
evtSelectAlly4=[Shift][z]
evtSelectAlly2=[Shift][x]
// parsing http request authorization body
https://regex101.com/r/bO7vG8/5
let pat = /([^=,\s]*)\s*=\s*["'\s]?([^,"]+)["'\s]?/gi;
let WWW-Authenticate =`Digest username="sdfa", realm="dggrs", nonce="0.9645404655020684 ", `+
`uri="/", response="27d9d30c793867d9db15cc69145a72bd", opaque="undefined", qop=auth, `+
`nc=00000001, cnonce="fa56655dc694e1a0"`
@etherealite
etherealite / rate_limits.rb
Created January 17, 2016 22:53 — forked from jeffrafter/rate_limits.rb
Handle Shopify API rate limits
# https://docs.shopify.com/api/introduction/api-call-limit
module ActiveResource
# 429 Client Error
class RateLimitExceededError < ClientError # :nodoc:
end
class Connection
RATE_LIMIT_SLEEP_SECONDS = 20 # number of seconds to sleep (by sleeping 20 you reset the clock to get 40 fresh burst calls with the default 2 calls/sec)
const fs = require('fs');
const file = fs.readFileSync('contacts.rtf', 'utf8');
const matches = file.match(/\n[a-z ]+.* 0 Y(?:\n.+)+/gi);
const contacts = matches.map(match => {
const lines = match.split("\n");
const contact = Object.create({});
import random, inspect
def func_a():
if bool(random.getrandbits(1)):
func_b()
else:
func_c()
def func_b():
@etherealite
etherealite / line-item.json
Created July 4, 2022 07:01
Shopify Notification email sample line-item
{
"id":866550311766439020,
"title":"Enlighten Tourmaline Stone Stretch Bracelet",
"price":"40.00",
"line_price":"40.00",
"quantity":1,
"sku":"BrSBMulStoStr",
"grams":26,
"properties":[
@etherealite
etherealite / product_properties.json
Created July 4, 2022 07:24
Sample of Shopify Cart Product Property key value pairs
[
[
"Customize the Message",
"asfdsf"
],
[
"Delivery Deadline",
"adfasdf"
],
[
@etherealite
etherealite / inventoryadjustment.gql
Created August 7, 2022 19:59
Shopify Inventory Adjustment
query InventoryAdjustments($first: Int, $last: Int, $after: String, $before: String, $locationId: ID, $variantId: ID) {
location(id: $locationId) {
id
name
__typename
}
inventoryHistory(
first: $first
last: $last
after: $after