Skip to content

Instantly share code, notes, and snippets.

View elee's full-sized avatar

Eric Lee elee

View GitHub Profile
use strict;
use warnings;
# output:
# foo
# bar
combine({
name => "foo",
surname => "bar"
We couldn’t find that file to show.
if os.path.exists('/private/tmp/corehist.txt'):
with open('/private/tmp/corehist.txt', 'r') as f:
int_from_file = int(f.readline())
if my_int != int_from_file:
f.seek(0)
f.writeline(new_int_value)
else:
with open('/private/tmp/corehist.txt', 'w+') as f:
f.write(42)
import os
coredir = "/etc/sv/core"
histfile = "/tmp/corehist.txt"
dirlist = os.listdir(coredir)
dirlist.remove("core")
dirlist.count
with open(histfile, 'w') as f:
value_in_file = f.readline()
import os
import fnmatch
import re
coredir = '/etc/sv/core'
# with fnmatch
cores = [file for file in os.listdir(coredir) if fnmatch.fnmatch(file, 'core.*')]
# with re.compile
import fnmatch
import os
coredir = "/Users/cwj/Dropbox/Needle/corecheck/test"
histfile = "/Users/cwj/Dropbox/Needle/corecheck/corehist.txt"
cores = [file for file in os.listdir(coredir) if fnmatch.fnmatch(file, 'core.*')]
if os.path.exists(histfile):
with open(histfile, 'w') as f:
GIRUGAMESH:~ $ python -c 'import sys; print "\n".join(["%s %s" % (i, v) for i, v in enumerate(sys.path)])'
function [vega] = calculate_vega(S,K,r,T,sigma,N,q,option_parity,option_type)
vol_change = 0.01;
% change constantly volatility inputs, recalculate option prices
price_difference = priceit_(S,K,r,T,sigma+vol_change,N,q,option_parity,option_type) ...
- priceit_(S,K,r,T,sigma-vol_change,N,q,option_parity,option_type);
% take changes in option prices and divide by twice volatility difference
vega = price_difference / (2 * vol_change);
end
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -Didea.launcher.port=7532 -Didea.launcher.bin.path=/Applications/IntelliJ IDEA 10 CE.app/bin -Dfile.encoding=UTF-8 -classpath /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/deploy.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/dt.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/javaws.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/jce.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/jconsole.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/management-agent.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/plugin.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/sa-jdi.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/alt-rt.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/alt-string.jar:/
@elee
elee / foo.pl
Created December 8, 2011 04:55
fixed
use strict;
use warnings;
use diagnostics;
use feature qw(say);
my @arr = grep { $_ % 2 == 0 } 1..10;
my $name = 'slim shady';
bar(\@arr,$name);