Skip to content

Instantly share code, notes, and snippets.


Jussi Räsänen jrasanen

View GitHub Profile
Kartones /
Last active Jul 24, 2021
PostgreSQL command line cheatsheet


Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
gcatlin / glfw-metal-example.m
Last active Jul 24, 2021
Minimal C GLFW Metal example
View glfw-metal-example.m
// cc glfw-metal-example.m -lGLFW -framework AppKit -framework Metal -framework QuartzCore
#include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h>
#import <Metal/Metal.h>
#import <QuartzCore/CAMetalLayer.h>
lelandbatey /
Last active Jul 22, 2021
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!


This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"


simonista / .vimrc
Last active Jul 19, 2021
A basic .vimrc file that will serve as a good template on which to build.
View .vimrc
" Don't try to be vi compatible
set nocompatible
" Helps force plugins to load correctly when it is turned back on below
filetype off
" TODO: Load plugins here (pathogen or vundle)
" Turn on syntax highlighting
syntax on
JeffBelback /
Last active Jun 29, 2021
Destroy all Docker Containers and Images
# Stop all containers
containers=`docker ps -a -q`
if [ -n "$containers" ] ; then
docker stop $containers
# Delete all containers
containers=`docker ps -a -q`
if [ -n "$containers" ]; then
docker rm -f -v $containers
zethon / gist:dc7a5c71b0ac3cff35017febd1f15511
Last active Jun 27, 2021
Changing the color of macOS app title bar in Qt with CMake
View gist:dc7a5c71b0ac3cff35017febd1f15511

In CMake, add/link the Carbon library to the executable


Make sure to add ${CARBON_LIBRARY} in the TARGET_LINK_LIBRARIES call for the executable.

Then create a file to hold the Object-C code, in this case

kgrz / mongoid3_sinatra_config.rb
Created Aug 22, 2012
A Better Mongoid Sinatra configuration implementation. Using settings hash for db options sucks!
View mongoid3_sinatra_config.rb
# This is a modification of the blogpost on how to use Mongoid and Sinatra.
# Here is the original blogpost
# The modification lets you use Mongoid 3.0 with the new Moped driver
# The new Moped driver uses the Sessions component to define the MongoDB connection rather
# than the that is used in the case of the default Ruby driver.
# vs
# Mongoid.load!(yaml_config.yml) is used to build the config hash. Alternatively, the hash can
# be built manually by using Mongoid.config {|config| ...} syntax. The config.sessions hash
madwork / attachment.rb
Last active Oct 13, 2020
Polymorphic attachments with CarrierWave and nested_attributes
View attachment.rb
class Attachment < ActiveRecord::Base
mount_uploader :attachment, AttachmentUploader
# Associations
belongs_to :attached_item, polymorphic: true
# Validations
validates_presence_of :attachment
ChuckJHardy / run.js
Created Sep 28, 2013
Express Server for ZeroMQ, and Angular.js
View run.js
'use strict';
var express = require('express'),
app = express(),
http = require('http'),
server = http.createServer(app),
path = require('path'),
io = require('').listen(server),
fs = require('fs'),
zmq = require('zmq'),
randrews / main.lua
Created Aug 8, 2012
Example code for nice-feeling player movement in Love
View main.lua
require 'point'
function love.load()
love.physics.setMeter(32), 120, 64)
world = love.physics.newWorld(0, 0)
crates = { makeCrate(world, 5, 5),
makeCrate(world, 5, 6) }