Skip to content

Instantly share code, notes, and snippets.

Change Apple OS X Dock size from Apple Terminal

defaults write com.apple.dock tilesize -int 32; killall Dock

32 is icon size

@svoboda-jan
svoboda-jan / run-puma
Created June 29, 2016 18:21
Updated heler script for Puma init script for Debian 8.5
#!/bin/bash
# on system boot, and root have no rbenv installed,
# after start-stop-daemon switched to current user, we have to init rbenv
if [ -d "$HOME/.rbenv/bin" ]; then
PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
eval "$(rbenv init -)"
elif [ -d "/usr/local/rbenv/bin" ]; then
PATH="/usr/local/rbenv/bin:/usr/local/rbenv/shims:$PATH"
eval "$(rbenv init -)"
@svoboda-jan
svoboda-jan / puma
Created June 29, 2016 16:51
Updated Puma init script for Debian 8.5
#! /bin/sh
### BEGIN INIT INFO
# Provides: puma
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
@svoboda-jan
svoboda-jan / Gemfile
Last active January 27, 2016 16:10 — forked from rkh/Gemfile
jquery-sinatra-streaming - A server-side service outputs a long response using Sinatra's streaming API.
source "http://rubygems.org/"
gem "sinatra", "~> 1.3.0"
gem "thin"
@svoboda-jan
svoboda-jan / database.yml
Created September 9, 2015 21:15
Example Redmine database.yml configuration for FirebirdSQL database (https://github.com/svoboda-jan/redmine/tree/firebirdsql)
production:
adapter: fb
database: ~/Documents/redmine/db/redmine.fdb
username: SYSDBA
password: masterkey
host: localhost
encoding: UTF-8
create: true
development:
@svoboda-jan
svoboda-jan / tenant_model.rb
Created August 18, 2015 13:29
Very simple multi-tenancy for Rails (shared database)
module TenantModel
def self.included(base)
base.extend ClassMethods
base.instance_eval do
acts_as_tenant
end
end
class InvalidTenant < SecurityError; end
@svoboda-jan
svoboda-jan / gist:cd309fac8d29ba5effd6
Created October 6, 2014 13:15
JavaScript bookmarklet for Easy Redmine
// generates link to new issue form with prefilled values
// save the following code(single line) as bookmark
// use on new issue form to generate link
javascript:try{$('textarea[id=issue_description]').val(CKEDITOR.instances["issue_description"].getData());}catch(e){}s=$.param($('#issue-form *[name!=authenticity_token]').serializeArray());alert(location.href+"?"+s);
@svoboda-jan
svoboda-jan / 001_add_author_to_project.rb
Created January 23, 2014 19:37
This is a simple example of how to create a redmine plugin, which adds a new custom field format to allow dynamic values to be used as options for custom fields
# redmine/plugins/project_author/db/migrate/001_add_author_to_project.rb
class AddAuthorToProject < ActiveRecord::Migration
def up
ProjectCustomField.create(
name: 'Author',
field_format: 'all_users',
default_value: nil,
is_required: false,
editable: true,
@svoboda-jan
svoboda-jan / 01_ini_files.rb
Created September 25, 2013 13:24
Rails code sample with CouchDB database, INI config files and custom email validation
# rails initializer to load *.ini into Rails.application.config
Dir.glob(File.join Rails.root, "/config/**/*.ini").each do |file_name|
config_name = File.basename(file_name, ".ini")
Rails.application.config.send "#{config_name}=", IniFile.new(file_name).to_struct.send(Rails.env)
end
@svoboda-jan
svoboda-jan / sorting.rb
Created June 3, 2013 16:34
A simple module include that allows client side model sorting in Vienna
module Vienna
module Sorting
module ClassMethods
def sorted_by(field, options = {})
@_sort_field = field
@_sort_descending = options.fetch(:order, "asc") != 'asc'
end