Skip to content

Instantly share code, notes, and snippets.

View phpmyadmin_file_import.py
def pma_import_resubmit(br, sqlfile, target_dbname):
""" To be used in phpmyadmin dump.sql file imports using python-mechanize
as described in <https://github.com/phpmyadmin/phpmyadmin/issues/17423#issuecomment-1268271930>
Only call this function when you have already found a 'timeout_passed=' string in browser response
(so you are sure the page contains a resubmit link)
"""
# https://stackoverflow.com/questions/3569622/python-mechanize-following-link-by-url-and-what-is-the-nr-parameter/3569707#3569707
#link = br.find_link(url = resumeurl)
link = br.find_link(text = "resubmit the same file")
link.absolute_url = link.absolute_url.replace("&amp;","&").replace("?", "?db="+target_dbname+"&")
@abubelinha
abubelinha / esslinger.rb
Created Jul 31, 2022 — forked from kueda/esslinger.rb
Script to parse Esslinger's A Cumulative Checklist for the Lichen-forming, Lichenicolous and Allied Fungi of the Continental United States and Canada into machine-readable CSV
View esslinger.rb
#encoding: utf-8
#
# Script to parse Esslinger's A Cumulative Checklist for the Lichen-forming,
# Lichenicolous and Allied Fungi of the Continental United States and Canada
# into machine-readable CSV.
#
# Esslinger's checklist (e.g.
# http://www.ndsu.edu/pubweb/~esslinge/chcklst/chcklst7.htm) is considered
# authoritative for North American lichens, but it's authored with MS Word and
# has incosistent formatting. This script attempts to smooth that out and
@abubelinha
abubelinha / inat-password.py
Last active Jul 31, 2022 — forked from kueda/inat-password.py
iNaturalist API Resource Owner Password Credentials Flow Example (Python)
View inat-password.py
def get_inat_access_token(username = None, password = None, app_id = None, app_secret = None, jwt=True):
""" Get iNaturalist access token to make authenticated api requests and access your private data.
Example posted in <https://groups.google.com/g/inaturalist/c/PNfHggqoIYs/m/Lk30rlzKBAAJ>
and forked from <https://gist.github.com/kueda/53ef93159c64de96ddc2>
Other Python-iNaturalist stuff:
- <https://github.com/pyinat/pyinaturalist/>
- <https://inaturalist.nz/posts/20991-20-oauth2-package-for-python-body-str-paramsxml>
- <https://www.inaturalist.org/journal/glmory/21331-python-upload-script>
- <https://www.inaturalist.org/journal/glmory/21539-updated-python-upload-script>
- <https://github.com/glmory/iNaturalist-Uploads>
@abubelinha
abubelinha / vcard2org-contacts.py
Created Jul 12, 2022 — forked from tmalsburg/vcard2org-contacts.py
A simple script for converting vCard files to org-contacts.
View vcard2org-contacts.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Written by Titus von der Malsburg <malsburg@posteo.de>, March 2014.
# This is a simple script for converting vCard files to
# org-contacts. There is one mandatory argument: the name of the
# vCard file. The result is printed to standard out.
# Usage:
View migrate-from-php-to-python.md

Migrate from PHP to Python

Hi all, recently I've decided to move on and learn Python programming. At first, I though that it would be very difficult but in fact... Not that much. So I've decided to write this little gist and show the main differences between both languages.

I will use try to follow the same order used on this website: https://pythonprogramming.net/introduction-to-python-programming/. It was really usefull to improve my understanding of Python programming.

To finish, I'm assuming that you already got basic knowledge in Object Oriented Programming and already got skills and understanding of PHP programming. This is not intended to explain you how to code in PHP but if you're coming from Python programming, then this gist might help you to migrate from Python to PHP.

Official documentations

@abubelinha
abubelinha / iframe-killa.js
Created Mar 2, 2022 — forked from rodmcnew/iframe-killa.js
This is a bookmarklet that removes all iframes from the current page. Paste its code into a bookmark URL field. Click the bookmark to remove all iframes. Once started, it also removes newly spawned iframes every 100ms.
View iframe-killa.js
javascript:void(function(){setInterval(function(){document.querySelectorAll('iframe').forEach(function(element){console.log('Iframe Killa - Removing Element:', element);element.parentNode.removeChild(element)})},100)}());
View col_versions.R
library(tidyverse)
# 2017 monthly
x <- tempfile("col")
dir.create(x)
download.file("https://download.catalogueoflife.org/col/monthly/2017-02-27_dwca.zip", file.path(x, "dwca.zip"))
unzip(file.path(x, "dwca.zip"), exdir = x)
fs::dir_ls(x)
taxa <- readr::read_tsv(file.path(x, "taxa.txt"), guess_max=1e6, quote="", col_types = readr::cols(.default = "c"))
taxa %>% filter(specificEpithet == "sapiens", taxonomicStatus == "accepted name", genus=="Homo")
@abubelinha
abubelinha / reportlab_hello.py
Created Jan 3, 2022 — forked from cwebber314/reportlab_hello.py
Reportlab hello world with an image, bulleted list, and enumerated list.
View reportlab_hello.py
"""
Reportlab sandbox.
"""
from reportlab.lib.enums import TA_JUSTIFY
from reportlab.lib.pagesizes import letter, landscape
from reportlab.lib.enums import TA_JUSTIFY
from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
@abubelinha
abubelinha / dbbackup.py
Last active Feb 26, 2022 — forked from trafficinc/dbbackup.py
Python script for taking mysqldump
View dbbackup.py
#!/usr/local/bin/python3
"""
Will backup all the databases listed, will put files in same DIR as script'
To run: $ python dbbackup.py
"""
import configparser
import os
import time
@abubelinha
abubelinha / df_to_markdown.py
Last active Nov 7, 2021 — forked from jplsightm/df_to_markdown.py
Convert a Pandas Dataframe to Markdown
View df_to_markdown.py
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])