Skip to content

Instantly share code, notes, and snippets.

View pokka's full-sized avatar
🌮
I may be slow to respond.

Pokka pokka

🌮
I may be slow to respond.
View GitHub Profile
@colby-schrauth
colby-schrauth / lorenz_and_gini.py
Last active July 25, 2017 10:35
lorenz_and_gini
# Import necessary libraries
from __future__ import division
import numpy as np
import pandas as pd
# Load dataset and store dataframe in variable 'df'
# 25 randomly selected income values w/ a range of $50k – $250k
df = pd.read_csv('http://bit.ly/2eaP6ny', header = None)
df = df
@sloria
sloria / bobp-python.md
Last active May 31, 2024 07:02
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@holman
holman / Guthrie IP.md
Last active August 4, 2016 03:30
Woody Guthrie, on intellectual property.

This song is Copyrighted in U.S., under Seal of Copyright # 154085, for a period of 28 years, and anybody caught singin it without our permission, will be mighty good friends of ourn, cause we don’t give a dern. Publish it. Write it. Sing it. Swing to it. Yodel it. We wrote it, that’s all we wanted to do.

  • Woody Guthrie, 1940's —

Moved

Now located at https://github.com/JeffPaine/beautiful_idiomatic_python.

Why it was moved

Github gists don't support Pull Requests or any notifications, which made it impossible for me to maintain this (surprisingly popular) gist with fixes, respond to comments and so on. In the interest of maintaining the quality of this resource for others, I've moved it to a proper repo. Cheers!

@huacnlee
huacnlee / move_files.rb
Last active December 20, 2015 17:49
将一个目前下面的文件,根据文件名前缀分散到不同的文件夹,比如 a12.jpg -> a/1/a12.jpg, b287.jpg -> b/2/b287.jpg 此方法用于处理由于最初设计上传文件夹没有分层次导致一个目录文件过多的问题。可以将一个目录下面的文件分散到子目录中
require "fileutils"
root_dir = "/Users/jason/Downloads/images"
Dir.chdir(root_dir)
puts Dir.pwd
Dir.glob("**/*.{jpg}").each do |fname|
tfname = fname.split("/").last
if fname.match("[small|large|normal]_")
tfname = fname.split("_").last
end
p1,p2 = tfname[0,1],tfname[1,1]
$ = jQuery
$.fn.lineHeight or= ->
if height = @data('lineHeight')
return height
# Create a hidden div with the same font
# properties, then measure its height
$shadow = $('<span />')
$shadow.css({
@leobossmann
leobossmann / gist:5998424
Created July 15, 2013 08:41
Dump rails database to a remote location, strip schema migrations
mysqldump --skip-triggers --compact --no-create-info --complete-insert -u [db_user] -p [db_name] | sed '/schema_migrations/d' | gzip -c | ssh [remote_user]@[remote_host] 'cat > [remote_file].sql.gz'
@jakeasmith
jakeasmith / mysqldump.sh
Last active June 28, 2021 20:07
A quick snippet for doing a compressed mysql dump with a pv to monitor progress
mysqldump [database] | pv | gzip -c > [file].sql.gz
@pokka
pokka / delay.es6.js
Last active September 6, 2016 06:15
simple delay javascript function,when you care about duplicate execute
let timer;
const delay = (func, ms = 500) => {
clearTimeout(timer);
timer = setTimeout(func, ms);
}
export default delay;
@HungYuHei
HungYuHei / Gemfile
Created October 19, 2012 01:41
followable with redis Sorted-Set
# Gemfile
gem 'redis', '~> 3.0.1'