Skip to content

Instantly share code, notes, and snippets.

View jtomaszewski's full-sized avatar

Jacek Tomaszewski jtomaszewski

View GitHub Profile
@jtomaszewski
jtomaszewski / iptables.sh
Created November 24, 2013 17:55
A basic, example iptables file you can use to configure your VPS.
#!/bin/sh
iptables -F
iptables -X
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A FORWARD -o lo -j ACCEPT
iptables -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED
@jtomaszewski
jtomaszewski / vps_configuration.md
Last active December 29, 2015 06:39
Example, quick VPS configuration (debian 7 wheeze). Submit changes or fork it and we'll make it better! =)

ssh

  1. create your own user
adduser johndoe # root@vps

# now, relogin onto johndoe 
mkdir .ssh

# copy ssh key from your local machine to johndoe's account
@jtomaszewski
jtomaszewski / god.cap.rb
Last active March 7, 2022 01:21
God tasks for Capistrano v3
# Thanks to http://makandracards.com/makandra/1431-resque-+-god-+-capistrano for an idea and v2 version.
namespace :god do
def god_is_running
capture(:bundle, "exec god status > /dev/null 2>&1 || echo 'god not running'") != 'god not running'
end
# Must be executed within SSHKit context
def config_file
"#{release_path}/config/god.rb"
@jtomaszewski
jtomaszewski / god.rb
Created December 25, 2013 01:24
Watch websocket_rails server with God
RAILS_ROOT = File.expand_path('../', File.dirname(__FILE__))
RAILS_ENV = ENV['RAILS_ENV'] || 'production'
God.watch do |w|
w.name = "websocket_rails"
w.start = "cd #{RAILS_ROOT} && bundle exec rake websocket_rails:start_server"
w.stop = "cd #{RAILS_ROOT} && bundle exec rake websocket_rails:stop_server"
w.pid_file = "#{RAILS_ROOT}/tmp/pids/websocket_rails.pid"
@jtomaszewski
jtomaszewski / multi_column_clearance.sass
Created January 31, 2014 12:34
Bootstrap 3 Grid Multi Column Clearing
// See issue https://github.com/twbs/bootstrap/issues/8810 for more information.
//
// Thanks for the idea of the fix to:
// https://github.com/sixfootsixdesigns/Bootstrap-3-Grid-Columns-Clearing
@import "bootstrap/variables"
// Useful @media mixins (based on dimensions taken from bootstrap-sass)
=media-width-below($max)
@jtomaszewski
jtomaszewski / asyncable.rb
Created February 16, 2014 01:09
Allow instance methods to be delayed to Sidekiq
# Idea from http://krautcomputing.com/blog/2012/10/07/how-to-make-everything-background-processable-through-sidekiq/
#
# Usage:
#
# class Synchronization
# include Asyncable
# end
#
# Then:
# Synchronization.find(12).perform_async(:synchronize, 3, 2)
@jtomaszewski
jtomaszewski / ng_http_transform_request_to_form_data.coffee
Created April 17, 2014 14:45
Method that transforms data[Hash] into FormData object.
angular.module 'gulliver'
# This will transform data[Hash] into FormData object.
# Supports nested objects and FileList (file input's value).
#
# Note: This won't work on browsers not supporting FormData and FileList (f.e. IE 8-9).
.service 'httpTransformRequestToFormData', ->
(data) ->
return data unless data
@jtomaszewski
jtomaszewski / ionicVerticalSlideBox.js
Created November 5, 2014 10:45
A cloned `ionic.views.Slider` and `slideBox` directive to `ionic.views.verticalSlider` and `verticalSlideBox`: it was done just by renaming "x, y, left, right" strings into "y, x, top, bottom". It works correctly ;)
var IonicModule = angular.module('ionic'),
extend = angular.extend,
forEach = angular.forEach,
isDefined = angular.isDefined,
isString = angular.isString,
jqLite = angular.element;
/**
* @ngdoc directive
* @name ionVerticalSlideBox
@jtomaszewski
jtomaszewski / app_run.coffee
Created January 7, 2015 15:47
Ionic Framework: Turn off animations on Android and iOS 6 devices.
app.config ($injector) ->
model = ionic.Platform.device().model or ""
animateNavigation = ionic.Platform.grade == "a"
unless animateNavigation
defaults =
'$ionicNavBarConfig':
transition: 'no-animation'
'$ionicNavViewConfig':
transition: 'no-animation'
@jtomaszewski
jtomaszewski / deploy.rb
Last active October 21, 2015 17:22
Eye configuration for unicorn && sidekiq
# ...
namespace :deploy do
desc 'Restart application'
task :restart => ["eye:reload", "eye:restart"]
after :published, :restart
end