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
@vastus
vastus / README.md
Last active January 3, 2018 06:22
Modal dialog for confirming the user to close the window in Qt

Confirm dialog in Qt

Compiling

Run the following commands from the project dir:

$ qmake -project && qmake && make
class UsersController < ApplicationController
def new
@user = User.new
end
def create
user = User.new(params[:user])
user.save # breaks the: "creates a new user with the given attributes" with error: Mock "User_1001" received unexpected message :save with (no args)
render :nothing => true
end
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 <