Skip to content

Instantly share code, notes, and snippets.

Henri Hyyryläinen hhyyrylainen

Block or report user

Report or block hhyyrylainen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
j127 / auth_controller.rb
Last active Feb 26, 2019
Rails 5.2 with Discourse SSO Authentication
View auth_controller.rb
# This is just a sketch. Please leave a comment if you have suggestions.
class AuthController < ApplicationController
# Generate and SSO URL and redirect the user to Discourse
def authenticate
# Save the ?destination=some_url parameter if it exists
destination = request.query_parameters['destination'] || root_url
session[:destination] = destination
# `nonce` here will have `:value` and `:created_at` keys
nonce = generate_nonce
drmalex07 /
Last active Jun 29, 2019
An example with an oneshot service on systemd. #systemd #systemd.service #oneshot


Services declared as oneshot are expected to take some action and exit immediatelly (thus, they are not really services, no running processes remain). A common pattern for these type of service is to be defined by a setup and a teardown action.

Let's create a example foo service that when started creates a file, and when stopped it deletes it.

Define setup/teardown actions

Create executable file /opt/foo/

shunchu / convert-seconds-into-hh-mm-ss-in-ruby.rb
Created Jul 25, 2012
Convert seconds into HH:MM:SS in Ruby
View convert-seconds-into-hh-mm-ss-in-ruby.rb
t = 236 # seconds"%H:%M:%S")
=> "00:03:56"
# Reference
perky / ProFi.lua
Created May 30, 2012
ProFi, a simple lua profiler that works with LuaJIT and prints a pretty report file in columns.
View ProFi.lua
ProFi v1.3, by Luke Perkin 2012. MIT Licence
ProFi = require 'ProFi'
coroutine.resume( some_coroutine )
gre / easing.js
Last active Jul 16, 2019
Simple Easing Functions in Javascript - see
View easing.js
* Easing Functions - inspired from
* only considering the t value for the range [0, 1] => [0, 1]
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity
You can’t perform that action at this time.