Skip to content

Instantly share code, notes, and snippets.

@fi11
fi11 / switch.js
Created September 20, 2018 08:29
function render() {
switch(this.state) {
case LOGIN_STATE:
return <Login/>
case SUCCESS_STATE:
return <Success/>
default:
return <Login />
}
}
if (curr.type === 'validationError') {
const fieldName = curr.payload.name;
const error = curr.payload.error;
return acc.map((key, field) => {
if (key === fieldName && !field.getValue()) {
return field.setError(error);
}
return field;
@fi11
fi11 / file.js
Created May 4, 2018 09:51
file.js
'use strict';
export const fileDownloader = (res) => {
var filename = '';
let contentDisposition = res.headers.get('Content-Disposition');
if (contentDisposition && contentDisposition.indexOf('attachment') !== -1) {
let filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
let matches = filenameRegex.exec(contentDisposition);
import Dispatcher from '@uikit/dispatcher';
const dispatcher = new Dispatcher();
// register callback
const removeListener = dispatcher.register((message) => {
console.log(message);
});
// dispatch message
@fi11
fi11 / quantize.js
Created December 23, 2016 08:55 — forked from nrabinowitz/quantize.js
Javascript module for color quantization, based on Leptonica
/*!
* quantize.js Copyright 2008 Nick Rabinowitz.
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
// fill out a couple protovis dependencies
/*!
* Block below copied from Protovis: http://mbostock.github.com/protovis/
* Copyright 2010 Stanford Visualization Group
* Licensed under the BSD License: http://www.opensource.org/licenses/bsd-license.php
http {
map $http_user_agent $limit_bots {
default '';
~*(google|bing|yandex|msnbot) $binary_remote_addr;
}
limit_req_zone $limit_bots zone=bots:10m rate=1r/m;
server {
@fi11
fi11 / my.cnf
Last active December 27, 2015 18:29
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
character-set-server=utf8
collation_server=utf8_unicode_ci
slow_query_log=1
slow_query_log_file=slow-queries.log
#!/bin/bash
#
# supervisord This scripts turns supervisord on
#
# Author: Mike McGrath <mmcgrath@redhat.com> (based off yumupdatesd)
#
# chkconfig: - 95 04
#
# description: supervisor is a process control utility. It has a web based
# xmlrpc interface as well as a few other nifty features.