Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
#
# Ruby script to download a number of files
# from individual URLs via HTTP/HTTPS/FTP
# specified in an external file.
#
# Author: Tobias Preuss
# Revision: 2013-04-18 16:26 +0100 UTC
# License: Creative Commons Attribution-ShareAlike 3.0 Unported

Convert file names to lowercase

$> for i in $(find . -type f -name "*[A-Z]*"); do mv "$i" "$(echo $i | tr A-Z a-z)"; done

Replace hyphen with underbar in all files

$> for i in $(find . -type f -name "*[a-z]*"); do mv "$i" "$(echo $i | tr '-' '_')"; done

Backup via rsync

$ rsync -rt --delete --delete-excluded --links \
--exclude-from '/home/user/rsync-home-exclude.txt' /home/user/ server:/backups/home

How to mount an encrypted home partition?

First add the passphrase

$ sudo ecryptfs-add-passphrase --fnek

Which gets me the following information:

Inserted auth tok with sig [aaaaaaaaaaaaaaaa] into the user session keyring

#!/usr/bin/env python
import scraperwiki
import requests
import lxml.html
from collections import namedtuple
from datetime import datetime
/*
* The plugins used for this build.
*/
/*
* Provides the compile, test, jar, etc tasks
*/
apply plugin: 'java'
/*
* Generates the Eclipse project files.
@saipe
saipe / .gitignore
Last active August 29, 2015 14:17 — forked from johnjohndoe/.gitignore
build
node_modules
.DS_Store

#GDG Android in Berlin brainstorming session


On November 27, 2013 I was asking the brilliant Android developers at GDG Android in Berlin for their favorite libraries that make their lives easier and should be included in every newly developed app.

This is the list of libraries we collected during this 10 minute session.

Architecture

require 'addressable/uri'
# Source: http://gist.github.com/bf4/5320847
# Accepts options[:message] and options[:allowed_protocols]
# spec/validators/uri_validator_spec.rb
class UriValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
uri = parse_uri(value)
if !uri
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render json: user.as_json(auth_token: user.authentication_token, email: user.email), status: :created
return
else