Skip to content

Instantly share code, notes, and snippets.

@kujon
kujon / react-url-query.d.ts
Created June 6, 2018 16:16
react-url-query typings
declare module 'react-url-query' {
import * as React from 'react';
type Dictionary<T = string> = {
[key: string]: T;
};
export const UrlQueryParamTypes: {
number: 'number';
string: 'string';
@kujon
kujon / ControlDelegation.jsx
Last active August 9, 2016 13:38
Control Delegation
class Child extends React.Component {
static defaultProps = {
type: 'text',
onChange: () => {},
value: ''
}
render() {
return <input {...this.props} />;
}
}
@kujon
kujon / samplerest.js
Last active August 27, 2015 22:24 — forked from joshbirk/samplerest.js
Sample of using passport w/ mult strategies
var fs = require("fs")
var ssl_options = {
key: fs.readFileSync('privatekey.pem'),
cert: fs.readFileSync('certificate.pem')
};
var port = process.env.PORT || 3000;
var express = require('express');
var ejs = require('ejs');
var passport = require('passport')
#sync-settings
@kujon
kujon / blud.js
Created July 10, 2015 16:52
Brototype plugin for London-based developers
var Blud = Bro;
Blud.NANG = Bro.TOTALLY;
Blud.DRED = Bro.NOWAY;
var methods = {
// Blud(blud1).manz('sket')
manz: Bro.prototype.doYouEven,
// Blud(blud1).dash('puff')
dash: Bro.prototype.iCanHaz,
/**
* @constructor
*/
function Injector() {
/**
* @type {!Object.<string, function(Injector=): !Object>}
*/
this.factories = {};
@kujon
kujon / checked.js
Created June 5, 2012 13:34
JavaScript: Radio button and checkbox replacement
/**
* Radio button and checkbox replacement
* Author: Jakub Korzeniowski
* Agency: Softhis
* http://www.softhis.com
*/
(function($) {
$.fn.checked = function() {
@kujon
kujon / clamp.js
Created May 24, 2012 13:13
JavaScript: Clamp a number.
/**
* Clamps a number. Based on Zevan's idea: http://actionsnippet.com/?p=475
* params: val, min, max
* Author: Jakub Korzeniowski
* Agency: Softhis
* http://www.softhis.com
*/
(function(){Math.clamp=function(a,b,c){return Math.max(b,Math.min(c,a));}})();
@kujon
kujon / container.css
Created May 24, 2012 10:56
CSS: Vertically streched container
.streched {
height: auto;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
@kujon
kujon / color.js
Created May 10, 2012 14:54
JavaScript: one line color generator
'#' + (function(h){return new Array(7-h.length).join("0")+h})((Math.random()*0x1000000<<0).toString(16))