Skip to content

Instantly share code, notes, and snippets.

View tbjers's full-sized avatar
🙃

Torgny Bjers tbjers

🙃
View GitHub Profile
@tbjers
tbjers / wordpress.rb
Created August 14, 2012 22:11
Version of migrators/wordpress.rb adapted for Jekyll-Bootstrap
require 'rubygems'
require 'sequel'
require 'fileutils'
require 'yaml'
# NOTE: This converter requires Sequel and the MySQL gems.
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
# installed, running the following commands should work:
# $ sudo gem install sequel
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
@tbjers
tbjers / qrcode_tag.rb
Created August 15, 2012 04:06
Xorcode QR tag for Google Play items
require 'cgi'
module Xorcode
module Liquid
class QrCodeTag < ::Liquid::Tag
def initialize(tag_name, id, tokens)
@url = "https://market.android.com/details?id=#{id.strip}"
super
end
@tbjers
tbjers / Rakefile
Created August 15, 2012 14:51
Adding a production flag to Jekyll-Bootstrap and jekyll itself
desc "Deploy to production environment"
task :deploy do
require 'net/scp'
system "rm -Rf ./_site"
system "jekyll --production --no-auto --no-future"
username = ask("Username: ", nil) { |q| q.echo = true }
system "rsync --progress --stats --compress --recursive --times --links --delete --force ./_site/ #{username}@xorcode.com:/home/xorcode.com/_site/"
end # task :deploy
@tbjers
tbjers / bitly_filter.rb
Created August 15, 2012 17:53
Liquid Filter to convert URLs to short URLs automatically
require 'bitly'
module Jekyll
class BitlyFilterCache
def initialize
@result_cache = {}
config = Jekyll.configuration({})
@username = config['bitly']['username']
@key = config['bitly']['api_key']
Bitly.use_api_version_3
@tbjers
tbjers / backup.sh
Created August 22, 2012 23:10
Round Robin MongoDB backups to S3 with Tar
#!/bin/sh
#Change these settings to match your system
ACCESS_KEY='YOUR_ACCESS_KEY'
ACCESS_SECRET='YOUR_SECRET_KEY'
BUCKET="YOUR_BUCKET_NAME"
DATABASE="YOUR_DATABASE_NAME"
# Do not change anything below this line
tool=`which s3multiput s3cmd`
@tbjers
tbjers / menu.js
Created September 3, 2012 17:12
Express resources with authentication middleware
module.exports = {
menu: {
'wall': { title: 'Wall', name: 'wall' },
'logs': { title: 'Logs', name: 'logs', submenu: {
'system': { title: 'System', name: 'system' }
} },
'stats': { title: 'Stats', name: 'stats' },
'admin': { title: 'Admin', name: 'admin', submenu: {
'users': { title: 'Users', name: 'users' },
'grants': { title: 'Grants', name: 'grants' }
1 leek plant
1 bushel of asparagus
2 cups veggie broth
1 table spoon Butter
1 table spoon olive oil
Salt & pepper
First cut leek and asparagus into smaller less then 2 inch pieces.
Melt butter with olive oil
@tbjers
tbjers / check-apache-instances.sh
Last active April 6, 2023 18:25
Script to determine Apache ServerLimit and MaxClients.
#!/bin/sh
available=$(free --mega -tw | grep "Total:" | awk '{print $4}')
ps -ylC httpd --sort:rss | awk -v avail="$available" '{ s += $8; } END { print "Average Size:", s/(NR-1)/1024, "MB,", NR-1, "Processes, Total usage:", (s/(NR-1)/1024)*(NR-1), "MB, Max Servers:", avail/(s/(NR-1)/1024) }'
@tbjers
tbjers / .gitconfig
Created March 21, 2013 17:51
git aliases I cannot live without...
[alias]
st = status
ci = commit
br = branch
co = checkout
df = diff
sync = !sh -c 'git pull && git diff --quiet HEAD || (git commit $1 && git push)' -
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
edit-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; sublime_text `f`"
add-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; git add `f`"
@tbjers
tbjers / Preferences.sublime-settings.json
Created July 7, 2013 17:26
Sublime Text user configuration
{
"font_size": 13,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"use_tab_stops": false,
"word_wrap": false,
"highlight_line": true,
"caret_style": "phase",
"match_brackets_angle": true,
"default_line_ending": "unix",