Skip to content

Instantly share code, notes, and snippets.

@abubelinha
abubelinha / df_to_markdown.py
Last active November 7, 2021 09:15 — forked from jplsightm/df_to_markdown.py
Convert a Pandas Dataframe to Markdown
import pandas as pd
from tabulate import tabulate
def pandas_df_to_markdown_table(df):
# Dependent upon ipython
# shamelessly stolen from https://stackoverflow.com/questions/33181846/programmatically-convert-pandas-dataframe-to-markdown-table
from IPython.display import Markdown, display
fmt = ['---' for i in range(len(df.columns))]
df_fmt = pd.DataFrame([fmt], columns=df.columns)
df_formatted = pd.concat([df_fmt, df])
@abubelinha
abubelinha / push_file_to_github_repo_branch.py
Created October 29, 2021 18:04 — forked from avullo/push_file_to_github_repo_branch.py
Push file update to GitHub repository using GitHub API in Python
import requests
import base64
import json
import datetime
def push_to_repo_branch(gitHubFileName, fileName, repo_slug, branch, user, token):
'''
Push file update to GitHub repo
import requests
params = {'access_token': '<your-access-token>'}
# Create the deposit resource
url = "https://sandbox.zenodo.org/api/deposit/depositions"
headers = {"Content-Type": "application/json"}
res = requests.post(
url,
@abubelinha
abubelinha / Makefile
Last active February 4, 2021 10:11 — forked from guss77/Makefile
MariaDB update table with UUID (reproduction of the issue using docker-compose)
COMPOSE := docker-compose -p demouuid
start:
$(COMPOSE) up -d
sleep 3
while $(COMPOSE) ps | grep -q database; do \
$(COMPOSE) logs 2>/dev/null| grep -q 'MySQL init process done.' && break;\
$(COMPOSE) logs 2>/dev/null| grep -i error && break;\
$(COMPOSE) ps | grep -q Exit && break;\
done
@abubelinha
abubelinha / bench.py
Created January 23, 2021 17:48 — forked from methane/bench.py
Benchmarking MySQL drivers (Python 3.4)
from __future__ import print_function
import time
def query_10k(cur):
t = time.time()
for _ in range(10000):
cur.execute("SELECT 1,2,3,4,5")
res = cur.fetchall()
assert len(res) == 1
assert res[0] == (1,2,3,4,5)
@abubelinha
abubelinha / so_read_url_write_file.py
Created January 19, 2021 22:06 — forked from hughdbrown/so_read_url_write_file.py
Read from URL, write to file
"""
Code to write data read from a URL to a file
Based on an answer on SO:
http://stackoverflow.com/questions/22676/how-do-i-download-a-file-over-http-using-python/22721
"""
import urllib2
mp3file = urllib2.urlopen("http://www.example.com/songs/mp3.mp3")
@abubelinha
abubelinha / d3.slider.css
Created April 6, 2020 09:50 — forked from cmdoptesc/d3.slider.css
D3: Map Timeline
.d3-slider {
position: relative;
font-family: Verdana,Arial,sans-serif;
font-size: 1.1em;
border: 1px solid #aaaaaa;
z-index: 2;
}
.d3-slider-horizontal {
height: .8em;
@abubelinha
abubelinha / index.html
Created April 6, 2020 09:49 — forked from rengel-de/index.html
Timeline for d3 - proof-of-concept
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="keywords" lang="de" content="Zeitleiste, Zeitlinie, Zeitkarte, Geschichte, Chronologie">
<meta name="keywords" lang="en" content="Timeline, Timemap, History, Chronology">
<title>Timeline - Proof-of-concept</title>
<!-- That's my local d3 path. When working locally, use your local path. -->
@abubelinha
abubelinha / .treehouse
Last active April 5, 2020 18:36 — forked from ErikGartner/.treehouse
dTree Demo
1.3.1
@abubelinha
abubelinha / .block
Last active April 3, 2020 22:56
index.html/js bl.ocks example
license: gpl-3.0
height: 500
scrolling: no
border: yes