Skip to content

Instantly share code, notes, and snippets.

View jrasanen's full-sized avatar

Jussi Räsänen jrasanen

  • Internet
View GitHub Profile
jrasanen / s3-individual-bucket.json
Created October 8, 2015 09:53
How to give permission to an individual S3 bucket (IAM policy)
"Version": "2012-10-17",
"Statement": [
"Sid": "Stmt1442911835000",
"Effect": "Allow",
"Action": [
"Resource": [
if [ -f /usr/local/bin/virtualenv ];
virtualenv --no-site-packages --distribute -- $1
elif [ -f /usr/bin/virtualenv ];
virtualenv --no-site-packages --distribute -- $1
echo "No virtualenv found. Please install setuptools & virtualenv. :("
module PayPal::SDK
module REST
module DataTypes
Payer.class_eval do
object_of :merchant_id, String
class ChargeModel < Base
object_of :id, String
object_of :type, String
ChuckJHardy / run.js
Created September 28, 2013 16:19
Express Server for ZeroMQ, and Angular.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'),
kgrz / mongoid3_sinatra_config.rb
Created August 22, 2012 17:04
A Better Mongoid Sinatra configuration implementation. Using settings hash for db options sucks!
# 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
zethon / gist:dc7a5c71b0ac3cff35017febd1f15511
Last active June 27, 2021 04:04
Changing the color of macOS app title bar in Qt with CMake

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

madwork / attachment.rb
Last active July 25, 2021 09:13
Polymorphic attachments with CarrierWave and nested_attributes
class Attachment < ActiveRecord::Base
mount_uploader :attachment, AttachmentUploader
# Associations
belongs_to :attached_item, polymorphic: true
# Validations
validates_presence_of :attachment
voter101 / Gulpfile.js
Last active November 29, 2021 01:17
Gulpfile for Rails application with replaced Sprockets with Gulp
'use strict'
var gulp, sass, babelify, browserify, watchify, source, util;
gulp = require('gulp');
sass = require('gulp-sass');
babelify = require('babelify')
browserify = require('browserify');
watchify = require('watchify');
source = require('vinyl-source-stream');
randrews / main.lua
Created August 8, 2012 04:16
Example code for nice-feeling player movement in Love
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) }
roman01la /
Last active October 22, 2022 12:07
ClojureScript REPL Workflow

ClojureScript REPL Workflow

Short write up on using REPL when developing UIs in ClojureScript.

Hot-reload on save or Eval in REPL?

Everyone's standard approach to hot-reloading is to use a tool (Figwheel or shadow-cljs) that reloads changed namespaces automatically. This works really well: you change the code, the tool picks up changed files, compiles namespaces and dependants, notifies REPL client which then pulls in compiled changes, and re-runs a function that re-renders UI.

The other approach is to use ClojureScript's REPL directly and rely only on eval from the editor. This more or less matches Clojure style workflow. This approach might be useful when you don't want tools overhead or hot-reloading becomes slow for you or you just used to this style of interactions. Also changing code doesn't always mean that you want to reload all the changes. On the other hand it is very easy to change a couple of top-level forms and forget to eval one of them.