Skip to content

Instantly share code, notes, and snippets.

@tpitale
tpitale / feed.xml
Created March 29, 2018 21:37
Petrolicious.com Feed
<?xml version="1.0"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>Petrolicious</title>
<link>https://staging.petrolicious.com</link>
<description>Petrolicious is a leading automotive lifestyle brand providing world class short films and tasteful editorial around the world&#x2019;s finest classic vehicles.</description>
<language>en-us</language>
<copyright>&#xA9; Petrolicious / May Moon Media 2018. All Rights reserved.</copyright>
<atom:link href="https://staging.petrolicious.com/feed" rel="self" type="application/rss+xml"/>
<item>
import Ember from 'ember';
import Utils from 'docket/utils';
import Status from 'docket/models/status';
import User from 'docket/models/user';
export default Ember.Route.extend({
activate: function() {
this._super();
// do some setup related to event_source here
},
@tpitale
tpitale / adjust-srt.rb
Created April 19, 2017 20:37
Adjust timestamps in an SRT file
adjust_by = 48 # seconds
srt = File.read(File.expand_path("~/Downloads/EN.srt"))
new_srt = srt.
split("\r\n\r\n").
map {|s| s.split("\r\n")}.
map do |i, times, *values|
new_times = times.split(" --> ").map {|t| (Time.strptime(t, "%H:%M:%S,%L") + adjust_by).strftime("%H:%M:%S,%L")}.join(" --> ")
CREATE OR REPLACE FUNCTION update_notify() RETURNS trigger AS $$
DECLARE
channel text;
BEGIN
channel := TG_ARGV[0];
NOTIFY channel;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
@tpitale
tpitale / gist:b3e19f903a0bfd825792
Created April 23, 2015 16:54
Traceroute to use.typekit.com
traceroute to gp1.wac.v2cdn.net (72.21.91.8), 64 hops max, 52 byte packets
1 10.194.112.1 (10.194.112.1) 1.668 ms 1.234 ms 1.043 ms
2 * * *
3 * * *
4 * * *
5 * * *
6 * * *
7 * * *
8 * * *
9 * * *
Required: dm-core
Is inherited public or private in A
public
Required: dm-active_model
Is inherited public or private in B
public
Required: dm-rails
Is inherited public or private in C
#!/usr/bin/env ruby
require 'trello' # ruby-trello gem
require 'csv'
#
# export TRELLO_DEVELOPER_PUBLIC_KEY=yourkeyfrom # https://trello.com/app-key
# export BOARD_NAME=nameofboardtoimportto
# export MEMBER_NAME=yourusername
@tpitale
tpitale / one_row.sql
Last active August 29, 2015 14:13
One row for each association id SQL
CREATE OR REPLACE VIEW next_episode_ids AS (
SELECT id, ROW_NUMBER() OVER(PARTITION BY show_id ORDER BY airs_on) AS r
FROM episodes
WHERE airs_on >= NOW()
);
CREATE OR REPLACE VIEW next_episodes AS (
SELECT * FROM episodes WHERE id IN (
SELECT id FROM next_episode_ids WHERE r = 1
)
@tpitale
tpitale / always_center.py
Created August 27, 2014 17:42
Center Sublime Text 2 on current line when changing
import sublime_plugin
class AlwaysCenterCommand(sublime_plugin.EventListener):
def on_modified(self, view):
sel = view.sel()
region = sel[0] if len(sel) == 1 else None
if region != None:
view.show_at_center(region)
@tpitale
tpitale / deeply_hash.rb
Created August 25, 2014 18:12
Using default proc to deeply, arbitrarily nest new Hash
# http://www.ruby-doc.org/core-1.9.3/Hash.html#method-i-default_proc-3D
h = Hash.new {|hash, key| hash[key] = Hash.new(&hash.default_proc)}
h[:foo][:bar][:baz][:bat] = "hello"
p h
#=> {:foo=>{:bar=>{:baz=>{:bat=>"hello"}}}}