Skip to content

Instantly share code, notes, and snippets.

# This tests whether the first point is east or west of the boundary
if (boundary[1] < point1[1]):
if (bearing < 30 and bearing > 230):
direction = 'Upstream'
else:
direction = 'Downstream'
else:
if (bearing < 270 and bearing > 120):
direction = 'Upstream'
0.166898322139,59.9970928278,Downstream
0.00426075690575,54.9854929446,Downstream
0.0188063310586,220.337029895,Downstream
0.0365702125754,305.906672328,Downstream
0.0278539907523,316.560476554,Downstream
0.184274611676,307.479440894,Downstream
2.48424575672,306.973665439,Downstream
2.48128188418,309.37248466,Downstream
2.40545617578,270.465405831,Downstream
1.50952385385,313.037718076,Upstream
['1', 0.16689832213912348, 59.99709282775342, 'East of boundary.']
['1', 0.004260756905747937, 54.98549294460736, 'East of boundary.']
['1', 0.018806331058633906, 220.33702989450754, 'East of boundary.']
['1', 0.03657021257535287, 305.90667232816327, 'East of boundary.']
['1', 0.02785399075226293, 316.5604765542264, 'East of boundary.']
['1', 0.18427461167581766, 307.4794408936658, 'East of boundary.']
['1', 2.484245756716924, 306.97366543906054, 'East of boundary.']
['1', 2.4812818841756568, 309.3724846601186, 'East of boundary.']
['1', 2.4054561757813238, 270.46540583116104, 'East of boundary.']
['1', 1.5095238538513351, 313.03771807636167, 'East of boundary.']
@bmoore
bmoore / nodegit.sh
Created September 24, 2015 12:24 — forked from tbranyen/nodegit.sh
emscripten fallback
λ node
> require("nodegit").Repository.open(".", function(err, repo) { console.log(err, repo); });
0 {}
def get_cruise_type_ticket_type_price_id_by_cruise_type_id_and_ticket_type_id(cruise_type_id, ticket_type_id):
with session_scope() as session:
result = session.execute('''
SELECT id
FROM cruise_type_ticket_type
WHERE cruise_type_id = :cruise_type_id
AND ticket_type_id = :ticket_type_id
''', {
'cruise_type_id': cruise_type_id,
'ticket_type_id': ticket_type_id
@bmoore
bmoore / gist:7995441
Created December 16, 2013 22:16
Lazy solution... like pseudoprototype.
var WebCam = {
capturing: false,
callbacks: [],
capture: function(cb) {
addCallback(cb);
_takePic();
},
addCallback(cb) {
@bmoore
bmoore / base_26.php
Created December 12, 2013 15:04
For Frankie about his base_26 problem.
<?php
function base_26($num)
{
$alpha = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
// Get the character
$i = $num%26;
// Get the rest of the characters "power/base" math
$num = ($num - $i)/26;
@bmoore
bmoore / tmtail
Last active December 21, 2015 20:09
tmux split and tail all your files in the logs directory.
#!/bin/bash
if [ !-d 'logs' ]
then
echo "No logs!"
exit 1
fi
i=0
count=$(ls logs | grep log | wc -l)
perc=$((100/$count))
@bmoore
bmoore / gist:5831578
Last active December 18, 2015 19:18
Imagick resize
<?php
$x = $y = 0;
$image = new Imagick('orig.jpg');
//get_smallest_dimension
if ($image->getImageWidth() < $image->getImageHeight()) {
$x = 612;
} else {
$y = 612;
}
@bmoore
bmoore / upimg
Created May 28, 2013 18:02
Upload image selection to imgur, and pipe the image url to xclip. Based on http://sirupsen.com/a-simple-imgur-bash-screenshot-utility/
#!/bin/bash
function uploadImage {
curl -s -F "image=@$1" -F "key=486690f872c678126a2c09a9e196ce1b" https://imgur.com/api/upload.xml | grep -E -o "<original_image>(.)*</original_image>" | grep -E -o "http://i.imgur.com/[^<]*"
}
import shot.png
url=`uploadImage "shot.png"`
echo $url
echo $url | xclip -selection c