The current solar terminator is shown in blue, assuming a spherical Earth and an axial tilt of 23.4°. Hmm, on second thought, I think I didn’t account for the orbit of the Earth around the sun, so this is not entirely accurate. Please fork this example and fix it!
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 cacheprop(object): | |
def __init__(self, getter): self.getter = getter | |
def __get__(self, shelf, _): | |
value = self.getter(shelf) | |
shelf.__dict__[self.getter.__name__] = value | |
return value | |
class Foo(): | |
@cacheprop | |
def bar(self): |
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
""" | |
Examples: | |
with figure_grid(5, 3) as grid: | |
grid.next() | |
# plot something | |
grid.next() | |
# plot something | |
# ...etc | |
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
<OrderSet> | |
<moduleMetadata> | |
<identifier> | |
<system value="http://nccn.org/ordertemplates" /> | |
<value value="KDN5" /> | |
</identifier> | |
</module> | |
<!-- Here we only have one course (which repeats for 6 21-day cycles), but we could have multiple courses --> | |
<action> |
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
## replace all instances of $1 with $2 within $3. | |
function supersub { | |
ack -l "$1" "$3" | xargs perl -p -i -e "s/$1/$2/g" | |
} |
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 DeepOpenStruct | |
def initialize(hash) | |
hash.each { |k, v| define_singleton_method(k) { | |
instance_variable_get(:"@#{k}") || instance_variable_set(:"@#{k}", coerce(v)) | |
} } | |
end | |
def [](k) | |
send(k) | |
end |
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
# execute e.g. | |
# $ kill_matching phantomjs | |
function kill_matching { | |
export matchee=$1 | |
ruby -e 'puts `ps aux | grep #{`echo $matchee`}`.split("\n").each{|l| `kill -9 #{l.split[1]}` unless l.include?("grep") }' | |
} |
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
function randomizeFonts() { | |
if (window.jQuery) { | |
elements = jQuery('*'); | |
families = jQuery.unique(elements.map(function() { return jQuery(this).css('font-family') })); | |
families.push("'comic sans ms', sans-serif"); | |
elements.each(function() { | |
jQuery(this).css('font-size', 32*Math.random() + 'px'); | |
jQuery(this).css('font-family', families[Math.floor(Math.random()*families.length)]); | |
}); |
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 twitter_puddle(wall): | |
height = max(wall) | |
total = 0 | |
for x in range(1, len(wall)-2): | |
lowest_wall = min(max(wall[:x]), max(wall[x+1:])) | |
if lowest_wall > wall[x]: | |
total += lowest_wall - wall[x] | |
return total | |
assert(twitter_puddle([2, 5, 1, 2, 3, 4, 7, 7, 6]) == 10) |
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
function groc { # git rebase origin/{current} | |
local remote_branch="${1:-origin}/$(git branch | grep \* | cut -c 3-)" | |
git rebase $remote_branch | |
} | |
function gpoc { # git push origin {current} | |
local current_branch="$(git branch | grep \* | cut -c 3-)" | |
git push origin $current_branch | |
} |
NewerOlder