Skip to content

Instantly share code, notes, and snippets.

View pichfl's full-sized avatar
👨‍🎨
No mistakes, only happy accidents.

Florian Pichler pichfl

👨‍🎨
No mistakes, only happy accidents.
View GitHub Profile
{
"data": {
"id": "43917710-36f0-4e41-9767-786f744fb1bd",
"type": "containeroutlet",
"attributes": {
"position": 0,
"name": "Any Layout",
"is_searchable": false,
"help_text": "Any description for any layout",
"is_array": false
// sample array
const rolling = [2, 4, 6, 8, 15];
// Returns the average of an array of numeric values
function average(arr) {
// .reduce() with a simple callback creates the sum of all values inside the array
// dividing by the length of the array to get the average
return arr.reduce((a, b) => a + b) / arr.length;
}
const argv = require('minimist')(process.argv.slice(2));
const readFileSync = require('fs').readFileSync;
const join = require('path').join;
const configFilePath = argv.config;
const config = JSON.parse(readFileSync(join(__dirname, '..', 'config.json')));
if (configFilePath) {
// Read config file defined by param from disk
const configFile = readFileSync(configFilePath);
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 6,
sourceType: 'module'
},
extends: 'airbnb-base',
env: {
'node': true
@pichfl
pichfl / Usage.hbs
Last active December 14, 2016 13:57
In need for snow in your ember app?
{{!-- Fullscreen --}}
{{x-snow fullscreen=true}}
{{!-- Fixed size --}}
{{x-snow width=1000 height=200}}
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'button',
result: 0,
click() {
this.set('result', Math.random());
const result = this.get('result');
@pichfl
pichfl / components.a-button.js
Last active April 27, 2017 11:06
Button Interaction inside translation
import Ember from 'ember';
var htmlEscapes = [
{
char: /&/gim,
repl: '&',
},
{
char: /</gim,
repl: '&lt;',
@pichfl
pichfl / simple-server.js
Created June 6, 2017 20:19
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.
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 = {
Verifying my Blockstack ID is secured with the address 13GbhHKSAZRByGrREAcsTZwsjXm6YW2AwG https://explorer.blockstack.org/address/13GbhHKSAZRByGrREAcsTZwsjXm6YW2AwG
@pichfl
pichfl / UIImage+EdgeColor.swift
Created April 30, 2018 21:44
Calculate the average color of the edges of an UIImage
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)