Skip to content

Instantly share code, notes, and snippets.

@lebalz
lebalz / git_sync_all.py
Created December 28, 2020 16:50
sync all git projects in a folder
from pathlib import Path
import os
root = Path(__file__).parent
git_folders = root.rglob("*.git")
for git_dir in git_folders:
git = git_dir.parent
print('stash and pull master: ', git)
res = os.system(f'(cd {git} && git stash && git checkout master && git pull)')
@lebalz
lebalz / tts.py
Last active October 10, 2020 12:51
def save(self, savefile):
"""Do the TTS API request and write result to file.
Args:
savefile (string): The path and file name to save the ``mp3`` to.
Raises:
:class:`gTTSError`: When there's an error with the API request.
"""
@lebalz
lebalz / playsound.py
Last active October 10, 2020 13:31
playsound in jupyter
from IPython.display import Audio
from pathlib import Path
def _playsoundJupyter(sound, block=True):
sound = Path(sound)
sound = str(Path(get_ipython().home_dir, sound.name))
audio = Audio(sound, autoplay=False)
display(audio)
from platform import system
@lebalz
lebalz / 06_functions.ipynb
Last active September 8, 2020 13:27
06_gbsl_functions.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lebalz
lebalz / pip-packages.json
Last active September 1, 2020 14:05
gist example for vs code python2go plugin
[
{
"package": "jupyter"
},
{
"package": "numpy",
"version": "1.19.1"
},
{
"package": "smartphone-connector",
SELECT
cols.TABLE_SCHEMA as 'database',
cols.TABLE_NAME as 'table',
cols.COLUMN_NAME as 'column',
cols.DATA_TYPE AS 'data_type',
cols.COLUMN_TYPE AS 'type',
COALESCE(cols.COLUMN_DEFAULT, cols.extra) AS 'default',
(
CASE WHEN COLUMN_KEY='PRI'
THEN 'YES'
@lebalz
lebalz / markdown_table.rb
Created May 11, 2020 08:51
methods to create a markdown-formatted table from 2d-arrays, hashes or csv data
require 'json'
def to_md_row(row, max_field_sizes)
md = row.zip(max_field_sizes).map do |field, sz|
"#{field.to_s.ljust(sz, ' ')}"
end.join(' | ')
"| #{md} |"
end
def table_def_row(max_field_sizes)
@lebalz
lebalz / upload_image.php
Created May 10, 2020 10:25
Upload images with php
<?php
// definiere Funktion "endsWith" falls sie nicht bereits definiert wurde
if (!function_exists('endsWith')) {
/**
* endet $string mit $endString?
* @param string [String]
* @param endString [String]
* @return [boolean]
*/
function endsWith($string, $endString)
@lebalz
lebalz / mysql_lo_leduc_db.sql
Last active May 14, 2020 14:42
Small db for educational purpose
DROP DATABASE IF EXISTS lo_leduc;
CREATE DATABASE lo_leduc;
USE lo_leduc;
CREATE TABLE alben (
album CHAR(32) PRIMARY KEY,
artist CHAR(32) NOT NULL,
veroeffentlichung DATE
);