Skip to content

Instantly share code, notes, and snippets.

View 3vivekb's full-sized avatar

V 3vivekb

  • San Jose, CA
View GitHub Profile
@csessig86
csessig86 / gist:4447555
Last active June 30, 2017 18:22
Simple DataTables template part 3
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://wcfcourier.com/app/special/data_tables/media/css/demo_page.css">
<link rel="stylesheet" type="text/css" href="http://wcfcourier.com/app/special/data_tables/media/css/demo_table.css">
<style>
table {
font-size: 12px;
font-family: Arial, Helvetica, sans-serif;
float: left;
@niksumeiko
niksumeiko / git.migrate
Last active June 28, 2024 21:01
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@bsweger
bsweger / useful_pandas_snippets.md
Last active April 19, 2024 18:04
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@mhweber
mhweber / explode.py
Created July 25, 2016 17:45 — forked from debboutr/explode.py
Explode MultiPolygon geometry into individual Polygon geometries in a shapefile using GeoPandas and Shapely
import geopands as gpd
from shapely.geometry.polygon import Polygon
from shapely.geometry.multipolygon import MultiPolygon
def explode(indata):
indf = gpd.GeoDataFrame.from_file(indata)
outdf = gpd.GeoDataFrame(columns=indf.columns)
for idx, row in indf.iterrows():
if type(row.geometry) == Polygon:
outdf = outdf.append(row,ignore_index=True)
@kphaneuf
kphaneuf / Origin_Destination_DistanceAnalysis.sql
Created September 29, 2017 19:05
Creates geometry and distance columns, geometry, and distance between two points
--create geometry columns
ALTER TABLE vta_wkday_od_database ADD COLUMN origin_geom geometry(Point, 4326);
ALTER TABLE vta_wkday_od_database ADD COLUMN first_board_geom geometry(Point, 4326);
--create geometry from latitude and longitude columns
UPDATE vta_wkday_od_database SET first_board_geom = ST_SetSRID(ST_MakePoint(first_board_lon::double precision, first_board_lat::double precision), 4326);
UPDATE vta_wkday_od_database SET origin_geom = ST_SetSRID(ST_MakePoint(origin_lon::double precision, origin_lat::double precision), 4326);
--change to 2227 so that calculations are in feet not meters.
ALTER TABLE vta_wkday_od_database