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
; Purely functional implementation of Set data structure | |
(define set-init | |
(lambda (x) #false)) | |
(define (set-add set x) | |
(lambda (y) | |
(if (= x y) | |
#true | |
(set y)))) |
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
(define (seq lst last) | |
(if (empty? lst) | |
0 | |
(if (< last (first lst)) | |
(max (add1 (seq (rest lst) (first lst))) | |
(seq (rest lst) last)) | |
(seq (rest lst) last)))) |
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
#!/usr/bin/env python | |
# | |
# Script to send SMS via way2sms | |
# | |
# @author Vishesh Yadav | |
# @license BSD License | |
# | |
#TODO: Phonebook |
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
#!/usr/bin/python2 | |
# | |
# Longest Common Subsequence problem | |
# Just implements simple lcs function. One solution, not all. | |
def lcs(x, y): | |
if len(x) == 0 or len(y) == 0: | |
return "" | |
elif x[-1:] == y[-1:]: | |
return lcs(x[:-1], y[:-1]) + x[-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
import threading | |
def threadify(func): | |
def run(*fargs, **fkwargs): | |
t = threading.Thread(target=func, args=fargs, kwargs=fkwargs) | |
t.start() | |
return run | |
@threadify | |
def function_a(): |
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
#!/usr/bin/env python | |
# | |
# BillBoard problem solution | |
# Vishesh Yadav | |
# | |
# Note: Lot many easy optimizations can be made, but for the sake of | |
# clarity, let it be. | |
# | |
from math import sqrt |
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
/** | |
* Time Difference | |
* | |
* function : timeDiff(t1, t2) | |
* timeformat : 'HOUR:MINUTES' | |
* | |
*/ | |
function timeInHours(str) | |
{ |
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
var user = { | |
validateCredentials: function (username, password) { | |
return ( | |
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' } | |
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' } | |
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' } | |
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' } | |
: (!/^([a-z0-9-_]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' } | |
: false | |
); |
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
Index: Makefile.common | |
=================================================================== | |
RCS file: /cvsroot/pkgsrc/editors/vim-share/Makefile.common,v | |
retrieving revision 1.143 | |
diff -u -p -r1.143 Makefile.common | |
--- Makefile.common 31 Oct 2010 23:50:51 -0000 1.143 | |
+++ Makefile.common 13 May 2012 10:52:19 -0000 | |
@@ -76,7 +76,7 @@ ALTERNATIVES_SRC= ${.CURDIR}/../../edito | |
ALTERNATIVES_SRC= | |
.endif |
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
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns | |
Compress 1K bytes with Zippy 3,000 ns | |
Send 2K bytes over 1 Gbps network 20,000 ns | |
Read 1 MB sequentially from memory 250,000 ns | |
Round trip within same datacenter 500,000 ns | |
Disk seek 10,000,000 ns |
OlderNewer