Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
-- DESCRIPTION -- | |
If you accidentally commit a huge file, you have a problem. Sure, you can remove it from the working tree and commit, | |
but the file is still reachable from your history and therefore causes every clone to be as huge as the commented | |
binary file. | |
Fixing this can be very ugly, time consuming and might not even work as you wish. Luckily, this script can protect | |
you from committing such monsters in the first place. | |
It looks through the staged files (the ones that are added with the "git add"-command) and checks for their file-size. | |
If they are larger then the given size, the commit is aborted and you get a message telling you what file takes so |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
# File Transfer for Pythonista | |
# ============================ | |
# This script allows you to transfer Python files from | |
# and to Pythonista via local Wifi. | |
# It starts a basic HTTP server that you can access | |
# as a web page from your browser. | |
# When you upload a file that already exists, it is | |
# renamed automatically. | |
# From Pythonista's settings, you can add this script | |
# to the actions menu of the editor for quick access. |
import os | |
import sys | |
import pickle | |
import console | |
# I moved 'dropboxlogin' into a sub folder so it doesn't clutter my main folder | |
sys.path += [os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lib')] | |
import dropboxlogin # this code can be found here https://gist.github.com/4034526 | |
STATE_FILE = '.dropbox_state' |
Install portaudio using homebrew (or method of your choice)
brew install portaudio
create $HOME/.pydistutils.cfg using the include
and lib
directories of your portaudio install:
[build_ext]
#!/bin/bash | |
# GUI-related packages | |
pkgs=" | |
xserver-xorg-video-fbdev | |
xserver-xorg xinit | |
gstreamer1.0-x gstreamer1.0-omx gstreamer1.0-plugins-base | |
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-alsa | |
gstreamer1.0-libav | |
epiphany-browser |
import asyncio | |
from collections import deque | |
class AsyncioPool: | |
def __init__(self, concurrency, loop=None): | |
""" | |
@param loop: asyncio loop | |
@param concurrency: Maximum number of concurrently running tasks | |
""" |
// Implement Pic. It should return a slice of length dy, each element of which is | |
// a slice of dx 8-bit unsigned integers. When you run the program, it will display your picture, | |
// interpreting the integers as grayscale (well, bluescale) values. | |
// | |
// The choice of image is up to you. Interesting functions include (x+y)/2, x*y, and x^y. | |
// | |
// (You need to use a loop to allocate each []uint8 inside the [][]uint8.) | |
// | |
// (Use uint8(intValue) to convert between types.) | |
package main |
import pandas as pd | |
import numpy as np | |
import datetime as dt | |
import math | |
import warnings | |
warnings.filterwarnings("ignore") | |
prices = pd.read_csv("adjclose.csv", index_col="Date", parse_dates=True) | |
volumechanges = pd.read_csv("volume.csv", index_col="Date", parse_dates=True).pct_change()*100 |