Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Stamatiou stammy

View GitHub Profile
View convert-videos.sh
#!/bin/bash
VIDEOS=~/Dropbox/_vid
find "$VIDEOS" -name '*.mp4' -exec sh -c 'ffmpeg -i "$0" -c:v libvpx -crf 10 -b:v 3000k -f webm -vf scale=-1:720 -bufsize 1500k -quality good -cpu-used 0 -qmin 10 -qmax 42 -c:a libvorbis -threads 8 "${0%%.mp4}.webm"' {} \;
find "$VIDEOS" -name '*.mp4' -exec sh -c 'ffmpeg -i "$0" -vf scale=-1:720 -quality good -cpu-used 0 -threads 8 "${0%%.mp4}_720p.mp4"' {} \;
# square video
#find "$VIDEOS" -name '*.mp4' -exec sh -c 'ffmpeg -i "$0" -c:v libvpx -crf 10 -b:v 3000k -f webm -aspect 1 -vf "scale=-1:720, crop=720:720" -bufsize 1500k -quality good -cpu-used 0 -qmin 10 -qmax 42 -c:a libvorbis -threads 8 "${0%%.mp4}.webm"' {} \;
#find "$VIDEOS" -name '*.mp4' -exec sh -c 'ffmpeg -i "$0" -aspect 1 -vf "scale=-1:720, crop=720:720" -quality good -cpu-used 0 -threads 8 "${0%%.mp4}_720p.mp4"' {} \;
exit;
View gist:8e4aa4e4911372862521
[458 pstam-blog]$ s3_website push
[info] Ignoring the extensionless_mime_type setting in /Users/stammy/code/pstam-blog/s3_website.yml. Counting on Apache Tika to infer correct mime types.
[info] Deploying /Users/stammy/code/pstam-blog/_site/* to no-www.paulstamatiou.com
[fail] Failed to upload feed/ (The website redirect location must have a prefix of 'http://' or 'https://' or '/'. (Service: Amazon S3; Status Code: 400; Error Code: InvalidRedirectLocation; Request ID: 1317F27ED7AECE65))
[fail] Failed to upload about (The website redirect location must have a prefix of 'http://' or 'https://' or '/'. (Service: Amazon S3; Status Code: 400; Error Code: InvalidRedirectLocation; Request ID: E3016510B36CBE9D))
[fail] Failed to upload feed (The website redirect location must have a prefix of 'http://' or 'https://' or '/'. (Service: Amazon S3; Status Code: 400; Error Code: InvalidRedirectLocation; Request ID: 5592047C96256EB6))
[fail] Failed to upload search (The website redirect location must have a prefix of 'htt
View gist:47886744a65276b3f176
[458 pstam-blog]$ /Users/stammy/code/jekyll/bin/jekyll build --watch --trace
Configuration file: /Users/stammy/code/pstam-blog/_config.yml
Source: .
Destination: ./_site
Generating...
Liquid Exception: comparison of Jekyll::Document with Jekyll::Document failed in photos/index.html
/Users/stammy/code/jekyll/lib/jekyll/filters.rb:215:in `sort': comparison of Jekyll::Document with Jekyll::Document failed (ArgumentError)
from /Users/stammy/code/jekyll/lib/jekyll/filters.rb:215:in `sort'
from /Users/stammy/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/liquid-2.5.5/lib/liquid/strainer.rb:43:in `invoke'
from /Users/stammy/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/liquid-2.5.5/lib/liquid/context.rb:75:in `invoke'
View gist:c6d8a632617b9fdb0e9a
onfiguration file: /Users/stammy/code/pstam-blog/_config.yml
Source: .
Destination: ./_site
Generating...
Liquid Exception: comparison of Jekyll::Document with Jekyll::Document failed in photos/index.html
/Users/stammy/code/jekyll/lib/jekyll/filters.rb:214:in `sort': comparison of Jekyll::Document with Jekyll::Document failed (ArgumentError)
from /Users/stammy/code/jekyll/lib/jekyll/filters.rb:214:in `sort'
from /Users/stammy/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/liquid-2.5.5/lib/liquid/strainer.rb:43:in `invoke'
from /Users/stammy/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/liquid-2.5.5/lib/liquid/context.rb:75:in `invoke'
from /Users/stammy/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/liquid-2.5.5/lib/liquid/variable.rb:50:in `block in render'
@stammy
stammy / wp_list_articles_function.php
Created Oct 29, 2008
function to list all wordpress blog entries, by month.. for archives
View wp_list_articles_function.php
<?php function list_articles(){
global $month, $wpdb, $wp_version;
$now = current_time('mysql');
if(version_compare($wp_version, '2.1', '<')){$current_posts = "post_date < '$now'";} else {$current_posts = "post_type='post'";}
$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM " . $wpdb->posts . " WHERE post_status='publish' AND $current_posts AND post_password='' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC");
if($arcresults){
foreach($arcresults as $arcresult) {
$url = get_month_link($arcresult->year, $arcresult->month);
View gist:60892
javascript:void(function(){var%20i,a,s;a=document.getElementsByTagName('link');for(i=0;i%3Ca.length;i++){s=a[i];if(s.rel.toLowerCase().indexOf('stylesheet')%3E=0&&s.href)%20{var%20h=s.href.replace(/(&|%5C?)forceReload=\d+/,'');s.href=h+(h.indexOf('?')%3E=0?'&':'?')+'forceReload='+(new%20Date().valueOf())}}})();
View submenu code
var submenuTimerId = 0;
var last_menu;
function submenuOver(id){
$(id+'_link').setStyle({zIndex:50});
$(id).appear({duration: 0.3});
clearTimeout(submenuTimerId);
if ( ( typeof( window[ 'last_menu' ] ) != "undefined" ) && !(id == last_menu) ){
submenuClose(last_menu);
}
}
@stammy
stammy / gist:91927
Created Apr 8, 2009
installing twitter_auth and it's..
View gist:91927
Aurora:skribit Paul$ script/generate twitter_auth
done loading services
The name 'User' is either already used in your application or reserved by Ruby on Rails.
Please choose an alternative and run this generator again.
Suggestions:
exploiter
drug user
substance abuser
View rewrite acts_as_taggable_on migration for apps previously using acts_as_taggable_on_steriods
class ActsAsTaggableOnMigration < ActiveRecord::Migration
def self.up
change_table :taggings do |t|
t.column :tagger_id, :integer
t.column :tagger_type, :string
t.column :context, :string
end
add_index :taggings, :context
end
View gist:103935
SELECT count(DISTINCT blogs.*) AS count_distinct_blogs_all FROM `blogs` LEFT OUTER JOIN taggings blogs_taggings ON blogs_taggings.taggable_id = blogs.id AND blogs_taggings.taggable_type = 'Blog' LEFT OUTER JOIN tags blogs_tags ON blogs_tags.id = blogs_taggings.tag_id WHERE (context = 'tags' AND blogs_tags.name LIKE 'Technology') ORDER BY created_at DESC LIMIT 0, 15