Skip to content

Instantly share code, notes, and snippets.

View fonzai's full-sized avatar

Timo Saloranta fonzai

View GitHub Profile
@fobin
fobin / script.js
Last active June 25, 2023 16:08
Get latest news from hs.fi
// To run this on your iOS device,
// check that you are running iOS 14
// and get Scriptable app from App
// Store.
// https://apps.apple.com/us/app/scriptable/id1405459188
// The script shows the latest article
// from Helsingin Sanomat in a widget on
// Home screen. Go to your Home screen
// to set up the script in a widget.
// The script will present a preview
@bamarch
bamarch / lambda_logging.py
Last active April 12, 2024 12:23
Python: Log to Datadog from AWS Lambda
"""Logger for use in Lambda functions.
Replaces the default AWS provided logger with our own.
Provides a structure format that can be easily parsed i.e. by datadog.
"""
import json
import logging
import sys
import time
import traceback
from functools import wraps
const jwt = require('jsonwebtoken')
const fs = require('fs')
const path = require('path')
const request = require('request-promise') //Peer-dep to request
const QLIK_HOST = 'usrad-aklprobook'
const QLIK_VIRTUAL_PROXY_PREFIX = 'stratsys'
/**
* In this case we re-use the private cert from Qlik to sign our token
# # Fixing key bindings for `irb`
#
# when your ruby comes from `brew`, `rbenv`, and arrow keys don't work in your `irb`
brew upgrade readline rbenv ruby-install # ensure we have the `readline` library, and a recent version of `ruby-install` which will link to it properly when building `ruby`.
rbenv install <your-favourite-ruby-version> # rebuild ruby.
# watch out for the message 'ruby-build: use readline from homebrew' in output from the command above,
# then, go get some coffee.
# ...
anonymous
anonymous / gmailAutoarchive.js
Created January 8, 2017 16:39
function gmailAutoarchive() {
var delayDays = 2; // will only impact emails more than 48h old
var maxDate = new Date();
maxDate.setDate(maxDate.getDate()-delayDays); // what was the date at that time?
// Get all the threads labelled 'autoarchive'
var label = GmailApp.getUserLabelByName("autoarchive");
var threads = label.getThreads(0, 400);
@yang-wei
yang-wei / destructuring.md
Last active September 5, 2024 18:56
Elm Destructuring (or Pattern Matching) cheatsheet

Should be work with 0.18

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !

Tuple

myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))
#!/usr/bin/env bash
#
# see: https://gist.github.com/gregorynicholas/2160046ec6946a2ce0fa
# src: https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# updated: 2015-06-06
#
# ask for the administrator password upfront
sudo -v
@emad-elsaid
emad-elsaid / gaming-test.rb
Created March 10, 2014 10:59
Random bouncy particles using ruby Gosu games library
require 'gosu'
$width, $height = 200, 200
$number_of_particles = 200
class Quad
def initialize
@pos = {x:rand($width), y:rand($width)}
@vel = { x:(rand(5)+1)*[1,-1].sample, y:(rand(5)+1)*[1,-1].sample }
@size = rand(4)*[1,-1].sample
@color = [ Gosu::Color::GRAY, Gosu::Color::WHITE,
@forkfork
forkfork / atomic_redis.md
Last active May 3, 2019 01:02
Atomic Json modifications with Redis

Atomic Operations in Redis

Redis is a commonly used as a mini 'database' for caching, shared queues, and similar. It is generally fast & reliable for these tasks. Redis does not support nested data types, and misusing redis for this type of thing can end up with the situation described below.

Imagine that we want to store the following data in Redis:

set users '[{"user":"tim", "pages": ["aaa", "bbb"]}]'

@grosser
grosser / lazydog.rb
Last active December 15, 2015 22:09
Non-blocking datadog metrics / reporting
require "dogapi"
require "celluloid/autostart"
require "singleton"
class LazyDog
include Celluloid
include Singleton
def emit_point(*args)
client.emit_point(*args)