This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dir = ARGV.first || Dir.pwd | |
Dir.chdir dir unless dir == Dir.pwd | |
avi_files, srt_files = Dir.glob('*.avi'), Dir.glob('*.srt') | |
avi_files.each do |avi_file| | |
md = avi_file.match /s\d+e\d+/i | |
if md | |
srt_file = srt_files.find {|srt_file| srt_file =~ Regexp.new(md.to_s, true)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# flesystem: http://www.lacie-unlam.org:2082/getbackup/backup-lacie-unlam.org-6-10-2011.tar.gz | |
# db : http://www.lacie-unlam.org:2082/getsqlbackup/lacieunl_mysql.sql.gz | |
require "date" | |
require "net/http" | |
today = Date.today | |
backup_dir = today.strftime("%d_%m_%Y") | |
Dir.mkdir(backup_dir) unless File.directory?(backup_dir) | |
user, passwd = ENV["hosting_user"], ENV["hosting_passwd"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// c++ | |
#include <iostream> | |
#include <vector> | |
using namespace std; | |
int main() | |
{ | |
vector<int> vec; | |
vec.push_back(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
class P(object): | |
def foo(self): | |
print "Called P's foo()" | |
# print "Called %s's foo()" % self.__class__.__name__ | |
class C(P): | |
def foo(self): | |
# P.foo(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
class Queue(object): | |
def __init__(self): | |
self.arr = [] | |
def enqueue(self, val): | |
self.arr.insert(0, val) | |
def dequeue(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
class Queue | |
def initialize | |
@arr = [] | |
end | |
def enqueue(val) | |
@arr << val | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
# returns a list of 2-tuples: [('a', 'b'), ('c', 'd'), ('e', 'f')] | |
re.findall(r'([a-z])\d([a-z])\s', 'a1b c2d e3f ') | |
# returns a list of strings: ['1', '2', '3'] | |
re.findall(r'[a-z](\d)[a-z]\s', 'a1b c2d e3f ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 15-19 validate US telephone numbers with optional area code | |
# 800-555-1212, 555-1212, and also (800) 555-1212 | |
regex = re.compile(r'(\d{3}-|\(\d{3}\)\s)?\d{3}-\d{4}') | |
for s in ['800-555-1212', '555-1212', '(800) 555-1212']: | |
match = re.match(regex, s) | |
if not match: | |
print 'Error! %s should be a valid telephone number' % s | |
break | |
else: | |
print 'All telephone numbers are valid, yey!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/apt/apt.conf | |
APT::Default-Release "stable"; | |
# add the testing repos' URLs to your /etc/apt/sources.list | |
apt-get update | |
apt-get -t testing install foo | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install the building dependencies | |
sudo aptitude install libevent-pthreads-2.0-5 libao-dev gnutls-dev libmad0-dev libfaad-dev libjson0-dev | |
rm -rf ~/Soft/pianobar | |
git clone git://github.com/PromyLOPh/pianobar.git ~/Soft/pianobar | |
cd ~/Soft/pianobar | |
make | |
# all set, you can run pianobar directly from the source directory, alternatively run this command to have it installed: | |
[sudo make install] |
OlderNewer