Skip to content

Instantly share code, notes, and snippets.

@matsukaz
matsukaz / 01.README.md
Last active September 27, 2021 11:07
Find a geolocation of an IP address in BigQuery

This query is to find geolocation of an IP address including latitude, longitude, city and country.

Legacy SQL doesn't support range conditions such as BETWEEN when using JOIN, so we need to filter data by WHERE. This means if IP address does not match any of the data inside geolite_city_bq_b2b, records will not be able to receive.

Use Standard SQL if you want to receive records no matter you succeed to find geolocation or not.

Please refer to the following post for more detail.

https://cloudplatform.googleblog.com/2014/03/geoip-geolocation-with-google-bigquery.html

@eduncan911
eduncan911 / Revert-Gist.md
Last active July 20, 2023 09:41
Revert Gist Commits

Revert / Undo a Gist Commit

It was not exactly obvious. Here's how to revert a Gist commit!

Checkout the gist like a normal git repo:

# replace the Gist ID with your own
git clone git@github.com:cc13e0fcf2c348cc126f918e4a3917eb.git

Treat it like a normal repo. Edit, force push, etc.

@donmccurdy
donmccurdy / .block
Last active September 4, 2023 11:52
Custom tiles in Google Maps
license: apache-2.0
@rmania
rmania / geopandas_convert_geometry_3D_2D.py
Created March 13, 2017 21:06
flatten geometry series (3D to 2D) in geopandas dataframe
# Often when reading in a ShapeFile from Basemap, you'll get: "ValueError: readshapefile can only handle 2D shape types"
# A trick can be to convert your geometry in your GeoPandas Dataframe and restoring the new flattened 2D geometry
# series back into a shapefile and try again.
# edit from http://stackoverflow.com/questions/33417764/basemap-readshapefile-valueerror
from shapely.geometry import Polygon, MultiPolygon, shape, Point
import geopandas as gp
def convert_3D_2D(geometry):
'''
@molpopgen
molpopgen / RemoteJupyter.md
Last active February 19, 2022 22:05
SSH port forwarding and Jupyter

Problem

You want to use Jupyter remotely. X11 forwarding is too slow for this.

Solution

SSH port forwarding!

The recipe

(from : https://simplifiedthinking.co.uk/2015/10/03/install-mqtt-server/ )
Installing Brew
The Mosquitto MQTT Server can be easily installed using Homebrew. If it’s not installed on your system already, then a quick visit to the homepage will give you all you need to get going. Homebrew is an OS X Package Manager for installing and updating non-Mac OS X utilities that are more commonly found in other variants of Linux. To install the basic package manager run the following command.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Installing Mosquitto MQTT
@bbengfort
bbengfort / nx2gt.py
Created June 26, 2016 12:01
Convert a networkx to graph-tool graph
import networkx as nx
import graph_tool as gt
def get_prop_type(value, key=None):
"""
Performs typing and value conversion for the graph_tool PropertyMap class.
If a key is provided, it also ensures the key is in a format that can be
@joelouismarino
joelouismarino / googlenet.py
Last active October 9, 2023 07:09
GoogLeNet in Keras
from __future__ import print_function
import imageio
from PIL import Image
import numpy as np
import keras
from keras.layers import Input, Dense, Conv2D, MaxPooling2D, AveragePooling2D, ZeroPadding2D, Dropout, Flatten, Concatenate, Reshape, Activation
from keras.models import Model
from keras.regularizers import l2
from keras.optimizers import SGD

Interactive Machine Learning

Taught by Brad Knox at the MIT Media Lab in 2014. Course website. Lecture and visiting speaker notes.

@ryanmaclean
ryanmaclean / osx_port_scan.sh
Created April 25, 2016 05:52
Mac OSX: Port Scan Your Own Network with Netcat from Homebrew
#!/bin/bash
# Turn on job control to do more than one at a time
set -m
# Check to see if Homebrew is installed, and install it if it is not
command -v brew >/dev/null 2>&1 || { echo >&2 "You will need Homebrew to use this tool, installing now"; /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; }
# Check to see if `netcat` is installed, install it if it is not
command -v netcat >/dev/null 2>&1 || { echo >&2 "You will also need netcat in order to use this tool, installing it now"; brew install netcat; }