Skip to content

Instantly share code, notes, and snippets.

View sempostma's full-sized avatar

Sem Postma sempostma

View GitHub Profile
@sempostma
sempostma / copy-files-to-heroku.bash
Created July 22, 2019 10:40
Copy files to heroku
cat <file_name> | gpg -ac -o- | curl -X PUT -T "-" https://transfer.sh/<file_name>.gpg
curl https://transfer.sh/<hash>/<file_name>.gpg | gpg -o- > <file_name>
@sempostma
sempostma / get-repo-commits.js
Created July 22, 2019 10:39
Get all repo commits json
fetch('https://api.github.com/repos/:user/:repo/commits')
.then(x => x.json())
.then(json => json.map(x => ({ author: x.commit.author.name, date: x.commit.author.date })))
.then(console.log)
@sempostma
sempostma / device.css.js
Last active July 5, 2019 16:46
Extract data from devices.css demo page
Array.from(document.querySelectorAll('.section-device')).map(x => {
var def = x.querySelector('.device').classList.item(1);
var colors = Array.from(x.querySelectorAll('.dot.tooltip'))
if (colors.length === 0) {
return [{
className: def,
color: null
}]
}
return colors.map(c => {
collections:
- label: Settings
name: settings
files:
- label: CMS
name: cms
file: static/admin/config.yml
fields:
- label: Site URL
name: site_url
var username = 'LesterGallagher';
var repo = 'ikverstaat';
var date = '12/12/2010';
var per_page = 100;
var page = 1;
var locale = 'nl-NL';
var link = `https://api.github.com/repos/${username}/${repo}/commits?since=${new Date(date)}&per_page=${per_page}&page=${page}`;
var getLog = async () => {
var commits = [];
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<!-- Latest compiled and minified CSS -->
@sempostma
sempostma / cordova-download.js
Last active December 26, 2023 15:12
Downloading/Saving/Opening files with Cordova in javascript and polyfill the achor's download attribute for android webview.
"use strict";
if (window.cordova && cordova.platformId !== "browser") {
document.addEventListener("deviceready", function () {
document.addEventListener("click", function (e) {
var elem = e.target;
while (elem != document) {
if (elem.tagName === "A" && elem.hasAttribute("download")) {
e.preventDefault();
@sempostma
sempostma / indexeddb-wrapper.js
Created February 10, 2019 16:01
indexeddb-wrapper.js
function IndexedDBStorage(name) {
this.name = name;
var self = this;
this.ready = new Promise(function(resolve, reject) {
var request = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB)
.open(location.origin);
request.onupgradeneeded = function(e) {
self.db = e.target.result;
self.db.createObjectStore(name);
@sempostma
sempostma / final-approach.html
Last active February 7, 2019 13:15
final-approach.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Game</title>
<style>
const NLP = require('natural');
const path = require('path');
const readline = require('readline');
const fs = require('fs');
const { stemmer } = require('./config');
const trainingDataPath = process.argv[2];
const classifierName = process.argv[3];
if (!trainingDataPath || !classifierName) {
console.log('usage: node . <path/to/trainingdata.json> <classifier_name>');