Skip to content

Instantly share code, notes, and snippets.

View zealot128's full-sized avatar

Stefan Wienert zealot128

View GitHub Profile
@zealot128
zealot128 / README.md
Created October 18, 2011 08:08
pludoni Capistrano Deploy script

USAGE

cap deploy:setup
# will create shared dir's and symlinks for assets
#  db, log and "public/system"
cap deploy
# Let's go
@zealot128
zealot128 / install.sh
Created November 5, 2011 21:08
ubuntu apt install eee-pc
sudo su
apt-add-repository ppa:chromium-daily/ppa
apt-add-repository ppa:eee-control/eee-control
apt-add-repository ppa:ubuntu-mozilla-daily/ppa
apt-get update && sudo apt-get install build-essential eee-control vlc cpufrequtils \
powertop htop install libncurses-dev libgnome2-dev libgtk2.0-dev libatk1.0-dev \
libbonoboui2-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev git-core guake \
openssh-server chromium-browser thunderbird thunderbird-locale-de \
exuberant-ctags ack-grep python-pygments
@zealot128
zealot128 / README.md
Created December 16, 2011 21:21
Ruby - HTML Tagcloud with easy changeable formular

Tagcloud Calculation

Usage

Calculate weight of given array. e.g. %w[ruby ruby ruby rails]

Tagcloud.tagcloudize [ "rails", "ruby", "rails" ...] do |count,max|
@zealot128
zealot128 / README.md
Created December 16, 2011 21:55
Easy XML Sitemap with rails (little work involved anyway)

Sitemap XML with Rails

Rails is too custom, to provide a generic sitemap as a gem for any situation. But it ist not too hard anyway! Here is a frame how to make one:

rails g controller sitemap
@zealot128
zealot128 / drush.sh
Created March 12, 2012 23:47
Drupal 7 Installation with compass configuration
# Download latest Drupal
version="7.12"
wget http://ftp.drupal.org/files/projects/drupal-$version.tar.gz
tar xf drupal-$version.tar.gz
mv drupal-$version/.* . -f
mv drupal-$version/* .
rm drupal-$version.tar.gz -rf drupal-$version
rm *txt -f
wget http://ftp.drupal.org/files/translations/7.x/drupal/drupal-7.11.de.po -O profiles/standard/translations/drupal-7.11.de.po
chown www-data\: sites/default/ -R
@zealot128
zealot128 / imap-stats.rb
Created May 20, 2012 20:05
Imap mail statistic with Ruby
require "net/imap"
require "progressbar"
require "active_support/all" # sort_by!
class Array
def histogram ; self.sort.inject({}){|a,x|a[x]=a[x].to_i+1;a} ; end
end
server = "mailserver.com"
username = "mail@mailserver.com"
@zealot128
zealot128 / podcast-download.sh
Created July 18, 2012 15:46
Download Media Podcasts (RSS-Feed with audio/Video in enclosure)
#!/bin/bash
# Run with podcast-download.sh http://linktofeed.xml
# should work in BusyBox (my NAS is an ARM Linux with busybox)
set -e # exit when one line has error
filename="/tmp/rssdwn-$(date +%s)"
curl $1 2> /dev/null | grep enclosure | sed "s/.*\(http[^\"\?]*\).*/\1/" > $filename
echo "Found $(wc -l $filename) Links, start downloading to pwd"
@zealot128
zealot128 / download_file.rb
Created July 22, 2012 16:21
Download an URL with open-uri to paperclip
# encoding: utf-8
def download_url(url)
url.gsub!(" ","%20")
# TODO better escaping of stuff like umlauts
# url.gsub!("ö","%C3%B6")
logo_path = url.split("/").last
io = open(url)
io.define_singleton_method(:original_filename) do
logo_path
@zealot128
zealot128 / README.md
Created August 13, 2012 21:15
Debian startup file for Rails thin instances

Rails startup with bundler, rvm and specific user

e.g. for user stefan, starting two different applications, located under /apps/APPLICATION/prod/current.

This script is very useful, because it is run at startup of server, so no 503 anymore.

Put this script under /etc/init.d/ and make it executable chmod +x /etc/init.d/rails_apps

@zealot128
zealot128 / config.rb
Created November 28, 2012 21:11
Earthquake - Show replies to a tweet
# paste into ~/.earthquake/config
Earthquake.init do
command :replies do |m|
thread = [twitter.status(m[1])]
r = twitter.get "/related_results/show/#{273873995647045633}.json"
results = r.first["results"].map{|i|i["value"]}
results.reverse_each.with_index do |t,i|
t["_mark"] = config[:thread_indent] * i