Skip to content

Instantly share code, notes, and snippets.

@kujon
kujon / react-url-query.d.ts
Created Jun 6, 2018
react-url-query typings
View react-url-query.d.ts
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 Aug 9, 2016
Control Delegation
View ControlDelegation.jsx
class Child extends React.Component {
static defaultProps = {
type: 'text',
onChange: () => {},
value: ''
}
render() {
return <input {...this.props} />;
}
}
@kujon
kujon / samplerest.js
Last active Aug 27, 2015 — forked from joshbirk/samplerest.js
Sample of using passport w/ mult strategies
View samplerest.js
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')
@kujon
kujon / blud.js
Created Jul 10, 2015
Brototype plugin for London-based developers
View blud.js
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,
View injector.js
/**
* @constructor
*/
function Injector() {
/**
* @type {!Object.<string, function(Injector=): !Object>}
*/
this.factories = {};
@kujon
kujon / checked.js
Created Jun 5, 2012
JavaScript: Radio button and checkbox replacement
View checked.js
/**
* 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
JavaScript: Clamp a number.
View clamp.js
/**
* 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
CSS: Vertically streched container
View container.css
.streched {
height: auto;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
@kujon
kujon / color.js
Created May 10, 2012
JavaScript: one line color generator
View color.js
'#' + (function(h){return new Array(7-h.length).join("0")+h})((Math.random()*0x1000000<<0).toString(16))