Skip to content

Instantly share code, notes, and snippets.

Hello, now click on the "Back" history button of your browser.
{"state": "checked"}
@josephernest
josephernest / duckdbtest.py
Last active January 1, 2021 13:51
Quick benchmark of DuckDB / Sqlite3 (disclaimer: it doesn't necessarily showcase the power of both solutions, there might be better ways I'm not aware of)
"""
Quick benchmark of DuckDB / Sqlite3 (disclaimer: it doesn't necessarily showcase the power of both solutions, there might be better ways I'm not aware of)
https://gist.github.com/josephernest/2c02f7627b83a32fd2086fe9dde15215.js
https://github.com/cwida/duckdb/issues/1249
1M rows 10M rows 20M rows 50M rows
duckdb 13ms ? 130ms ? 285ms ? ?
sqlite 13ms 26 MB 113ms 260 MB 221ms 527 MB ?
"""
@josephernest
josephernest / index.html
Last active December 29, 2020 18:15
Electron Fiddle Gist
<html>
<head>
<style>
* { margin: 0; }
#topright { float: right; width: 100px; background-color: blue; -webkit-app-region: no-drag; }
#topright:hover { background-color: black; }
#topleft { background-color: red; -webkit-app-region: drag; padding: 10px; }
</style>
</head>
<body>
@josephernest
josephernest / _pdf_cut_half.py
Last active June 2, 2020 07:16
Cut PDF pages in two halfs + rotated (ready for ereaders!)
import os, glob, pdfrw # todo: pip install pdfrw
for f in glob.glob('*.pdf'):
if '_cut.pdf' in f:
continue
writer = pdfrw.PdfWriter()
for page in pdfrw.PdfReader(f).pages:
for y in [0, 0.5]:
newpage = pdfrw.PageMerge()
newpage.add(page, viewrect=(0, y, 1, 0.5))
p = newpage.render()
@josephernest
josephernest / fulltextsearch.py
Created October 14, 2018 18:26
Examples of FullTextSearch, spellfix, FullTextSearch+spellfix together, with Python and Sqlite
import sqlite3
db = sqlite3.connect(':memory:')
c = db.cursor()
c.execute('CREATE TABLE mytable (description text)')
c.execute('INSERT INTO mytable VALUES ("Riemann")')
c.execute('INSERT INTO mytable VALUES ("All the Carmichael numbers")')
print '1) EQUALITY'
c.execute('SELECT * FROM mytable WHERE description == "Riemann"'); print 'Riemann:', c.fetchall()
@josephernest
josephernest / mklinkgui.py
Last active September 3, 2018 23:24
mklinkgui - make symbolic links in Windows Explorer with context menu
import win32clipboard # pip install pywin32 if needed
import sys, os, subprocess
fname = sys.argv[1]
win32clipboard.OpenClipboard()
filenames = win32clipboard.GetClipboardData(win32clipboard.CF_HDROP)
win32clipboard.CloseClipboard()
for filename in filenames:
base = os.path.basename(filename)
link = os.path.join(fname, base)
subprocess.Popen('mklink %s "%s" "%s"' % ('/d' if os.path.isdir(filename) else '', link, filename), shell=True)
@josephernest
josephernest / wave.py
Last active March 24, 2022 17:23
wave.py (enhanced)
# wave.py (Enhanced)
# Date: 2018/04/30 Joseph Ernest
#
# URL: https://gist.github.com/josephernest/e3903ba30b820cd199500e50f145a11f
# Source: Lib/wave.py
#
# Added:
# * IEEE support
# * 24 bit support
# * cue + loops markers support
@josephernest
josephernest / eeencode.py
Created January 26, 2017 17:46
Sublime Text plugin that adds simple encryption/decryption with password. Available with CTRL+SHIFT+P as "Eeencode" and "Dddecode"
# Based on http://stackoverflow.com/a/16321853/1422096
# Added a few things to support UTF8.
#
# Install:
# 1) Put the file in C:\Users\***\AppData\Roaming\Sublime Text 2\Packages\User
# 2) Add a reference in C:\Users\***\AppData\Roaming\Sublime Text 2\Packages\User\Default.sublime-commands:
# [{ "caption": "Eeencode", "command": "eeencode" }, { "caption": "Dddecode", "command": "dddecode" }]
import sublime, sublime_plugin

Here is a solution, inspired of DenisSheremet's comment and slightly modified.

[![enter image description here][1]][1]

document.getElementById('nav').addEventListener('click', function() { 

document.getElementById('hello').className = '';