Skip to content

Instantly share code, notes, and snippets.

@fraank
fraank / create_a_gem
Last active January 12, 2016 14:38
collection of commands for writing an own gem
We do it with bundler:
$ bundle gem name_of_new_gem
Linklist:
Testing, testing, testing
http://www.smashingmagazine.com/2014/04/how-to-build-a-ruby-gem-with-bundler-test-driven-development-travis-ci-and-coveralls-oh-my/
Create and share rake tasks inside a gem
http://andyatkinson.com/blog/2014/06/23/sharing-rake-tasks-in-gems
@fraank
fraank / ruby_christmas.rb
Last active December 25, 2015 10:20
a christmas tree in one line of ruby
((1..20).to_a+[6]*4).map{|i|puts(('*'*i*2).center(80))}
@fraank
fraank / laravel_cheatsheet
Last active August 29, 2015 14:23
laravel cheatsheet
add laravel Installer:
composer global require "laravel/installer=~1.1"
add path for laravel-command
PATH=$PATH:~/.composer/vendor/bin
PATH=~/.composer/vendor/bin:$PATH
Now you can do..
laravel new yournewproject
@fraank
fraank / unicorn.rb
Created April 22, 2015 09:07
unicorn config file for EventMachine for development-use
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 15
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
before_fork do |server,worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
@fraank
fraank / unicorn.conf.erb
Created April 22, 2015 08:22
unicorn aws opsworks recipe with included EventMachine (used for async_publish with keen.io)
# adapted version of https://github.com/aws/opsworks-cookbooks/blob/release-chef-11.10/unicorn/templates/default/unicorn.conf.erb
worker_processes <%= node[:unicorn][:worker_processes] %>
user "<%= @deploy[:user]%>"
working_directory "<%= @deploy[:deploy_to]%>/current"
listen "<%= @deploy[:deploy_to]%>/shared/sockets/unicorn.sock", :backlog => <%= node[:unicorn][:backlog] %>, :tcp_nodelay => <%= node[:unicorn][:tcp_nodelay] %>, :tcp_nopush => <%= node[:unicorn][:tcp_nopush] %>, :tries => <%= node[:unicorn][:tries] %>, :delay => <%= node[:unicorn][:delay] %>, :accept_filter => <%= node[:unicorn][:accept_filter].inspect %>
@fraank
fraank / mysql_console.txt
Last active August 29, 2015 14:09
mysql console
# Export one table from database:
mysqldump -u root -p db_with_data table1 > /your/path/newsql.sql
# .. and import it again to another db:
mysql -u username -p -D db_without_data < /your/path/newsql.sql
if you need some encoding you can add "--default-character-set=UTF8"
#You can also connect directly into mysql and set the source:
mysql –h <host_name> -port=3306 –u <db_master_user> -p
@fraank
fraank / rake_cheatsheet
Created May 20, 2014 11:08
Raking to the End (just a small rake cheatsheet)
Rollback n steps
$ rake db:rollback STEP=n
@fraank
fraank / starting_with_django
Last active August 29, 2015 14:01
a pragmatic guide to start django to be productive from zero
# =============
# Basic Setup
# =============
# I guess you’ve Python, right? So here we go to install django
$ pip install Django==1.6.4
# It should output the Version number you set above
$ python -c "import django; print(django.get_version())"
@fraank
fraank / ec2_gui_vnc
Last active August 29, 2015 14:01
VNC on Ubuntu with GUI via AWS - EC2
Easy Install VNC on Ubuntu with GUI via EC2 (I used a Ubuntu 64 Precise 12.04 HVM Instance, daily)
$ sudo apt-get update
$ sudo apt-get install ubuntu-desktop
$ sudo apt-get install vnc4server
Add correct permissions for the Securty-Group of the Instance and grant access for port 5901
Start the VNC-Server on Port :1 (or 5901) and set Password for connection
$ vncserver :1
@fraank
fraank / AWS Elastic Block Store - Basics
Last active August 29, 2015 14:01
Basics for using Elastic Block Store (EBS) in your EC2-Instances (OS: Ubuntu)
Mounting an EBS-Storage
Variables:
@device_name = /dev/sdf
@device_mount = xvdf
@mount_point = /my_space
Select the EBS-Storage in the AWS-Console (Web-Interface) and attach it to the desired device.
Here you can set the @device_name which is shown in your instance as @device_mount.