Skip to content

Instantly share code, notes, and snippets.

View kjk's full-sized avatar

Krzysztof Kowalczyk kjk

View GitHub Profile
@staltz
staltz / introrx.md
Last active April 25, 2024 04:18
The introduction to Reactive Programming you've been missing
@6174
6174 / Random-string
Created July 23, 2013 13:36
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@mikelehen
mikelehen / generate-pushid.js
Created February 11, 2015 17:34
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@cryptix
cryptix / vineScrape.go
Created August 27, 2014 12:31
extract a javascript object value from a html page using goquery and otto
package main
import (
"errors"
"log"
"os"
"github.com/PuerkitoBio/goquery"
"github.com/robertkrimen/otto"
)
@mridgers
mridgers / pdbdump.c
Created June 21, 2012 21:19
Small tool to list and query symbols in PDB files.
//------------------------------------------------------------------------------
// pdbdump.c - dump symbols from .pdb and executable files (public domain).
// - to compile; cl.exe /Ox /Zi pdbdump.c
// -
// - Martin Ridgers, pdbdump 'at' fireproofgravy.co.uk
//------------------------------------------------------------------------------
#include <stdio.h>
#include <Windows.h>
#include <DbgHelp.h>
@sma
sma / README.md
Last active July 4, 2023 06:28
This is an ad-hoc Java-to-Dart translator written in three days. This is version 2 which some bug fixes.

Java to Dart

This is an ad-hoc Java-to-Dart translator originally written on two (admittedly long) evenings.

See http://sma.github.io/stuff/java2dartweb/java2dartweb.html for a demo.

Note: It doesn't support the complete Java grammar specification and cannot translate everything. It only translates syntax and does not attempt to translate Java library classes and methods to Dart equivalents (with the exception of String.charAt and StringBuffer.append). You will have to make changes to the resulting Dart code. It does not support anonymous inner classes.

However, I was able to successfully convert a 7000+ line command line application with only minimal fixes in 30 minutes.

@praeclarum
praeclarum / EasyLayout.cs
Last active April 21, 2023 10:28
**OUT OF DATE** Please use the NuGet package https://www.nuget.org/packages/EasyLayout or the code on GitHub https://github.com/praeclarum/EasyLayout. (EasyLayout makes writing auto layout code in Xamarin.iOS easier. See [the example](https://gist.github.com/praeclarum/8185036) for hints on how to use this library.)
//
// Copyright (c) 2013-2015 Frank A. Krueger
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
---
- name: Register New Relic repository.
get_url: url=http://download.newrelic.com/debian/newrelic.list
dest=/etc/apt/sources.list.d/newrelic.list
- name: Download repo key.
apt_key: url=http://download.newrelic.com/548C16BF.gpg
- name: Install New Relic.
apt: pkg=newrelic-sysmond update_cache=yes

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns                     on recent CPU
L2 cache reference ........................... 7 ns                     14x L1 cache
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns                     20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs 4X memory