Skip to content

Instantly share code, notes, and snippets.

@stefl
stefl / scrape_tweets.rb
Created March 25, 2012 14:47
Download all tweets from the twitter search API for a given search term (limited to their maximum of 1500)
#! /usr/bin/env ruby
require "fileutils"
search_term = ARGV[0]
if search_term
time = Time.now
directory_path = File.dirname(__FILE__) + "/tweets/" + search_term + "_" + time.to_i.to_s
FileUtils.mkdir_p(directory_path)
directory = Dir.new(directory_path)
(1..15).each do |i|
`curl "http://search.twitter.com/search.json?q=#{search_term}&rpp=100&page=#{i}&include_entities=true&result_type=mixed" > #{directory.path}/#{i}.json`
@joepie91
joepie91 / README.md
Last active October 28, 2015 04:50
Uploading to curl.io without a browser (but with a progress bar!)

Simply save the script in your home directory (as set-alias.sh or whatever else you want), and add the following to your .bashrc:

source ~/set-alias.sh

Don't forget to use the right filename if you've changed it!

Now you can just use the curlio command:

@yoni
yoni / webm2mp3.sh
Created May 3, 2013 03:32
Extract MP3 audio from all WEBM videos.
find . -name "*.webm" -exec ffmpeg -i {} -vn -ac 2 -ar 44100 -ab 320k -f mp3 {}.mp3 \;
#!/usr/bin/python
from distutils.sysconfig import get_python_lib
print get_python_lib()
@ohhdemgirls
ohhdemgirls / rename.sh
Last active January 4, 2016 10:49
Rename html files based on title tag
#!/bin/bash
# Rename the ouput html file from redditPostArchiver with the reddit thread title.
# https://github.com/sJohnsonStoever/redditPostArchiver
for f in *.html;
do
title=$( awk 'BEGIN{IGNORECASE=1;FS="<title>|</title>";RS=EOF} {print $2}' "$f" )
mv -i "$f" "${title//[^a-zA-Z0-9\._\- ]}_$f"
@xr09
xr09 / ubackup.sh
Last active January 4, 2016 20:29
Minimal rotating backup system
#!/usr/bin/bash
backup_number=8
base_name="backup.gz"
backup_path="/opt/somebackup/"
cd $backup_path
# clean any old temp backup
# Add multimedia source
echo "deb http://www.deb-multimedia.org wheezy main non-free" >> /etc/apt/sources.list
echo "deb-src http://www.deb-multimedia.org wheezy main non-free" >> /etc/apt/sources.list
apt-get update
apt-get install deb-multimedia-keyring # if this aborts, try again
apt-get update
# Go to local source directory
cd /usr/local/src
@alvinfrancis
alvinfrancis / tmux-newsbeuter-open.sh
Created August 1, 2013 10:44
newsbeuter open browser script in tmux
#!/bin/sh
shellbrowser='elinks'
tmux_current_window=`tmux display-message -p "#W"`
tmux_current_pane=`tmux display-message -p "#P"`
# Check if in the right tmux window
if [ $tmux_current_window != 'news' ];then
elinks $1
exit 0
@drakeguan
drakeguan / bootstrap_for_encoding_server.sh
Last active January 12, 2017 03:13 — forked from xdamman/install_ffmpeg_ubuntu.sh
Bash script to install latest version of ffmpeg, x264 and libvpx on Ubuntu 14.04 server
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 14.04
# Copyright @ 2014 Shuen-Huei (Drake) Guan <drake.guan@gmail.com>
# References:
# * https://gist.github.com/xdamman/e4f713c8cd1a389a5917
# * https://blog.dlasley.net/2013/05/install-ffmpeg-from-source/
# * http://fermat-little-theorem-blog.logdown.com/posts/203069-solved-when-building-gpac-suffer-usr-local-lib-libswscalea-error-adding-symbols-bad-value
@pachacamac
pachacamac / tiler.rb
Last active July 29, 2017 08:44
simple tiling script
#!/usr/bin/env ruby
# DESCRIPTION:
# This is a script to rearrange your windows like this:
# _________________________ _________________________
# | _________ | x| | | major x| minor x|
# | | major x |__| | | | |____________|
# | | | |_____| | --> | | minor x|
# | |_________| | ______ | | |____________|
# | |______|| x|| | | minor x|