Skip to content

Instantly share code, notes, and snippets.

View Flowerowl's full-sized avatar
💭
coding

Flowerowl Flowerowl

💭
coding
View GitHub Profile
@Flowerowl
Flowerowl / uninstall_office_2016.sh
Created May 3, 2018 08:39 — forked from pirafrank/uninstall_office_2016.sh
Uninstall Office 2016 from OS X completely
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo -e "
ROOT PRIVILEDGES NEEDED!
You have to run this script as root.
Aborting...
"
exit 1
else
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]
@Flowerowl
Flowerowl / python
Created May 4, 2017 08:44
py2&3 compat
# -*- coding: utf-8 -*-
import os
import sys
try:
import pkg_resources
get_module_res = lambda *res: pkg_resources.resource_stream(__name__,
os.path.join(*res))
except ImportError:
get_module_res = lambda *res: open(os.path.normpath(os.path.join(
@Flowerowl
Flowerowl / python
Created May 3, 2017 01:38
pott_tokenizer
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This code implements a basic, Twitter-aware tokenizer.
A tokenizer is a function that splits a string of text into words. In
Python terms, we map string and unicode objects into lists of unicode
objects.
#!/usr/bin/env python
# encoding: utf-8
states = ('Rainy', 'Sunny')
observations = ('walk', 'shop', 'clean')
start_probability = {'Rainy': 0.6, 'Sunny': 0.4}
transition_probability = {
@Flowerowl
Flowerowl / gist:36b67818a54fe6f6342013f890fbaa6b
Created September 13, 2016 08:23 — forked from aisk/gist:3735854
百度地图坐标与像素互相转换的方法
pixelToPoint = function(point, zoom, center, bounds) {
// 像素到坐标
if (!point) {
return
}
var zoomUnits = getZoomUnits(zoom);
var mercatorLng = center.lng + zoomUnits * (point.x - bounds.width / 2);
var mercatorLat = center.lat - zoomUnits * (point.y - bounds.height / 2);
var mercatorLngLat = {lng: mercatorLng, lat: mercatorLat};
return mercatorToLngLat(mercatorLngLat)
import itertools as IT
import multiprocessing as mp
import csv
def worker(chunk):
return len(chunk)
def main():
# num_procs is the number of workers in the pool
num_procs = mp.cpu_count()
import multiprocessing as mp
import itertools
import time
import csv
def worker(chunk):
# `chunk` will be a list of CSV rows all with the same name column
# replace this with your real computation
# print(chunk)
return len(chunk)
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"sync"
)
1 #!/usr/bin/env python
2 # monkey-patch
3 import gevent.monkey
4 gevent.monkey.patch_all()
5
6 import sys
7 import hashlib
8 import re
9
10 import requests