Skip to content

Instantly share code, notes, and snippets.

@danhixon
danhixon / Download m3u8 video stream to file.txt
Last active May 23, 2020 15:46
Download m3u8 video stream to file
Requirements: VLC
1. Get the master.m3u8 text, use curl or Paw or just download the file and open with a text editor.
2. Find the url of the version you want
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1828000,RESOLUTION=1280x720
https://cdn.videoservice.com/services/mobile/streaming/index/rendition.m3u8?assetNumber=392392
3. Download that file.
4. Launch VLC, Choose File -> Convert/Stream from the menu
5. Drag the "rendition.m3u8" file onto that window, choose your settings and click save.
@danhixon
danhixon / string-truncate.swift
Last active March 6, 2017 22:58 — forked from carlhunterroach/string-truncate.swift
A truncate function extension for the default String type that honors words.
extension String {
/// Truncates the string to length number of characters and
/// doesn't truncate within a word.
/// appends optional trailing string if longer
func truncate(_ length: Int, wordSeparator: String = " ", trailing: String = "…") -> String {
// only truncate if needed
if self.characters.count > length {
// count the trailing characters first
var cumulativeCharacters = trailing.characters.count
@danhixon
danhixon / permission denied in docker instance
Created February 10, 2014 22:20
getting permission denied for user even though I should have read access.
postgres@e000d37cf793:/$ groups
postgres ssl-cert
postgres@e000d37cf793:/$ ls -la /etc/ssl/
total 28
drwxr-xr-x 7 root root 4096 Feb 10 20:40 .
drwxr-xr-x 95 root root 4096 Feb 10 20:44 ..
drwxr-xr-x 2 root root 4096 Feb 10 20:40 certs
-rw-r--r-- 1 root root 10835 Jan 8 20:48 openssl.cnf
drwxr-x--- 2 root ssl-cert 4096 Feb 10 20:40 private
@danhixon
danhixon / shared_to_dev.rb
Created August 3, 2012 22:06
Migrate Heroku Shared Database to Heroku Postgres Dev Database
#
# If you've got a bunch of heroku apps running with
# shared databases and you want to migrate them to
# heroku postgres dev databases you can use this
# ruby script.
#
# USAGE:
# ruby shared_to_dev.rb app_name
#
@danhixon
danhixon / gist:1603565
Created January 12, 2012 22:28
Thinking Sphinx Monkey Patch
module ThinkingSphinx
class Source
module SQL
def type_values
['Location']
end
end
end
end
@danhixon
danhixon / folderizer
Created January 3, 2012 18:17
create yyyy-mm folders for your photos
# Depends on the command line tool: exiftool
# brew install exiftool
# it also works with mov files if they have
# exif data. I know my iPhone adds the exif
photos = Dir.glob("*.jpg",File::FNM_CASEFOLD)
photos.each do |file_path|
file_path = file_path.gsub(' ','\ ')
@danhixon
danhixon / nearby.log
Created May 30, 2011 19:10
Anybody know where I can look for what is taking long in this rails action?
Parameters: {"auth_token"=>"2Sq2-Wo4_I0PeIu_OeRR", "options"=>{"lat"=>"33.465199999999996", "lng"=>"-111.92419833333334", "of_each"=>"15"}}
Geokit is using the domain: localhost
Location Load (9.5ms) SELECT locations.*, distance(coordinates, ST_GeomFromText('POINT(33.4657 -111.9229)')) distance FROM "locations" WHERE (nearby_categories & 1 <> 0) AND (coordinates && Expand( ST_GeomFromText('POINT(33.465199999999996 -111.92419833333334)'), 0.005)) ORDER BY distance ASC LIMIT 50 OFFSET 0
Location Load (3.5ms) SELECT locations.*, distance(coordinates, ST_GeomFromText('POINT(33.4657 -111.9229)')) distance FROM "locations" WHERE (nearby_categories & 2 <> 0) AND (coordinates && Expand( ST_GeomFromText('POINT(33.465199999999996 -111.92419833333334)'), 0.005)) ORDER BY distance ASC LIMIT 50 OFFSET 0
Location Load (3.4ms) SELECT locations.*, distance(coordinates, ST_GeomFromText('POINT(33.4657 -111.9229)')) distance FROM "locations" WHERE (nearby_categories & 4 <> 0) AND (coordinates && Expand( ST_GeomFromText
module Paperclip
class Cropper < Thumbnail
def transformation_command
if crop_command
cmd = crop_command + super.join(" ").sub(/ -crop \S+/, '')
cmd.split(" ")
else
super
end
end
class Auction
# is categorized once or twice
# with a primary_category_id and a secondary_category_id
# there is a Category class that acts_as_tree
# this scope will select duplicates if auction
# is categorized with a "brother" category because
# it has two categorizations included in the query
named_scope :in_category, lambda { |category_id|
{ :joins =>
to reconnect to screen session:
screen -r
to exit screen session:
Ctrl+a, d
to kill screen session:
Ctrl+a, k