Skip to content

Instantly share code, notes, and snippets.

@tpitale
tpitale / feed.xml
Created Mar 29, 2018
Petrolicious.com Feed
View feed.xml
<?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>
View application.es6
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 Apr 19, 2017
Adjust timestamps in an SRT file
View adjust-srt.rb
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(" --> ")
View notify_on_update.sql
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 Apr 23, 2015
Traceroute to use.typekit.com
View gist:b3e19f903a0bfd825792
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 * * *
View results.txt
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
View trello-cards-from-csv.rb
#!/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 Aug 29, 2015
One row for each association id SQL
View one_row.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 Aug 27, 2014
Center Sublime Text 2 on current line when changing
View always_center.py
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 Aug 25, 2014
Using default proc to deeply, arbitrarily nest new Hash
View deeply_hash.rb
# 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"}}}}
You can’t perform that action at this time.