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 / intersection.py
Created December 31, 2011 19:53
Line segment intersection
def intersects(line_1, line_2):
"""Whether line_1 and line_2 intersect or not."""
A, B = line_1
C, D = line_2
if _ccw(A,C,D) != _ccw(B,C,D) and _ccw(A,B,C) != _ccw(A,B,D):
# If the triangle pairs ACD, BCD and ABC, ABD have different
# orientations, then the segments have to intersect
return True
for pt in line_2:
@musically-ut
musically-ut / test_intersection.py
Created December 31, 2011 19:54
Testing line intersections.
def test_intersects():
line_1 = ((0, 0), (1, 1))
line_2 = ((2.5, 2.5), (1.5, 1.5)) # No intersection
assert not intersects(line_1, line_2)
line_1 = ((0, 0), (1, 1))
line_2 = ((0, 0.5), (1, 0.5)) # Intersects
assert intersects(line_1, line_2)
line_1 = ((0, 0), (1, 1))
@musically-ut
musically-ut / cmd_list.txt
Created December 31, 2011 20:23
Command history
[21:15] utkarsh@Arrakis:~/prog$ history | awk '{print $2}' | sort | uniq -c | sort -rn
74 ./a.out
62 git
53 gcc
48 cd
44 cat
40 exit
35 ll
29 ls
18 man
@musically-ut
musically-ut / 0001-Notification-rating-plugin.patch
Created March 5, 2012 15:33
Rhythmbox patch for Ratings in notification.
From 15b12ffc5b4b22ab104cf796e7173db4eeaefe90 Mon Sep 17 00:00:00 2001
From: Utkarsh Upadhyay <musically.ut@gmail.com>
Date: Fri, 2 Mar 2012 11:56:32 +0530
Subject: [PATCH] Notification rating plugin.
---
data/org.gnome.rhythmbox.gschema.xml | 10 +
plugins/notification/Makefile.am | 6 +
plugins/notification/notification-preferences.ui | 28 +++
plugins/notification/rb-notification-plugin.c | 243 ++++++++++++++++++++-
@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 / gist:3195033
Created July 28, 2012 22:37
Setting colors for my R-console.
# Copy this to your .Rprofile
library('colorout')
setOutputColors256(
normal = 40,
number = 214,
string = 85,
const = 35,
stderror = 45,
error = c(1, 0, 1),
warn = c(1, 0, 100)
@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 / README.md
Last active March 8, 2016 16:27 — forked from mbostock/.block
SunBurst with selection rotation

This example is an extension of the original example with the additional feature that clicking on a part of the graph will select it and rotate it to 90 deg.


A sunburst is similar to the treemap, except it uses a radial layout. The root node of the tree is at the center, with leaves on the circumference. The area (or angle, depending on implementation) of each arc corresponds to its value. Sunburst design by John Stasko. Data courtesy Jeff Heer.

@musically-ut
musically-ut / README.md
Last active December 12, 2015 08:49 — forked from mbostock/.block

This is an adaption of a Zoomable sunburst example with an added text box showing which item was last clicked.


Click on any arc to zoom in. Click on the center circle to zoom out.

A sunburst is similar to a treemap, except it uses a radial layout. The root node of the tree is at the center, with leaves on the circumference. The area (or angle, depending on implementation) of each arc corresponds to its value. Sunburst design by John Stasko. Data courtesy Jeff Heer.

@musically-ut
musically-ut / README.md
Last active December 12, 2015 08:59 — forked from mbostock/.block
Interacting with elements on brushes

This examples demonstrates how to use D3's brush component to implement focus + context zooming. Click and drag in the small chart below to pan or zoom.