This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
def smart_resize(filepath = "samp.png", width = 612, height = 612): | |
img = Image.open(image_file) | |
orig_height, orig_width = img.size | |
if orig_height >= orig_width: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION hist_sfunc (state INTEGER[], val REAL, min REAL, max REAL, nbuckets INTEGER) RETURNS INTEGER[] AS $$ | |
DECLARE | |
bucket INTEGER; | |
i INTEGER; | |
BEGIN | |
bucket := width_bucket(val, min, max, nbuckets - 1) - 1; | |
IF state[0] IS NULL THEN | |
FOR i IN SELECT * FROM generate_series(0, nbuckets - 1) LOOP | |
state[i] := 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dateutil import parser | |
parser.parse('') | |
# datetime.datetime(2014, 4, 7, 0, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ITE00100554 | 17630101 | TMAX | -36 | |
---|---|---|---|---|
ITE00100554 | 17630101 | TMIN | -50 | |
ITE00100554 | 17630102 | TMAX | -26 | |
ITE00100554 | 17630102 | TMIN | -40 | |
ITE00100554 | 17630103 | TMAX | -9 | |
ITE00100554 | 17630103 | TMIN | -29 | |
ITE00100554 | 17630104 | TMAX | -4 | |
ITE00100554 | 17630104 | TMIN | -24 | |
ITE00100554 | 17630105 | TMAX | 21 | |
ITE00100554 | 17630105 | TMIN | 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION hist_sfunc (state INTEGER[], val REAL, min REAL, max REAL, nbuckets INTEGER) RETURNS INTEGER[] AS $$ | |
DECLARE | |
bucket INTEGER; | |
i INTEGER; | |
BEGIN | |
bucket := width_bucket(val, min, max, nbuckets - 1) - 1; | |
IF state[0] IS NULL THEN | |
FOR i IN SELECT * FROM generate_series(0, nbuckets - 1) LOOP | |
state[i] := 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT histogram(column, 0, 100, 10) from table; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"histogram": [0, 1, 2, 3, 4, 4, 3, 2, 1, 0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def calc_per_rank(val, hist, min_, max_, n_bins): | |
# determine how large each bin is | |
bin_interval = ( max_ - min_ ) / float( n_bins) | |
# identify which bin the value falls in | |
bin_index = int( math.floor( ( float( val ) - min_ ) / bin_interval ) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on `kennethreitz.zsh-theme`: https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/themes/kennethreitz.zsh-theme | |
ZSH_THEME_GIT_PROMPT_PREFIX="🐙 %{$purple%}" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="" | |
ZSH_THEME_GIT_PROMPT_CLEAN="%{$reset_color%} ✅ " | |
ZSH_THEME_GIT_PROMPT_DIRTY="%{$reset_color%} ❗ " | |
PROMPT='🏡 %{$limegreen%}%c%{$reset_color%} \ | |
$(git_prompt_info) \ | |
👉 ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"word": "people", | |
"count": 999 | |
}, | |
{ | |
"word": "data", | |
"count": 749 | |
}, | |
{ |
OlderNewer