Skip to content

Instantly share code, notes, and snippets.

@viktorkelemen
viktorkelemen / gist:7a887d3b076c00fa0652
Created January 5, 2015 12:27
Get used selectors from inline stylesheets
function getUsedSelectors() {
var allRules = [];
_.each(document.styleSheets, function (sheet) {
var rules;
if (sheet.rules) {
rules = _.map(sheet.rules, function (rule) {
return rule.selectorText;
});
@viktorkelemen
viktorkelemen / gist:7155e0c02f090f16b4e4
Created April 30, 2014 13:45
An URL shortener algorithm
var codeset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var base = codeset.length;
function encode(n) {
var converted = "";
while (n > 0) {
converted = converted + codeset[n%base];
n = Math.floor(n/base);
@viktorkelemen
viktorkelemen / gist:2e7d6f6cf95bb2b3b117
Last active August 29, 2015 14:00
Open an Explorer Window from the CMD on Win7
explorer .
start .
explorer c:\some\folder\path
start %systemroot%
@viktorkelemen
viktorkelemen / 0_reuse_code.js
Created April 16, 2014 16:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@viktorkelemen
viktorkelemen / gist:9862779
Last active August 29, 2015 13:57
Extracting white noise statistics in GPS coordinate time series
First a GPS time series is decomposed into sub-time series using the EMD. Then the Hurst parameter is estimated for each sub-time series. Finally the sub-time series with H ≤ 0.5 are selected to extract the statistics of the white noise.
1. EMD (Empirical Mode Decomposition)
http://www.slideshare.net/EMYJANE/empirical-mode-decomposition
http://www.slideshare.net/puneet4gupta/hilbert-huang-transformhht
https://github.com/jaidevd/pyhht/blob/master/EMD.py
The EMD method consists of decomposing a time series, x(t), into sub-series, also called Intrinsic Mode Function (IMF). The decomposition of x(t) is done via the study of consecutive local extrema (i.e. two minima in the time interval [t1, t2]).
Each IMF is the result of applying a different band-pass filter with certain cutoff frequencies.
@viktorkelemen
viktorkelemen / gist:9232645
Last active August 29, 2015 13:56
Show the number of lines added and removed by an author
git log --author="YOUR_NAME" --pretty=tformat: --numstat \
| gawk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines : %s total lines: %s\n",add,subs,loc }' -
@viktorkelemen
viktorkelemen / gist:7068664
Last active December 26, 2015 00:59
Remove "Move to Dropbox" as option from two-finger click menu on Mac
sudo rm -rf /Library/DropboxHelperTools
@viktorkelemen
viktorkelemen / gist:6340572
Created August 26, 2013 11:37
Solving the airplay problem
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
@viktorkelemen
viktorkelemen / gist:5941157
Last active December 19, 2015 10:29
Reversed Binary Numbers
/*
Task
Your task will be to write a program for reversing numbers in binary.
For instance, the binary representation of 13 is 1101,
and reversing it gives 1011, which corresponds to number 11.
Input
The input contains a single line with an integer N, 1 ≤ N ≤ 1000000000.
Output
@viktorkelemen
viktorkelemen / local.yml
Created April 30, 2013 12:50
My Vagrant config/local.yml
memory_size: 8192
cpu_count: 4