Skip to content

Instantly share code, notes, and snippets.

@jmtame
jmtame / vanilla-js-cheatsheet.md
Created January 17, 2023 22:10 — forked from thegitfather/vanilla-js-cheatsheet.md
Vanilla JavaScript Quick Reference / Cheatsheet
@jmtame
jmtame / midiconvars.txt
Created April 22, 2022 23:25
rust_midiconvars
midiconvar.enabled 1
midiconvar.debugmode true
#bank1
midiconvar.bindknob 6 6 camspeed 0 1
midiconvar.bindknob 10 1 camlookspeed 0 1
midiconvar.bindknob 14 1 camzoomspeed 0 1
midiconvar.bindknob 18 1 camlerp 0 1
midiconvar.bindknob 22 1 env.cloudrotation 0 360
@jmtame
jmtame / keyboard_remap.ahk
Last active April 10, 2022 16:02
autohotkey script for microsoft keyboard to use macos-like keyboard layout
; I use a Microsoft Sculpt Ergonomic Keyboard because they're great keyboards.
; The problem is: I don't like Windows shortcuts. I like how the MacOS shortcuts work.
; I also don't like Mac keyboards because they're not ergonomic.
; This script remaps the keys on a Microsoft keyboard to behave more like a Mac keyboard.
SC044:: ; f10
SoundSet, +1,, Mute
return
SC057:: ; f11
@jmtame
jmtame / tricks.rb
Last active August 29, 2015 14:21
cool tricks in ruby
# Very fast way to determine if a string contains all unique characters
# Space O(1), Time O(N)
# Assumes ASCII strings. Unicode would require space of Array.new(1,111,998).
def is_unique(str)
return false if str.length > 256
chars = Array.new(256)
str.each_byte.lazy.each do |c|
return false if chars[c]
chars[c] = true
end
@jmtame
jmtame / batch.rb
Last active August 29, 2015 14:11
batch parallel processing
jobs_per_process = 100
process_count = 20
HolidayCampaignBidLapse.where('user_id % 2 = 0').where(sent: false).find_in_batches(batch_size: jobs_per_process * process_count) do |group|
batches = group.in_groups(process_count)
batches.each do |batch|
Process.fork do
ActiveRecord::Base.establish_connection
batch.each do |campaign|
@jmtame
jmtame / queue.rb
Last active August 29, 2015 14:11
multithread queue
# --- FILL
sqs = AWS::SQS.new(S3)
queue = sqs.queues.create('holiday')
i = 0
send = lambda { |start, finish|
HolidayCampaign.even.unsent.find_in_batches(batch_size: 10, start: start) do |batch|
users = batch.collect { |hc| "#{hc.id.to_s}||#{hc.user_id.to_s}||#{hc.name}" }
queue.batch_send(users)
@jmtame
jmtame / gist:6458832
Last active March 26, 2018 07:49
ruby blocks and yield explained by a bloc mentor

The following is an explanation of Ruby blocks and yield by another Bloc mentor (Adam Louis) who was trying to explain it to one of his students.

On my very first day programming, if someone asked me for "the sum of the numbers from 1 to 10", I'd have written:

puts 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10

Easy enough.

@jmtame
jmtame / office_hours.rb
Created September 10, 2012 09:08
office_hours.rb
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'mechanize'
require '~/Desktop/auth.rb'
agent = Mechanize.new
page = agent.get("http://news.ycombinator.com/newslogin?whence=news")
# Create the session
@jmtame
jmtame / peets.js
Created August 12, 2012 02:45
circumvent peet's wifi password screen
// a work in progress... so far it runs, but i need to let it run longer to test.
// memoizing would be good for the passcodes
// to test this yourself, see instructions to inject jquery offline: http://jmtame.posterous.com/inject-jquery-offline
var element1 = document.createElement("script");
element1.src = "chrome-extension://aaaaaaaaaaaaaaaaabbbbbbbbbbbbbbcccccccccccc/jquery.min.js"; // update this manually
element1.type="text/javascript";
document.getElementsByTagName("head")[0].appendChild(element1);
var el = document.createElement("iframe");
@jmtame
jmtame / groovesharkdj.user.js
Created November 3, 2011 09:41
Greasemonkey script to allow skipping of current Grooveshark song
// ==UserScript==
// @name Grooveshark Song Skipper
// @description Allows anyone in the same room as you to remotely skip the song playing on Grooveshark
// @author Jared Tame
// @version 1.0
// @include http://grooveshark.com/*
// @include http://retro.grooveshark.com/*
// ==/UserScript==
/*! jQuery v1.6.4 http://jquery.com/ | http://jquery.org/license */