View unicode.js
// @see http://www.dpawson.co.uk/xsl/rev2/UnicodeCategories.html
// @see http://sputniktests.googlecode.com/svn/trunk/tests/Unicode
var UnicodeCategories = {
ZWNJ : /\u200C/,
ZWJ : /\u200D/,
TAB : /\u0009/,
VT : /\u000B/,
FF : /\u000C/,
SP : /\u0020/,
NBSP : /\u00A0/,
View jsmin.c
/* jsmin.c
2008-08-03
Copyright (c) 2002 Douglas Crockford (www.crockford.com)
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
View git_remote_init.sh
git init
git add .
git commit -m "First commit"
git remote add origin $GIT_REMOTE_ORIGIN
git remote -v
git pull --allow-unrelated-histories origin master
git push -u origin master
View awk_colums_substring.sh
awk -F"," 'BEGIN { OFS="" ; ORS="" } ; { for (i=1; i<9; i++ ) print $i ","; print substr($NF,0,20) "\n"}' file.csv
View gensim_word2vec_procrustes_align.py
def smart_procrustes_align_gensim(base_embed, other_embed, words=None):
"""Procrustes align two gensim word2vec models (to allow for comparison between same word across models).
Code ported from HistWords <https://github.com/williamleif/histwords> by William Hamilton <wleif@stanford.edu>.
(With help from William. Thank you!)
First, intersect the vocabularies (see `intersection_align_gensim` documentation).
Then do the alignment on the other_embed model.
Replace the other_embed model's syn0 and syn0norm numpy matrices with the aligned version.
Return other_embed.
View color_palette.js
/**
* Color Palette Helper
*/
var Palette = {
/**
* Generates a random palette of HSV colors. Attempts to pick colors
* that are as distinct as possible within the desired HSV range.
*
* @param {number} [options.numColors=10] - the number of colors to generate
* @param {number[]} [options.hRange=[0,1]] - the maximum range for generated hue
View array_objects_statistics.js
var arrayObjectStatistics = function(arr) {
var keys=[];
arr.forEach(a => Object.keys(a).forEach(k => keys.push(a[k])))
var stats=[...keys.reduce( (m, v) => m.set(v, (m.get(v) || 0) + 1), new Map() )].sort((a,b) => b[1]-a[1])
stats=stats.map(c => new Object({label: c[0], count: c[1], mean: parseInt(c[1])/arr.length}) )
return stats;
}
View map_reduce.js
var survey=[["Active","Chill Out","Cozy","Dancebale","Dark","Energetic","Feel Good","Funky","Happy","Motivating","Party","Warm","Youthful","Athletic","Dramatic","Joyous","Provocative","Rowdy","Spicy","Stylish","Sweet","Aggressive","Atmospheric","Gloomy","Introspective","Sprightly","Seductive","Sensual","Groovy","Sweet","Hypnotic","Optimistic","Active"],["Driving","Happy","Motivating","Warm","Cosmopolitan","Dramatic","Joyous","Provocative","Stylish","Aggressive","Angry","Gloomy","Introspective","Melancholic","Intimate","Optimistic","Reflective","Romantic","Sophisticated","Thrilling","Celebratory","Exciting","Erotic","Enigmatic","Exotic","Ironic","Irreverent","Apocalyptic","Funereal","Austere","Dreamy","Declamatory","Nostalgic","Passionate","Tragic","Trashy","Heroic","Majestic","Naive","Powerful","Mystical","Cheerful","Rebellious"],["Dark","Feel Good","Happy","Motivating","Youthful","Bravado","Dramatic","Joyous","Provocative","Triumphant","Aggressive","Angry","Introspective","Melancholic","Intimate","Optimistic
View wc_file_list.sh
#!/bin/bash
find $1 -maxdepth 1 -type f -print0 | xargs -0 wc | awk '{print $1 "\t" $4}'
View fasttext_confusion_matrix.py
#!/usr/local/bin/python3
# @author cpuhrsch https://github.com/cpuhrsch
# @author Loreto Parisi loreto@musixmatch.com
import argparse
import numpy as np
from sklearn.metrics import confusion_matrix
def parse_labels(path):
with open(path, 'r') as f: