Skip to content

Instantly share code, notes, and snippets.

Avatar

Florian Pichler pichfl

View GitHub Profile
@pichfl
pichfl / incidence.js
Last active Dec 7, 2020 — forked from kevinkub/incidence.js
COVID-19 Inzidenz-Widget für iOS innerhalb Deutschlands 🇩🇪 - Ich empfehle die Nutzung des Originals! https://gist.github.com/kevinkub/46caebfebc7e26be63403a7f0587f664
View incidence.js
// Forked from Keven Kub.
// See https://gist.github.com/kevinkub/46caebfebc7e26be63403a7f0587f664
// Licence: Robert Koch-Institut (RKI), dl-de/by-2-0
const apiUrl = ({ longitude, latitude }) =>
`https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=1%3D1&outFields=GEN,cases7_per_100k&geometry=${longitude.toFixed(
3
)}%2C${latitude.toFixed(
3
)}&geometryType=esriGeometryPoint&inSR=4326&spatialRel=esriSpatialRelWithin&returnGeometry=false&outSR=4326&f=json`;
@pichfl
pichfl / MiteEntries.js
Last active Oct 6, 2020
https://scriptable.app script for your own mite.yo.lk widget. Fill in API key and account as necessary.
View MiteEntries.js
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: orange; icon-glyph: stopwatch;
// mite.yo.lk API key
let apikey = '';
let account = '';
// ---
async function loadEntries() {
View .finicky.js
module.exports = {
defaultBrowser: 'Safari',
handlers: [
// Anything localhost should open in Edge
{
match: finicky.matchHostnames(['localhost']),
browser: 'Microsoft Edge',
},
// Launch Google Meet on my third user account
@pichfl
pichfl / example.hbs
Last active May 21, 2020
Media query helper for Ember.js
View example.hbs
{{#if (match-media "(max-width:800px)")}}
MediaQuery matches
{{ else}}
MediaQuery doesn't match
{{/if}}
@pichfl
pichfl / now.json
Last active May 4, 2019
Now.sh config for Ember.js projects
View now.json
{
"version": 2,
"name": "your-ember-app-name",
"builds": [{ "src": "package.json", "use": "@now/static-build" }],
"routes": [
{ "handle": "filesystem" },
{ "src": ".*", "dest": "/index.html" }
]
}
@pichfl
pichfl / UIImage+EdgeColor.swift
Created Apr 30, 2018
Calculate the average color of the edges of an UIImage
View UIImage+EdgeColor.swift
import UIKit
extension UIImage {
func edgeColor(_ insets: UIEdgeInsets = UIEdgeInsets(top: 10.0, left: 10.0, bottom: 10.0, right: 10.0), defaultColor: UIColor = .black) -> UIColor {
guard let pixelData = self.cgImage?.dataProvider?.data else {
return defaultColor
}
let data: UnsafePointer<UInt8> = CFDataGetBytePtr(pixelData)
let width = Int(self.size.width * self.scale)
View gist:675a95f4c3d7fcb6ea7d4fda95084ff5
Verifying my Blockstack ID is secured with the address 13GbhHKSAZRByGrREAcsTZwsjXm6YW2AwG https://explorer.blockstack.org/address/13GbhHKSAZRByGrREAcsTZwsjXm6YW2AwG
@pichfl
pichfl / simple-server.js
Created Jun 6, 2017
Never try to use this somewhere in production. Ever. I had to put this somewhere as I wrote this server without having access to any online docs, only an offline dump of the Node.js docs. Also no linter nor proper editor. For that I think, it turned out to be rather okay.
View simple-server.js
const http = require('http');
const { statSync, readFileSync, createReadStream } = require('fs');
const { join, extname, basename } = require('path');
const { networkInterfaces } = require('os');
const port = 3000;
const cwd = join(__dirname, 'dist');
const defaultFile = join(cwd, 'index.html');
const maxAge = 24 * 3600;
const mimeTypes = {
@pichfl
pichfl / components.a-button.js
Last active Apr 27, 2017
Button Interaction inside translation
View components.a-button.js
import Ember from 'ember';
var htmlEscapes = [
{
char: /&/gim,
repl: '&amp;',
},
{
char: /</gim,
repl: '&lt;',
View components.a-component.js
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'button',
result: 0,
click() {
this.set('result', Math.random());
const result = this.get('result');
You can’t perform that action at this time.