Skip to content

Instantly share code, notes, and snippets.

View MicTech's full-sized avatar
😎
make product people want

Michal Těhník MicTech

😎
make product people want
View GitHub Profile
@MicTech
MicTech / hash_deep_diff.rb
Created December 27, 2017 09:35
Recursively diff two Ruby hashes.
# Recursively diff two hashes, showing only the differing values.
# By Henrik Nyh <http://henrik.nyh.se> 2009-07-14 under the MIT license.
#
# Example:
#
# a = {
# "same" => "same",
# "diff" => "a",
# "only a" => "a",
# "nest" => {
module CodeRetreat
open Xunit
type Cell =
| DeadCell of int
| LiveCell of int
let hasChanceToLife (cell:Cell) =
match cell with
@MicTech
MicTech / config.ru
Created December 27, 2017 09:34
The Rack::TryStatic middleware delegates requests to Rack::Static middleware trying to match a static file
# config.ru
# The Rack::TryStatic middleware delegates requests to Rack::Static middleware
# trying to match a static file
#
# Inspired by original code from rack-contrib
# http://github.com/rack/rack-contrib/blob/master/lib/rack/contrib/try_static.rb
#
module Rack
@MicTech
MicTech / gist:f481293a6528b326835087a2f94a3356
Created December 27, 2017 09:34
Batch: Date and time in custom format
: http://stackoverflow.com/questions/203090/how-to-get-current-datetime-on-windows-command-line-in-a-suitable-format-for-us
@ECHO off
set v_day=
set v_month=
set v_year=
SETLOCAL ENABLEEXTENSIONS
if "%date%A" LSS "A" (set toks=1-3) else (set toks=2-4)
::DEBUG echo toks=%toks%
for /f "tokens=2-4 delims=(-)" %%a in ('echo:^|date') do (
@MicTech
MicTech / fibonacci.js
Created December 27, 2017 09:34
Fibonacci number benchmark
// fibonacci(40) takes 2 seconds in Node.js 0.6.14
// http://en.wikipedia.org/wiki/Fibonacci_number
function fibonacci(n) {
return n < 2 ? n : fibonacci(n-2) + fibonacci(n-1);
}
@MicTech
MicTech / active.md
Created December 27, 2017 09:34
Most active GitHub users (by contributions). http://twitter.com/paulmillr

Most active GitHub users (git.io/top)

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Tue, 06 Dec 2016 17:06:46 GMT till Wed, 06 Dec 2017 17:06:46 GMT.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
 .filter(user =&gt; user.followers &gt; 1000)
@MicTech
MicTech / gist:8f3afd3767e62bda3a5a5aec6723d76e
Created December 27, 2017 09:34
World Map Geo JSON data
var countries_data = {"type":"FeatureCollection","features":[
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[74.92,37.24],[74.57,37.03],[72.56,36.82],[71.24,36.13],[71.65,35.42],[71.08,34.06],[69.91,34.04],[70.33,33.33],[69.51,33.03],[69.33,31.94],[66.72,31.21],[66.26,29.85],[62.48,29.41],[60.87,29.86],[61.85,31.02],[60.84,31.5],[60.58,33.07],[60.94,33.52],[60.51,34.14],[61.28,35.61],[62.72,35.25],[63.12,35.86],[64.5,36.28],[64.8,37.12],[66.54,37.37],[67.78,37.19],[69.32,37.12],[70.97,38.47],[71.59,37.9],[71.68,36.68],[73.31,37.46],[74.92,37.24]]]]},"properties":{"name":"Afghanistan"},"id":"AF"},
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[19.44,41.02],[19.37,41.85],[19.65,42.62],[20.07,42.56],[20.59,41.88],[20.82,40.91],[20.98,40.86],[20.01,39.69],[19.29,40.42],[19.44,41.02]]]]},"properties":{"name":"Albania"},"id":"AL"},
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[2.96,36.8],[8.62,36.94],[8.18,36.52],[8.25,34.64],[7.49,33.89],[9.06,3
@MicTech
MicTech / reactive-2015.md
Created December 27, 2017 09:33
Advanced React.js Performance - Reactive 2015 Lightning Talk Proposal

Note: This is a submission for a Reactive2015 lightning talk. If you'd like to see a lightning talk about this (or read a detailed blog post if you are not going for the conference), vote for it by starring this gist! Thanks a lot!

Advanced React.js Performance

Performance is one of the reasons why React.js is so popular for building complex, highly interactive web applications. It became the go-to library for developers who don’t like to make compromises for technical reasons when building awesome user experiences. However even with React.js it still can be easy to hit it’s performance limits.

In this lightning talk Daniel will go beyond the basics of shouldComponentUpdate and immutable data structures and will discuss how to correctly instrument, measure and optimize performance in complex React apps. He will help you understand the overhead of different parts of the React component lifecycle, how some of it’

Keybase proof

I hereby claim:

  • I am mictech on github.
  • I am mictech (https://keybase.io/mictech) on keybase.
  • I have a public key whose fingerprint is 7FE5 8B6F 1BD6 DC59 9AD4 7F54 932D 02C8 5E02 FE7F

To claim this, I am signing this object:

@MicTech
MicTech / gist:ddd0a15249d9250a50ad
Last active August 29, 2015 14:22
Ansible notes

Change location of hosts file

  • create your own ansible.cfg

    [defaults]  
    inventory = /path/to/hosts
    

Ping all hosts