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
# Workaround for "There are too many directories in your application for changes in all of them to be monitored." | |
# message in Flask | |
echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf; sudo sysctl -p |
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
# Run it live at | |
# https://www.pythonanywhere.com/gists/9671392e68fc0fff324c/all_functions.py/ipython3/ | |
import inspect, sys | |
def func1(): | |
pass | |
def func2(): | |
pass |
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
#! /usr/bin/env python3 | |
# coding=utf-8 | |
# Check if a number is happy or sad | |
# http://en.wikipedia.org/wiki/Happy_number | |
def happy(number, past = None): | |
def happy_calc(number): | |
return sum((int(digit)**2 for digit in str(number))) |
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
function $(q, parent) { | |
parent = parent || document; | |
//convert DOM NodeList into array, so that e.g. 'forEach' can be called. | |
return Array.prototype.slice.call(parent.querySelectorAll(q)); | |
} |
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
/* | |
* Using callbacks to set scope variables (Not as nice) | |
*/ | |
var app = angular.module("MyApp", []); | |
app.factory('sourceService', function($http, $q, $log) { | |
return { | |
get : function(){ | |
var endpoint = 'data.json'; |
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
\documentclass{article} | |
\usepackage{sepfootnotes} | |
\begin{document} | |
% \sepfootnotecontent needs to be defined before \sepfootnote | |
\sepfootnotecontent{a}{The footnotetext outside of the paragraph.} | |
A long sentence\sepfootnote{a} that I don't want broken by inline footnotes. | |
\end{document} |
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
\documentclass{article} | |
\begin{document} | |
\begin{enumerate} | |
% Redefine first level style to R1: | |
% \labelenumii would be second level | |
\renewcommand{\labelenumi}{\textbf{R\arabic{enumi}}:} | |
\item Question 1 | |
\item Question2 | |
\end{enumerate} |
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
% Enquote stuff nicely | |
\newcommand{\enquote}[1]{``#1''} | |
% Superscripts in text | |
\newcommand{\up}[1]{\ensuremath{^{\textrm{\small#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
# sorting options: https://docs.python.org/3/library/profile.html#pstats.Stats.sort_stats | |
FILE="file.py"; python -m cProfile -s cumulative $FILE > profile && less profile |
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
# Find and delete files | |
find . -type f -name "trash" -delete |