Skip to content

Instantly share code, notes, and snippets.

Hi Akira!
@zuk
zuk / byte_operations.js
Created March 19, 2010 22:04
How to convert between integers and bytes in JavaScript
// Here's how to do basic integer<->byte (string/char) operations in JavaScript.
// Took me a good while to dig this up.
function intToChar(integer) {
return String.fromCharCode(integer)
}
function charToInt(char) {
return char.charCodeAt(0)
}
@zuk
zuk / chainable_proto_promise.js
Last active August 4, 2018 18:00
Proto-Proimse
function Promise() { };
Promise.prototype = {
then: function(cb) {
var p = new Promise();
this.resolve = function(v) {
var value = cb(v);
if (p.resolve) p.resolve(value);
};
return p;
}
import './Foo.scss'
export default class Foo extends React.Component {
render() {
const { someProp } = this.props
return (
<div className="Foo">
...
</div>

Keybase proof

I hereby claim:

  • I am zuk on github.
  • I am zuk (https://keybase.io/zuk) on keybase.
  • I have a public key ASBcP-PkF8fSEym3UrGtc3noRG-AH3dFlKDPCcReah2Gzwo

To claim this, I am signing this object:

@zuk
zuk / redux_denormalizr.js
Last active February 3, 2016 10:09
Denormalizr
// copied from https://github.com/dotcs/normalizr/blob/963f9297ef5c97866bc3e6de5cdef730155a3e09/src/index.js
// ... waiting until this gets merged into normalizr
// see https://github.com/gaearon/normalizr/pull/20
import isObject from 'lodash/lang/isObject'
import clone from 'lodash/lang/clone'
import { Schema as EntitySchema } from 'normalizr'
function visitObjectForDenorm(obj, schema, bag) {
var denormalized = {},
@zuk
zuk / vim_quickies
Created November 27, 2013 17:40
vim quickies
# re-run last command with sudo/root
:w !sudo tee %
@zuk
zuk / aborted_http_request.sh
Created June 6, 2013 16:51
Send aborted HTTP request for testing handling of broken requests
curl http://127.0.0.1:8080/ &
P=$!
sleep 0.008 && kill -9 $P
@zuk
zuk / Algae.tmTheme
Created May 14, 2013 15:33
Modified Sourlick Sublime Text 2 color theme for CoffeeScript
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Generated by: TmTheme-Editor -->
<!-- ============================================ -->
<!-- app: http://tmtheme-editor.herokuapp.com -->
<!-- code: https://github.com/aziz/tmTheme-Editor -->
<plist version="1.0">
<dict>
<key>name</key>
<string>Algae</string>
import scala.io.Source
import scala.util.matching.Regex
import scala.collection._
object Spreadsheet extends App {
val RefFormat = new Regex("([a-z]+)([1-9]+)", "row", "col")
val LineFormat = new Regex("^([a-z]+)([1-9]+):(.*)", "row", "col", "expr")
val ExprInt = new Regex("(-?\\d+)", "v")
val ExprFloat = new Regex("(-?\\d+\\.\\d+)", "v")