Skip to content

Instantly share code, notes, and snippets.

View vastus's full-sized avatar
🦅
all(good)

Juho Hautala vastus

🦅
all(good)
View GitHub Profile
Section "Monitor"
Identifier "Monitor0"
EndSection
Section "Device"
Identifier "Device0"
Driver "vesa" # driver
EndSection
Section "Screen"
@vastus
vastus / model.rb
Created March 11, 2014 19:04
How to access subclasses instance variables in superclass
class Model
def self.all
puts self.table
end
class << self
attr_reader :table
end
end
@vastus
vastus / cask.md
Created May 12, 2014 10:06
Install VirtualBox and Vagrant using Cask

Install Cask (w/ home brew)

brew install caskroom/cask/brew-cask

Install VirtualBox

brew cask install virtualbox
@vastus
vastus / tut
Created September 2, 2014 07:34
pushd/popd
10:32 [~] $ cd /tmp/
10:32 [tmp] $ mkdir -p eka/toka/kolmas
10:32 [tmp] $ pushd eka/
/tmp/eka /tmp
10:33 [eka] $ pushd toka/
/tmp/eka/toka /tmp/eka /tmp
10:33 [toka] $ pushd kolmas/
/tmp/eka/toka/kolmas /tmp/eka/toka /tmp/eka /tmp
10:33 [kolmas] $ pwd
/tmp/eka/toka/kolmas
@vastus
vastus / gulpfile.js
Created December 28, 2014 06:33
Gulp file for browserify w/ vinyl source stream
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
gulp.task('js', function () {
return browserify('./src/js/application.js', { debug: true })
.bundle().on('error', handleError)
.pipe(source('application.js'))
.pipe(gulp.dest('./js'));
});
@vastus
vastus / db.js
Created January 24, 2015 21:43
Easy bloggin' w/ Node
var pg = require('pg');
var dcs = process.env['DATABASE_URL'];
function exec(sql, binds) {
return new Promise(function (resolve, reject) {
pg.connect(dcs, function connect(err, db, release) {
if (err) {
reject(err);
}
function lupaa(cond) {
return new Promise(function (resolve, reject) {
if (cond) {
resolve('Tuli');
}
reject('Meni');
});
}
@vastus
vastus / Output
Last active August 29, 2015 14:14
Simple threading in Ruby
$ ruby threadit.rb
> 2
> 1
> 0
> 3
> 4
> 5
> 6
2 <
0 <
<div class="wrap">
<section class="col content">
<h2>Main section</h2>
</section>
<nav class="col nav">
<h2>Navigation</h2>
</nav>
<aside class="col sidebar">
require 'koala'
require 'awesome_print'
g = Koala::Facebook::API.new(ENV["ACCESS_TOKEN"])
page = g.get_object("#{ENV["PAGE_ID"]}?fields=access_token")
raise "No page access_token" if !page["access_token"] || !page["id"]
page_graph = Koala::Facebook::API.new(page["access_token"])