Skip to content

Instantly share code, notes, and snippets.

View thomasnordquist's full-sized avatar

Thomas Nordquist thomasnordquist

  • Germany, Darmstadt
View GitHub Profile
@thomasnordquist
thomasnordquist / machine.js
Last active October 27, 2020 08:07
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@thomasnordquist
thomasnordquist / x.js
Created January 8, 2019 22:44
JSON String => Influx Measurement
const topics = msg.topic.split('/')
let payload
try {
payload = JSON.parse(msg.payload)
} catch (error) {
console.log('mqtt2influx: can\'t interpret payload', payload, error)
return
}
@thomasnordquist
thomasnordquist / makeCoverageBadge.sh
Created June 29, 2018 11:12
Creates a code coverage bash with bash "only"
#!/bin/bash
#
# Creates a coverage badge svg with bash "only"
# Intent is to create a coverage badge in a travis job and uploading it to S3 so it can be displayed in a projects readme
#
# Uses: bash, read, cut, sed
#
# Usage: makeCoverageBadge.sh percent target_svg
# Example: makeCoverageBadge.sh 81.83 coverage.svg
@thomasnordquist
thomasnordquist / testLocalizations.sh
Last active October 27, 2017 16:46
Find uses of non-localized NSLocalizedString by scanning the projects files
#!/bin/bash
IFS=$'\n'
# List of all localized strings by cat over all string files, then removing comments, empty lines
# result is a list of strings like this (including paranthesis): "order_list.title"
# - Remove comments from result: | grep -v '/\*' \
# - Remove empty lines: | grep -v '^$' \
LOCALIZED_STRINGS=$(\
find . -name '*.strings' -not -path './Pods/*' -print0 | xargs -0 cat \
| grep -v '/\*' \
<?php
// This script tests if the authentication header is received,
// it does so by creating a request with authentication and printing the response.
// Location of the php fiel on the server
$protocol = (isset($_SERVER['HTTPS']) ? "https" : "http");
$credentials = "username:password"; // Using inline credentials
$url = $protocol . '://' . $credentials . '@' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
(function() {
'use strict';
var tiles = [];
var activeTiles = [];
var inactiveTiles = [];
function waitForData() {
if($(".widget-size-1x1").length <= 0) {
setTimeout(waitForData, 50);
@thomasnordquist
thomasnordquist / db.js
Created March 3, 2016 13:34
Scrapes current trains and busses from your bus/train station
/*
Dependencies: request, cheerio
npm install cheerio
npm install request
Run with:
node db.js
*/
var cheerio = require('cheerio');