Skip to content

Instantly share code, notes, and snippets.

View vkargov's full-sized avatar
💭
🌱

vkargov

💭
🌱
View GitHub Profile
@vkargov
vkargov / sort_yt_by_score.js
Last active April 15, 2019 23:05
sort Youtube videos by score and output top 10 into console
// NB: This is just a proof of concept, use at your own risk. You must have the videos page open for it to work.
// This helped a lot: https://javascript.info/promise-chaining
// find all chats
function parseScore(score) {
//console.log(`parsing score ${score}`)
var calcscore = parseFloat(score.replace('K', 'e3').replace('M', 'e6').replace(',', ''))
//console.log(`= ${calcscore}`)
return calcscore
}
@vkargov
vkargov / gist:708c38e809cb1d476e39a480e7f53f19
Created November 8, 2018 05:27
C4.5 upper error limit formula
In his seminal article "C4.5. Programs for Machine Learning." Quinlan uses a criterion U_CF for determining error limits in nodes of decision trees. This criterion is important as it drives the tree pruning heuristic. Problem is, no clear formula is provided in the article. However, the formula can be found in the source code for C4.5 and C5.0:
U_CF(E, N) ≡ RawExtraErrs(N, E)/N, with RawExtraErrs defined in pruning.c
To verify the article results, you can insert the following line into main() or whatever:
#define U_CF(E, N, expectation) printf("U_CF(%d, %d) = %0.3f (expected to be " #expectation ")\n", E, N, RawExtraErrs(N, E)/N)
@vkargov
vkargov / funk.js
Created July 3, 2018 20:39
make things funky
for (let e of document.getElementsByTagName('*'))
{
let rndc = () => Math.floor(Math.random()*255).toString()
let funkify = function(e) {
this.style.color="rgb(" + rndc() + ',' + rndc() + ',' + rndc()+")"
e.stopPropagation()
}.bind(e)
e.addEventListener('click', funkify)
}
// cat thoughts.dot | mono fold_labels.exe 40 | unflatten | dot -Tpdf > thoughts.pdf && open thoughts.pdf
// unflatten makes the graph less... flat
using System;
using System.Text;
using System.Text.RegularExpressions;
class Fold
{
static void FoldTillQuotes (StringBuilder s, int i, int maxlen)
@vkargov
vkargov / private.xml
Created May 18, 2016 05:21
My OSX/Karabiner keyboard layout...
<?xml version="1.0"?>
<root>
<name>My, ehm, stuff.</name>
<replacementdef>
<replacementname>WEIRDOAPPS</replacementname>
<replacementvalue><![CDATA[<only>EMACS, TERMINAL, X11, VIRTUALMACHINE</only>]]></replacementvalue>
</replacementdef>
<item>
<name>Command_R to Option_R (only in Emacs, Terminal, X11)</name>
<identifier>sitagi.cr_to_or</identifier>
@vkargov
vkargov / .xinitrc
Last active May 18, 2016 05:21
My Linux keyboard layout...
#!/bin/sh
# My crazy layout...
# command <=> alt
# control <=> capslock
# enter becomes "control" when not released instantly
# Should be as close to my osx/karabiner config as possible...
# Because XFCE is not cool, it resets the settings when calling xkbmap.
# So putting this into .xinitrc won't cut it.
@vkargov
vkargov / gist:29dc1141c041dd8801b1
Created February 16, 2016 13:46
mono trace comparison thing
#!/bin/sh
HEX="0x[0-9a-f]+"
convert () {
gunzip -cS '' $1 | grep -v _gc_ |
sed -E "s/^\\[$HEX: [0-9.]* [0-9]*\\] //" |
sed -E "s/$HEX//g" |
sed -E "s/TRUE:/result=/g" |
head -$2 > $1_$2