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
# For remembering the little details. | |
# To get the FFT bins to line up perfectly, without any "skirts", | |
# you need to make a perfect cycle, where the next sample *after* | |
# this chunk lines up with the first. | |
from __future__ import division | |
# Sampling rate | |
fs = 128 # Hz |
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
print "hello,world"; | |
my $aa = 100; | |
my $bb = 200; | |
my $cc = 3000; | |
print "\n"; | |
print $aa+$bb+$cc; |
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 = 4; | |
print $var, "\n"; | |
&hello; | |
print $var, "\n"; | |
# subroutines | |
sub hello { | |
local $var = 10; | |
print $var, "\n"; | |
&gogo; # calling subroutine gogo |
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
#splice function | |
my @X = (0..10); | |
print join(" ",@X); | |
my @Y = splice(@X,10,1); | |
print "\nafter splice:"; | |
print join(" ",@X); | |
print "\nthe splice result:"; | |
print join(" ",@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
#use function as arugment of other function | |
sub add | |
{ | |
my $x =shift; | |
my $y = shift; | |
return $x + $y; | |
} | |
sub minus | |
{ |
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 Node: | |
def __init__(self,value,next=None): | |
self.value = value | |
self.next = next |
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
# -*- coding: utf-8 -*- | |
""" | |
Created on Tue Nov 27 13:02:53 2012 | |
@author: qzhang | |
""" | |
import re | |
#brute force solution 1 and 2 | |
#algorithm solution 3 |
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
# -*- coding: utf-8 -*- | |
""" | |
Created on Tue Nov 27 14:26:17 2012 | |
@author: qzhang | |
Given a array of integers , find 3 indexes i,j,k such that, | |
i<j<k and a[i] < a[j] < a[k]. Best possible is a O(n) algorithm. | |
""" | |
#brute force answer |
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 BaseBase(object): | |
def method(self): | |
print "BaseBase" | |
a = BaseBase() | |
a.method() | |
class Base1(BaseBase): | |
pass |
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 A(object): | |
def __init__(self): | |
print "A" | |
super(A, self).__init__() | |
class B(object): | |
def __init__(self): | |
print "B" | |
super(B, self).__init__() | |
OlderNewer