Skip to content

Instantly share code, notes, and snippets.

View mlitwiniuk's full-sized avatar

Maciej Litwiniuk mlitwiniuk

View GitHub Profile
@mlitwiniuk
mlitwiniuk / rails_4_2_postgres_10_sequence_monkey_patch_fix.rb
Created December 4, 2017 17:10
Monkey patch PostgreSQL 10 sequences in Rails 4.2
# In PostgreSQL 10 each sequence does not know `increment_by` or `min_value`
# This fix is already in Rails master, this is just monkey patch "to make it
# work" in Rails 4.2
# More details here: https://github.com/rails/rails/pull/28864
# Original issue: https://github.com/rails/rails/issues/28780
module ActiveRecord
module ConnectionAdapters
module PostgreSQL
module SchemaStatements
# Resets the sequence of a table's primary key to the maximum value.
@mlitwiniuk
mlitwiniuk / Capfile
Last active October 16, 2015 11:24
Deploy stack
# Capfile
# Load DSL and set up stages
require 'capistrano/setup'
# Include default deployment tasks
require 'capistrano/deploy'
require 'capistrano/rails'
@mlitwiniuk
mlitwiniuk / arch-linux-install
Last active August 29, 2015 14:26 — forked from mattiaslundberg/arch-linux-install
Minimal instructions for installing arch linux on an UEFI system with full system encryption using dm-crypt and luks
# Install ARCH Linux with encrypted file-system and UEFI
# The official installation guide (https://wiki.archlinux.org/index.php/Installation_Guide) contains a more verbose description.
# Download the archiso image from https://www.archlinux.org/
# Copy to a usb-drive
dd if=archlinux.img of=/dev/sdX bs=16M # on linux
# Boot from the usb. If the usb fails to boot, make sure that secure boot is disabeled in the BIOS configuration.
# Set swedish keymap
### Keybase proof
I hereby claim:
* I am mlitwiniuk on github.
* I am mlitwiniuk (https://keybase.io/mlitwiniuk) on keybase.
* I have a public key whose fingerprint is A88C 4CD3 C1B5 89C7 2224 8035 2F07 4167 D52F 9DF1
To claim this, I am signing this object:
after "deploy:symlink", "deploy:restart_workers"
after "deploy:restart_workers", "deploy:restart_scheduler"
##
# Rake helper task.
# http://pastie.org/255489
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/
def run_remote_rake(rake_cmd)
rake_args = ENV['RAKE_ARGS'].to_s.split(',')
window.share_contest = function(){
alert('sharing clicked');
FB.ui({
method: 'feed',
app_id: $('body').data('app_id'),
name: 'Title text',
link: $('body').data('tab_url'),
redirect_uri: $('body').data('app_url'),
caption: 'Caption text',
description: 'Description text',
@mlitwiniuk
mlitwiniuk / etc_init.d_unicorn_example.co.uk
Created August 26, 2012 19:48 — forked from rubysolo/etc_init.d_unicorn_example.co.uk
Ruby on Rails server setup on Ubuntu 11.04 with Nginx, Unicorn, Rbenv
#! /bin/bash
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the unicorn web server
# Description: starts unicorn
@mlitwiniuk
mlitwiniuk / example-user.js
Created May 4, 2012 13:13 — forked from nijikokun/example-user.js
Beautiful Validation... Why have I never thought of this before?!
var user = {
validateCredentials: function (username, password) {
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9-_]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);
@mlitwiniuk
mlitwiniuk / activesupport_load.rb
Created January 16, 2012 14:19
YAML in Rails - don't and do
json_object = ActiveSupport::JSON.decode(json_content)