Skip to content

Instantly share code, notes, and snippets.

@tpitale
tpitale / README.md
Last active Apr 20, 2020
Sublime Text plugin to create a simple timestamp
View README.md
  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
View gist:162954
#! /bin/sh
### BEGIN INIT INFO
# Provides: mongodb
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the mongodb data-store
# Description: starts mongodb using start-stop-daemon
@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>
@tpitale
tpitale / svg-to-vector-pdf.sh
Last active Jan 6, 2018
Loop to rsvg-convert all SVG files to Vector PDF
View svg-to-vector-pdf.sh
for i in `ls *.svg`
rsvg-convert -f pdf -o PDF/${i}.pdf $i
@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"}}}}
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 / scrollbar_example.css
Created Dec 17, 2010
Super simple scrollbars for webkit similar to iOS
View scrollbar_example.css
#sidebar ul.customers::-webkit-scrollbar {
width: 5px;
}
#sidebar ul.customers::-webkit-scrollbar-thumb:vertical {
margin: 5px;
background-color: #999;
-webkit-border-radius: 5px;
}
@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(" --> ")
@tpitale
tpitale / reel_ws_pg_example.rb
Last active Mar 23, 2017
Reel Websocket Server using PG Listen/Notify for crude pubsub
View reel_ws_pg_example.rb
require 'rubygems'
require 'bundler/setup'
require 'reel'
require 'celluloid/io'
require 'pg'
module PGNotifications
def self.included(actor)
actor.send(:include, Celluloid::IO)
end
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;
You can’t perform that action at this time.