Skip to content

Instantly share code, notes, and snippets.

Krzysztof Kowalczyk kjk

Block or report user

Report or block kjk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mikelehen
mikelehen / generate-pushid.js
Created Feb 11, 2015
JavaScript code for generating Firebase Push IDs
View generate-pushid.js
/**
* 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).
*/
View Makefile
# 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.
@dmitshur
dmitshur / Default (OSX).sublime-keymap
Created Nov 17, 2014
Add folder that contains current file to sidebar, for Sublime Text. Goes well with Cmd+.,Cmd+O of GoSublime until https://github.com/DisposaBoy/GoSublime/issues/553 is resolved.
View Default (OSX).sublime-keymap
[
// ... (existing content)
// Add folder that contains current file to sidebar.
{ "keys": ["f3"], "command": "add_to_project" },
// ...
]
@dmitshur
dmitshur / Default (OSX).sublime-keymap
Last active Aug 29, 2015
Sublime Text on OS X, make Cmd+F do the equivalent of Cmd+E followed by Cmd+F. Works for all selections, not just single line like "find_selected_text" setting.
View Default (OSX).sublime-keymap
[
// ... (existing content)
// Find selected text, even if it spans multiple lines (unlike "find_selected_text").
{ "keys": ["super+f"], "command": "run_multiple_commands", "args":
{ "commands":
[
// Only execute slurp if there's selected text.
{"command": "slurp_find_string", "context": "window", "condition": "selected_text"},
{"command": "show_panel", "args": {"panel": "find", "reverse": false}, "context": "window"}
@cryptix
cryptix / vineScrape.go
Created Aug 27, 2014
extract a javascript object value from a html page using goquery and otto
View vineScrape.go
package main
import (
"errors"
"log"
"os"
"github.com/PuerkitoBio/goquery"
"github.com/robertkrimen/otto"
)
@staltz
staltz / introrx.md
Last active Aug 25, 2019
The introduction to Reactive Programming you've been missing
View introrx.md
@cryptix
cryptix / client.go
Created Jun 22, 2014
multipart upload with io.Pipe
View client.go
package main
import (
"io"
"log"
"mime/multipart"
"net/http"
"os"
"path/filepath"
"runtime"
View install-new-relic.yml
---
- 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
View latency.markdown

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
@praeclarum
praeclarum / EasyLayout.cs
Last active Aug 19, 2019
**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.)
View EasyLayout.cs
//
// 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:
//
You can’t perform that action at this time.