Skip to content

Instantly share code, notes, and snippets.

@tpitale
tpitale / convert_sf_id.js
Last active August 29, 2015 14:05
Javascript from salesforce id converter to add suffix characters.
function convertId(id) {
if (id == null) return id;
id = id.replace(/\"/g, '');
if (id.length != 15) {
return null;
}
var suffix = "";
for (var i = 0; i < 3; i++) {
var flags = 0;
for (var j = 0; j < 5; j++) {
@tpitale
tpitale / README.md
Last active November 2, 2022 19:59
Sublime Text plugin to create a simple timestamp
  1. Go to Tools > New Plugin
  2. Paste timestamp.py contents and save in User as timestamp.py
  3. Open Preferences > Key Bindings - User (or Default, your call)
  4. Paste keybindings.json, or add a line to your keybindings
  5. Customize the keyboard shortcut to your liking and save

Keybase proof

I hereby claim:

  • I am tpitale on github.
  • I am tpitale (https://keybase.io/tpitale) on keybase.
  • I have a public key whose fingerprint is 6C17 F481 4889 B9AD 61EC 7719 A2EA 6E3E FD48 2FE3

To claim this, I am signing this object:

@tpitale
tpitale / errors_test.js
Created July 6, 2014 18:38
Failing test for conflict between Errors.content and a model attribute named content
// Added to the bottom of tests/unit/model/errors_test.js
var env, store, Person, Dog;
module("unit/model/errors - model.save() triggers errors", {
setup: function() {
Person = DS.Model.extend({
firstName: DS.attr(),
lastName: DS.attr()
});
@tpitale
tpitale / gist:93428db182dd44ec52e5
Created June 11, 2014 03:50
SideBarEnhancement for ST2
import os; path=sublime.packages_path(); (os.makedirs(path) if not os.path.exists(path) else None); window.run_command('exec', {'cmd': ['git', 'clone', 'https://github.com/titoBouzout/SideBarEnhancements', 'SideBarEnhancements'], 'working_dir': path})
import os; path=sublime.packages_path(); window.run_command('exec', {'cmd': ['git', 'checkout', '37429739a0452a2dc36343fb7875ba7fcbeb88a9'], 'working_dir': os.path.join(path, 'SideBarEnhancements')})
@tpitale
tpitale / data.tsv
Created May 29, 2014 15:23
Minimally responsive (flexible width) D3 Bar Chart
letter frequency
A .08167
B .01492
C .02782
D .04253
E .12702
F .02288
G .02015
H .06094
I .06966
@tpitale
tpitale / wait_for_notify.rb
Last active August 29, 2015 14:01
Implementation of wait_for_notify with PG and Celluloid::IO
def wait_for_notify(&block)
io = pg_connection.socket_io
while @listening do
Celluloid::IO.wait_readable(io) # blocks execution, but unblocks this actor
pg_connection.consume_input # fetch any input on this connection
# read the NOTIFY messages off the socket
while notification = pg_connection.notifies do
block.call(
@tpitale
tpitale / spec_helper.rb
Created May 24, 2014 01:31
Disable "should" syntax
RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = :expect
end
end
# connection and profile selection skipped
class Pageview
extend Legato::Model
metrics :pageviews
dimensions :pagePath, :date
filter :for_path, &lambda { |path| contains(:pagePath, path) }
end
@tpitale
tpitale / too_clever.rb
Created March 29, 2014 18:10
Chained enumerable and block arg destructuring
[1,2,3,4,5].each_cons(2).each_with_index do |(a, b), i|
p a
p b
p i
end