Skip to content

Instantly share code, notes, and snippets.

@n-bar
n-bar / osx-for-hackers.sh
Created July 20, 2017 21:44 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@n-bar
n-bar / pnpoly.py
Created June 22, 2017 09:19
Point in Polygon
# http://geomalgorithms.com/a03-_inclusion.html
# https://wrf.ecse.rpi.edu//Research/Short_Notes/pnpoly.html
# https://ru.wikibooks.org/wiki/Реализации_алгоритмов/Задача_о_принадлежности_точки_многоугольнику
# https://github.com/gregvw/pnpoly
def inPolygon(x, y, xp, yp):
c=0
for i in range(len(xp)):
if (((yp[i]<=y and y<yp[i-1]) or (yp[i-1]<=y and y<yp[i])) and \
(x > (xp[i-1] - xp[i]) * (y - yp[i]) / (yp[i-1] - yp[i]) + xp[i])): c = 1 - c
@n-bar
n-bar / geohash_encode.py
Last active June 22, 2017 09:19
geohash
# https://en.wikipedia.org/wiki/Geohash
__base32 = '0123456789bcdefghjkmnpqrstuvwxyz'
def encode(lat, lon, precision):
"""(Double?, Double? Uint32) -> String?
precision(km):
1 ±2500
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@n-bar
n-bar / haversine.py
Created March 17, 2017 08:12 — forked from rochacbruno/haversine.py
Calculate distance between latitude longitude pairs with Python
#!/usr/bin/env python
# Haversine formula example in Python
# Author: Wayne Dyck
import math
def distance(origin, destination):
lat1, lon1 = origin
lat2, lon2 = destination
@n-bar
n-bar / server.py
Created February 19, 2017 18:59
HTTPServer Basic Example
"""HTTPServer Basic Example
$ python3 server.py
# HEAD
$ curl -I http://localhost:3000
# GET
$ curl http://localhost:3000/app?id=123
# POST
$ curl http://localhost:3000 -F name=curl_form -F user=n-bar -F [email protected]
"""
@n-bar
n-bar / README.md
Last active February 16, 2017 13:46 — forked from jgoodall/README.md
This is a sample of how to send some information to logstash via the TCP input from python.

This is a sample of how to send some information to logstash via the TCP input in python. It assumes the logstash host is on "localhost" and the TCP listening input is 5959.

The logstash.conf should look something like the sample file.

The log message should be a stringified JSON object with the log message in the @message field.

To use, run the python script python sendMessageToLogstash.js

@n-bar
n-bar / JXA Resources.md
Created November 22, 2016 20:33 — forked from JMichaelTX/JXA Resources.md
JavaScript for Automation (JXA) Resources

JXA Resources

Revised: 2016-08-29 23:28 CT (Mon)

image

This is a list of the key resources I have found useful. If you know of others, please post in a comment below, and I will add to this list.

I have tried to order this list in the order that, to me, is best for learning JXA from scratch. We all learn a bit diferently, so adjust to suit your style/needs. Please post if you have suggestions on learning JXA.

  • I like starting with the videos in the Introduction.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
__version__ = "0.0.4"
import sys
import argparse
from collections import namedtuple
from multiprocessing.dummy import Pool