Skip to content

Instantly share code, notes, and snippets.

View joona's full-sized avatar

Joona Kulmala joona

  • Rootz LTD
  • Finland
View GitHub Profile
@joona
joona / remove_old_builds.sql
Created April 29, 2022 15:15 — forked from david-zw-liu/remove_old_builds.sql
Keep 1000 builds per repos for DroneCI (sqlite3 version >= 3.25 required)
-- Thank @sbengo to figure out foreign_keys constraints is defaults to false in sqlite
-- Enable to delete logs by cascading delete
PRAGMA foreign_keys = ON;
WITH n_build_ids_per_repo as (
SELECT build_id
FROM (
SELECT
build_id,
build_repo_id,
@joona
joona / das_yaml_processor.js
Last active March 13, 2020 06:39
Simplisting YAML syntax processor for CF
"use strict";
const config = global.dasBootConfig;
const path = require('path');
const fs = require('fs');
const jsonjs = require('jsonjs');
const handlebars = require('handlebars');
const bucket = config.basePath;
const BASE_PATH = config.basePath;
export function dispatch(el, eventName, payload, options) {
options || (options = {});
el || (el = document);
el = el.el || el;
const event = document.createEvent('Event');
event.initEvent(eventName, options.bubbles !== false, true);
event.detail = payload || {};
el.dispatchEvent(event);
}
@joona
joona / store_factory.js
Created February 4, 2020 10:25
Store factory
/*
* StoreFactory - Creates plain object to be used as store with listen and dispatch helpers
*/
export default function storeFactory(obj) {
const store = {};
// Create DOM element to be used as store specific event channel
const eventChannel = store._eventChannel = document.createElement('div');
eventChannel.setAttribute('data-store', true);
@joona
joona / api.js
Last active May 29, 2018 09:05
AWS lambda proxy request handler for https://www.npmjs.com/package/micro.
const { send } = require('micro');
module.exports = (req, res) => {
send(res, 200, { message: 'Hello world!' });
}
@joona
joona / output.txt
Last active September 29, 2017 09:30
<html><head><style></style></head><body><header><nav>NO:DOM</nav></header><div class="container"><h1>Hello world!!!</h1></div></body></html>
<html><head><style></style></head><body><header><nav>NO:DOM</nav></header><div class="container"><h1>Hello world!!!</h1></div></body></html>
<html><head><style></style><style></style></head><body><header><nav>NO:DOMNO:DOM</nav><nav>NO:DOMNO:DOM</nav></header><div class="container"><h1>Hello world!!!Hello world!!!</h1><h1>Hello world!!!Hello world!!!</h1></div><header><nav>NO:DOMNO:DOM</nav><nav>NO:DOMNO:DOM</nav></header><div class="container"><h1>Hello world!!!Hello world!!!</h1><h1>Hello world!!!Hello world!!!</h1></div></body></html>
<html><head><style></style><style></style></head><body><header><nav>NO:DOMNO:DOM</nav><nav>NO:DOMNO:DOM</nav></header><div class="container"><h1>Hello world!!!Hello world!!!</h1><h1>Hello world!!!Hello world!!!</h1></div><header><nav>NO:DOMNO:DOM</nav><nav>NO:DOMNO:DOM</nav></header><div class="container"><h1>Hello world!!!Hello world!!!<

Keybase proof

I hereby claim:

  • I am joona on github.
  • I am jmkulmala (https://keybase.io/jmkulmala) on keybase.
  • I have a public key ASAr8DdIz3f8GH-cqgLUWaQ3nNfAsD4WDSSCSzXnxf7tCwo

To claim this, I am signing this object:

@joona
joona / custom_events.js
Created April 24, 2017 20:50
CustomEvent based dispatch, listen and action dispatch
export function dispatch(el, eventName, payload, options) {
options || (options = {});
el || (el = document);
el = el.el || el;
var event = new CustomEvent(eventName, {
detail: payload || {},
bubbles: options.bubbles !== false
});
el.dispatchEvent(event);
}
@joona
joona / convert_short_tags.sh
Created April 20, 2017 13:49
Convert PHP short tags to full tags
sed -i -e 's/<?php\([^p=]\)/<?php \1/gm' -e 's/<?=\([^ ]\)/<?= \1/gm' -e 's/\([^ ]\)?>/\1 ?>/g' file.php
function distance(lat1, lon1, lat2, lon2) {
var radlat1 = Math.PI * lat1/180
var radlat2 = Math.PI * lat2/180
var theta = lon1-lon2
var radtheta = Math.PI * theta/180
var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta);
dist = Math.acos(dist)
dist = dist * 180/Math.PI
dist = dist * 60 * 1.1515
dist = dist * 1.609344