johan pretorius johan--

View index.md

Rails Models

Generating models

$ rails g model User

Associations

belongs_to
has_one
View Blackbored.xml
1 2 3 4 5 6 7 8 9 10
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="Blackbored" version="1" parent_scheme="Default">
<option name="LINE_SPACING" value="1.25" />
<option name="EDITOR_FONT_SIZE" value="12" />
<option name="EDITOR_FONT_NAME" value="Monaco" />
<colors>
<option name="ANNOTATIONS_COLOR" value="3e83e7" />
<option name="CARET_COLOR" value="" />
<option name="CARET_ROW_COLOR" value="40436" />
<option name="CONSOLE_BACKGROUND_KEY" value="0" />
View logstash.conf
1 2 3 4 5 6 7 8 9 10
filter {
# strip the syslog PRI part and create facility and severity fields.
# the original syslog message is saved in field %{syslog_raw_message}.
# the extracted PRI is available in the %{syslog_pri} field.
#
# You get %{syslog_facility_code} and %{syslog_severity_code} fields.
# You also get %{syslog_facility} and %{syslog_severity} fields if the
# use_labels option is set True (the default) on syslog_pri filter.
grok {
type => "syslog-relay"
View digitalocean.md

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

View README.md

You have your Rails Apps with specific Gemsets in RVM.

The following commands creates a wrapped unicorn_rails bin. Be sure to replace the variables and that you have unicorn in your bundle.

rvmsudo rvm wrapper [RUBY VERSION]@[GEMSET] [GEMSET] unicorn_rails

Now you have a /usr/local/rvm/bin/[GEMSET]_unicorn_rails I will refer to [GEMSET]_unicorn_rails as [WRAPPED_NAME]

View README.md

You have your Rails Apps with specific Gemsets in RVM.

The following commands creates a wrapped unicorn_rails bin. Be sure to replace the variables and that you have unicorn in your bundle.

rvmsudo rvm wrapper [RUBY VERSION]@[GEMSET] [GEMSET] unicorn_rails

Now you have a /usr/local/rvm/bin/[GEMSET]_unicorn_rails I will refer to [GEMSET]_unicorn_rails as [WRAPPED_NAME]

View Stone wall.js
1 2 3 4 5 6 7 8 9 10
/* http://blog.codility.com/2012/06/sigma-2012-codility-programming.html */
 
function stone_wall ( H ) {
var blocks = 0, stack = [], m, stack_length = 0;
for(m in H) {
// I use stack to remember all previous skyline levels
while(stack_length > 0 && stack[stack_length - 1] > H[m]) {
stack_length -= 1;
blocks += 1;
View equi.rb
1 2 3 4 5 6 7 8 9 10
# http://codility.com/ for info
 
def equi(a)
pres, posts = 0, a.reduce(:+)
 
0.upto(a.length - 1) do |pivot|
pres += (pivot > 0 ? a[pivot-1] : 0)
posts -= a[pivot]
return pivot if pres == posts
end
View tests_for_toptal_on_codility.py
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
#
# Test that I passed on codility.com for TopTal company
#
 
 
# Task #1
def binary_gap(N):
View sc-dl.js
1 2 3 4 5 6 7 8 9 10
(function(d) {
var dl = d.createElement('a');
dl.innerText = 'Download MP3';
dl.href = "http://media.soundcloud.com/stream/"+d.querySelector('#main-content-inner img[class=waveform]').src.match(/\.com\/(.+)\_/)[1];
dl.download = d.querySelector('em').innerText+".mp3";
d.querySelector('.primary').appendChild(dl);
dl.style.marginLeft = '10px';
dl.style.color = 'red';
dl.style.fontWeight = 700;
})(document);
Something went wrong with that request. Please try again.