Skip to content

Instantly share code, notes, and snippets.

View musically-ut's full-sized avatar
🐙
🐢 🎣 🐠

Utkarsh Upadhyay musically-ut

🐙
🐢 🎣 🐠
View GitHub Profile
@musically-ut
musically-ut / KnuthStdDev.cpp
Created December 20, 2011 15:55
Knuth's numerically stable standard deviation calculation
class StdDevCalcKnuth {
private:
long long m_count;
double m_meanPrev, m_meanCurr, m_sPrev, m_sCurr, m_varianceCurr;
public:
StdDevCalcKnuth() {
m_count = 0;
}
@musically-ut
musically-ut / poor_man_parallel.sh
Last active April 1, 2019 10:11
Poor man's parallel execution on servers
#!/usr/bin/env bash
set -e
for N in {1..5}
do
for M in {0.1,1,2,5,10};
do
# Replace ./my_prog.py with your program to run it in parallel
./my_prog.py -N $N -M $M > output/stdout_N${N}_M${M}.txt &
@musically-ut
musically-ut / list_creation_profiling.R
Created July 29, 2012 12:04
Four different ways of creating lists
f1 <- function (n) {
l <- list()
for(idx in 1:n) {
l <- append(l, idx)
}
return(l)
}
f2 <- function (n) {
l <- list()
@musically-ut
musically-ut / bench_semi_supervised_n_iter.py
Last active July 7, 2017 06:35 — forked from jnothman/bench_semi_supervised_n_iter
Benchmarking `sklearn.semi_supervised` `n_iter_` as a function of model and data characteristics
import numpy as np
from sklearn import datasets
from sklearn.semi_supervised import LabelPropagation, LabelSpreading
###for n_samples in [20, 200, 2000, 20000]:
### X, y = datasets.make_classification(n_samples=n_samples, n_classes=3, n_informative=3)
for (X, y) in [datasets.load_iris(return_X_y=True)]:
for model in [LabelPropagation(max_iter=1000),
#LabelSpreading(alpha=0.01),
#LabelSpreading(alpha=0.1),
#LabelSpreading(alpha=0.3)
@musically-ut
musically-ut / update_server.sh
Created March 16, 2017 23:14
Setting up a new server by copying config files from local computer.
#!/bin/bash
set -e
set -u
set -o pipefail
if [ -z $1 ]
then
echo "Usage: $0 [user@]servername"
exit 1
@musically-ut
musically-ut / 0001-Ratings-in-notifications.patch
Created March 17, 2012 08:09
Rhythmbox patch for Ratings in notification.
From 8a07f968d5185e23ec089669b1d2e2c65ccdcf68 Mon Sep 17 00:00:00 2001
From: Utkarsh Upadhyay <musically.ut@gmail.com>
Date: Sat, 17 Mar 2012 13:14:45 +0530
Subject: [PATCH] Ratings in notifications.
1. Adds buttons to rate the playing entry from the song-change/status-icon notification itself.
2. Adds configuration UI to enable/disable the rating buttons.
---
data/org.gnome.rhythmbox.gschema.xml | 10 +
plugins/notification/Makefile.am | 6 +
@musically-ut
musically-ut / 4 dots puzzle.md
Created September 16, 2016 16:40
4 dots puzzle

4 dots puzzle

Initial position: There are 4 dots arranged as a square on a grid.

Move: The dots can be moved by reflecting them through any other three dots. So to move a point, draw a line segment from that dot to another dot, extend it to twice its length and move the first dot to the place where it terminates.

Question: Is it possible to transform the square into another square of a larger size?


@musically-ut
musically-ut / pre-commit.no-git.sh
Last active August 14, 2016 05:18
Pre-commit hook to avoid committing lines with '#NO-GIT"
#!/bin/sh
PAT='#\s*NO(.)?GIT'
git diff --cached --name-only | \
xargs egrep -i --color --with-filename -n "$PAT" && echo "Found '"$PAT"' in code about to be committed. Rejecting commit." && exit 1
# Exit with error code zero if all went well.
exit 0
@musically-ut
musically-ut / README.md
Last active July 7, 2016 18:56
Bubble treemap with better labels

This is an example of how one might place the intermediate labels on circle-packing graphs using the circle-text plugin.

Transitions on position and radius of the path are now possible. Click on the circles to see them in action.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.