Skip to content

Instantly share code, notes, and snippets.

@riyad
riyad / Gemfile
Created February 23, 2011 10:56
How to setup your Rails app for using the declarative_authorization gem
source 'http://rubygems.org'
gem 'rails', '3.0.3'
...
gem 'declarative_authorization'
group :development do
# for the graphical overview over your rules
# available at /authorization_rules
@riyad
riyad / bootstrap_breadcrumbs_builder.rb
Created February 28, 2012 17:38
How to make breadcrumbs_on_rails render a Bootstrap compatible breadcrumb navigation
# The BootstrapBreadcrumbsBuilder is a Bootstrap compatible breadcrumb builder.
# It provides basic functionalities to render a breadcrumb navigation according to Bootstrap's conventions.
#
# BootstrapBreadcrumbsBuilder accepts a limited set of options:
# * separator: what should be displayed as a separator between elements
#
# You can use it with the :builder option on render_breadcrumbs:
# <%= render_breadcrumbs :builder => ::BootstrapBreadcrumbsBuilder, :separator => "&raquo;" %>
#
# Note: You may need to adjust the autoload_paths in your config/application.rb file for rails to load this class:
@riyad
riyad / application_helper.rb
Created May 23, 2012 13:45
Render Rails assets to string
module ApplicationHelper
# thanks to http://blog.phusion.nl/2011/08/14/rendering-rails-3-1-assets-to-string/
# you may need to change the owner of the tmp/cache/* directories to the web servers user
# e.g. for Debian systems: `chown -R www-data:www-data tmp/cache/*`
def render_asset(asset)
Conferator::Application.assets.find_asset(asset).body.html_safe
end
end
@riyad
riyad / gitlab_config_changer.sh
Created December 15, 2012 00:47
Automatically change GitLab's configs for https://github.com/gitlabhq/gitlabhq/pull/2247
#!/bin/bash
for f in `grep -rl Gitlab.config app config features lib spec`
do
for c in `cat gitlab_config_keys.list`
do
mv $f $f.bak
perl -pe $c $f.bak > $f
rm -f $f.bak
done
@riyad
riyad / ffmpeg-mp3-converter.rb
Last active November 17, 2018 22:14
Small scripts to transcode any file VLC or ffmpeg can play to mp3.
#!/usr/bin/env ruby -rubygems
#
# Author: Riyad Preukschas <riyad@informatik.uni-bremen.de>
# License: Mozilla Public License 2.0
#
# Transcode any file ffmpeg can play to mp3.
require 'optparse'
require 'shellwords'
@riyad
riyad / chrome-unsafe.plugin.zsh
Last active January 28, 2021 14:33
Open a Chrome window with a temporary profile and several security checks disabled.
#
# Author: Riyad Preukschas <riyad@informatik.uni-bremen.de>
# License: Mozilla Public License 2.0
#
# Loads an unsafe (i.e. with several security features disabled) instance of
# Chrome with a temporary profile (i.e. all data is lost once Chrome is closed)
chrome-unsafe() {
# for Homebrew Cask (see http://caskroom.io/) compatibility
local -a CHROME_PATHS
@riyad
riyad / magicdict.py
Last active November 17, 2018 22:32
MagicDict
# -*- coding: utf-8 -*-
#
# Author: Riyad Preukschas <riyad@informatik.uni-bremen.de>
# License: Mozilla Public License 2.0
#
from collections import defaultdict
class MagicDict(defaultdict):
@riyad
riyad / sync-to-from
Last active December 18, 2022 15:57
Synchronize directories between computers using rsync (and SSH)
#!/usr/bin/env python3
#
# Author: Riyad Preukschas <riyad@informatik.uni-bremen.de>
# License: Mozilla Public License 2.0
#
# Synchronize directories between computers using rsync (and SSH).
#
# INSTALLATION:
# Save this script as something like `sync-to` somewhere in $PATH.
# Link it to `sync-from` in the same location. (i.e. `ln sync-to sync-from`)
@riyad
riyad / android-backup.md
Last active November 22, 2018 11:35
Backup and Restore your Android Phone With ADB

Android-Backup

NOTE: this project has moved to https://github.com/riyad/android-backup

Backup and restore your Android phone with ADB (and rsync)

It will backup and restore all of your /sdcard directory and any other storage (e.g. an external SD Card) mounted within /storage except for emulated and self). Assuming you're using also something like Titanium Backup you'll be able to backup and restore all your apps, settings and data.

@riyad
riyad / bottle_plugin_lifecycle_tester.py
Created July 5, 2015 12:13
Bottle Plugin Lifecycle Test
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import bottle
import logging
logger = logging.getLogger(__name__)
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.DEBUG)