This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f1 <- function (n) { | |
l <- list() | |
for(idx in 1:n) { | |
l <- append(l, idx) | |
} | |
return(l) | |
} | |
f2 <- function (n) { | |
l <- list() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ++++++++++++++++++++- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() { | |
StdDevCalc c, c2; | |
StdDevCalcKnuth k, k2; | |
for(int i = 0; i < 100; i++) { | |
c.append(i); // Small values | |
k.append(i); | |
c2.append((double) i * 3e151); // Very very large values | |
k2.append((double) i * 3e151); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StdDevCalcKnuth { | |
private: | |
long long m_count; | |
double m_meanPrev, m_meanCurr, m_sPrev, m_sCurr, m_varianceCurr; | |
public: | |
StdDevCalcKnuth() { | |
m_count = 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StdDevCalc { | |
private: | |
long long m_count; | |
double m_sum_sq, m_sum, m_var; | |
public: | |
StdDevCalc() { | |
m_sum_sq = m_sum = m_var = m_count = 0; | |
} | |
void append(double d) { |