Skip to content

Instantly share code, notes, and snippets.

@ajmendez
ajmendez / age.py
Last active October 16, 2022 18:45
Here is a nice little wikipedia parser for grabbing an date of birth and date of death for a individual with an infobox template. This template is found generally on famous people. Works with people who are still alive by returning None for death_date.
import urllib2, json, pprint, re, datetime
import mwparserfromhell
def _parseDate(wikiDate):
''' Parse a mediawiki date template -- assumes years, month, day
Input:
a mwparser object containing just the date to be parsed
Returns:
datetime.date object of the date
'''
@camriddell
camriddell / Python Plotting - Working With Long Labels
Last active October 25, 2022 18:19
Summary of some of the ways one can work with long labels in both matplotlib & bokeh. Based on an example created in ggplot2 (R) https://www.andrewheiss.com/blog/2022/06/23/long-labels-ggplot/
We couldn’t find that file to show.
@namoshizun
namoshizun / regret_matching.py
Created July 14, 2017 01:03
Use regret matching to play rock-paper-scissors
from __future__ import division
from random import random
import numpy as np
import pandas as pd
'''
Use regret-matching algorithm to play Scissors-Rock-Paper.
'''
class RPS:
@MarvinT
MarvinT / black_code_prettify.json
Last active January 16, 2023 15:41
json you can paste into jupyter notebook's code prettify configuration that makes it use black to reformat your code instead of yapf.
{
"python": {
"library": "import json\ndef black_reformat(cell_text):\n import black\n import re\n cell_text = re.sub('^%', '#%#', cell_text, flags=re.M)\n try:\n reformated_text = black.format_str(cell_text, 88)\n except TypeError:\n reformated_text = black.format_str(cell_text, mode=black.FileMode(line_length=88))\n return re.sub('^#%#', '%', reformated_text, flags=re.M)",
"prefix": "print(json.dumps(black_reformat(u",
"postfix": ")))"
},
"r": {
"library": "library(formatR)\nlibrary(jsonlite)",
"prefix": "cat(toJSON(paste(tidy_source(text=",
"postfix": ", output=FALSE)[['text.tidy']], collapse='\n')))"
{"ISO 693-3":"aaa","Language Name":"Ghotuo","Language Family":"Niger-Congo","Subgrouping":"Atlantic-Congo","ASR":false,"TTS":false,"LID":true,"":"https://www.ethnologue.com/language/aaa"}
{"ISO 693-3":"aab","Language Name":"Arum","Language Family":"Niger-Congo","Subgrouping":"Atlantic-Congo","ASR":false,"TTS":false,"LID":true,"":"https://www.ethnologue.com/language/aab"}
{"ISO 693-3":"aac","Language Name":"Ari","Language Family":"Trans-New Guinea","Subgrouping":"Gogodala-Suki","ASR":false,"TTS":false,"LID":true,"":"https://www.ethnologue.com/language/aac"}
{"ISO 693-3":"aad","Language Name":"Amal","Language Family":"Sepik","Subgrouping":"Iwam","ASR":false,"TTS":false,"LID":true,"":"https://www.ethnologue.com/language/aad"}
{"ISO 693-3":"aaf","Language Name":"Aranadan","Language Family":"Dravidian","Subgrouping":"Southern","ASR":false,"TTS":false,"LID":true,"":"https://www.ethnologue.com/language/aaf"}
{"ISO 693-3":"aai","Language Name":"Miniafia Oyan","Language Family":"Austronesian","Subgrouping":"Malayo-Pol
@nbremer
nbremer / .block
Last active July 25, 2023 13:20
Storytelling with Chord Diagram
height: 750
@abul4fia
abul4fia / latex_items.py
Last active August 2, 2023 09:07
Latex items environment
"""
This module implements class LatexItems which is useful as an alternative
to manim's BulletedList.
Unless BulletedList, LatexItems uses standard latex itemize environment to
typeset the text and the bullets. The width of the paragraphs can be customized
as well as the kind of environment (itemize, enumerate, or description)
"""
from manim import Tex, TexTemplate
@ijy
ijy / sublime-text-3-setup.md
Last active January 15, 2024 14:21
My Sublime Text 3 setup.

Sublime Text 3 Setup

Install Package Control

Install Package Control for easy package management.

  1. Open the console with Ctrl+`
  2. Paste in the following:
@iamatypeofwalrus
iamatypeofwalrus / roll_ipython_in_aws.md
Last active January 22, 2024 11:18
Create an iPython HTML Notebook on Amazon's AWS Free Tier from scratch.

What

Roll your own iPython Notebook server with Amazon Web Services (EC2) using their Free Tier.

What are we using? What do you need?

  • An active AWS account. First time sign-ups are eligible for the free tier for a year
  • One Micro Tier EC2 Instance
  • With AWS we will use the stock Ubuntu Server AMI and customize it.
  • Anaconda for Python.
  • Coffee/Beer/Time
@loiseaujc
loiseaujc / LQE.ipynb
Last active January 31, 2024 09:07
Notebook for the control class on the Kalman filter
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.