Skip to content

Instantly share code, notes, and snippets.

View olleolleolle's full-sized avatar
🙌
In sunny Malmö in Sweden 🌞

Olle Jonsson olleolleolle

🙌
In sunny Malmö in Sweden 🌞
View GitHub Profile
@joeljunstrom
joeljunstrom / local_dev_reloads_under_falcon.rb
Last active May 26, 2026 06:55
Glue code that makes hotwire-spark and rails reloader work under Falcon + async-cable
# frozen_string_literal: true
# Glue code that makes hotwire-spark work under Falcon + async-cable.
#
# hotwire-spark assumes Puma + `rails server`:
# - Hotwire::Spark.enabled? gates install on `defined?(Rails::Server)`,
# which is only set by `rails s`. Falcon boots through its own CLI.
# - The cable server is mounted through the router and upgrades via rack
# hijack + nio4r, which does not cooperate with Falcon's fiber scheduler.
#
@marick
marick / xp2016.md
Last active February 28, 2016 00:48
Draft abstract for XP2016 talk

"Things are the way they are because they got that way." - Gerald Weinberg

XP, like everything else, contains traces of its history - traces that, to an outsider, seem arbitrary. The same is true of functional programming (FP). The histories of XP and FP have had little influence on each other. As a fan of both, I think that's a problem.

Possibly it's more of a problem for FP: I see XP insights being painfully and expensively rediscovered.

It's also a problem for XP. When Agile became popular, XP was eclipsed because (1) it requires a lot of discipline, and (2) it focuses on "that point in the proceedings [where] someone competent has to write some damn code" [told to me by a speaker at this conference who, at the time, wanted to remain anonymous]". As Agile became a management fad, that made XP unappealing.

FP is (arguably) at the point object-oriented programming was during XP's heydey: people with money to spend on programmers are willing to risk it on programmers programming in weird ways. IF XP can

@halfbyte
halfbyte / Gemfile
Created December 21, 2014 01:22
A Simple Calendar generator. Very specific for my case - Probably going to make it more configurable one day.
source "https://rubygems.org"
gem "prawn"
@ftrain
ftrain / actually.js
Last active November 10, 2023 01:16
A program that generates actuallies
/*
actually.js
_ _ _
__ _ __ _ __ _ __ _ ___| |_ _ _ __ _| | |_ _
/ _` |/ _` |/ _` |/ _` |/ __| __| | | |/ _` | | | | | |
| (_| | (_| | (_| | (_| | (__| |_| |_| | (_| | | | |_| |_
\__,_|\__,_|\__,_|\__,_|\___|\__|\__,_|\__,_|_|_|\__, ( )
|___/|/
*/
@tamoyal
tamoyal / gist:10441108
Created April 11, 2014 04:39
Create super user and database user in Mongo 2.6
# Create your superuser
$ mongo
> use admin
> db.createUser({user:"someadmin",pwd:"secret", roles:[{role:"root",db:"admin"}]})
> exit
# Alias for convenience (optional and at your own risk)
$ echo 'alias mongo="mongo --port 27017 -u someadmin -p secret --authenticationDatabase admin"' >> ~/.bash_profile
$ source ~/.bash_profile
@tolnem
tolnem / kontrol.py
Last active February 12, 2024 13:46
Reading midi input from nanoKontrol 2 in python, using python-rtmidi and jack-audio
#!/usr/bin/python
import rtmidi, time
buttons = {
58: 'track_left',
59: 'track_right',
46: 'cycle',
60: 'marker_set',
61: 'marker_left',
@bjonord
bjonord / CreateExtensionsForDb.rb
Created November 2, 2013 11:54
earth_box in ActiveRecord
# Migration to add cube and earthdistance extensions.
class CreatePostgresExtensions < ActiveRecord::Migration
def up
ActiveRecord::Base.connection.execute("CREATE EXTENSION cube;")
ActiveRecord::Base.connection.execute("CREATE EXTENSION earthdistance;")
end
def down
ActiveRecord::Base.connection.execute("DROP EXTENSION earthdistance;")
ActiveRecord::Base.connection.execute("DROP EXTENSION cube;")
@nellshamrell
nellshamrell / Beneath the Surface: Embracing the True Power of Regular Expressions in Ruby
Last active December 3, 2017 16:35
Resources I consulted when preparing my presentation "Beneath the Surface: Embracing the True Power of Regular Expressions in Ruby"
All of these resources were extremely valuable as I researched regex, finite state machines, and regex in Ruby. Check them out, they're full of fantastic information!
Articles
"Exploring Ruby's Regular Expression Algorithm" by Pat Shaughnessy
http://patshaughnessy.net/2012/4/3/exploring-rubys-regular-expression-algorithm
"Finite State Machines and Regular Expressions" by Eli Bendersky
http://www.gamedev.net/page/resources/_/technical/general-programming/finite-state-machines-and-regular-expressions-r3176
"Regular Expression Matching Can Be Simple and Fast" by Russ Cox
@SunboX
SunboX / inlineworker.js
Created June 24, 2013 12:21
Create web workers without a separate worker JS files. Source: http://jsbin.com/owogib/8/
function worker() {
setInterval(function() {
postMessage({foo: "bar"});
}, 1000);
}
var code = worker.toString();
code = code.substring(code.indexOf("{")+1, code.lastIndexOf("}"));
var blob = new Blob([code], {type: "application/javascript"});