Skip to content

Instantly share code, notes, and snippets.

View glasnt's full-sized avatar
🦜

Katie McLaughlin glasnt

🦜
View GitHub Profile
@glasnt
glasnt / Procfile
Last active November 21, 2023 03:29
Cloud Buildpacks and Cloud Build
web: ./main.py
from datasette.database import Database
from datasette import hookimpl
from datasette.utils.asgi import Response
import os
`
async def reload_db(datasette):
spec = datasette.plugin_config('datasette-reload-db')
db_dir = os.listdir(spec['dir'])
databases = datasette.databases
"""
My first application
"""
import toga
from toga.style import Pack
from toga.style.pack import COLUMN, ROW
class HelloWorld(toga.App):
def startup(self):
@glasnt
glasnt / Code.gs
Created December 10, 2018 09:29 — forked from rheajt/Code.gs
google apps script to open a new website in a new window
function openTab() {
var selection = SpreadsheetApp.getActiveSheet().getActiveCell().getValue();
var html = "<script>window.open('" + selection + "');google.script.host.close();</script>";
var userInterface = HtmlService.createHtmlOutput(html);
SpreadsheetApp.getUi().showModalDialog(userInterface, 'Open Tab');
}

Keybase proof

I hereby claim:

  • I am glasnt on github.
  • I am glasnt_ (https://keybase.io/glasnt_) on keybase.
  • I have a public key whose fingerprint is F026 9B50 5233 B0C9 8D1E 037C CA63 6DA6 7DA9 A6F6

To claim this, I am signing this object:

@glasnt
glasnt / glitchulate.py
Created November 15, 2016 00:06 — forked from hawkowl/glitchulate.py
Make your favourite images into glitched monstrosities! (Requires pillow from PyPI, Py2/3/pypy compatible)
from __future__ import print_function
import sys
import random
from collections import deque
from PIL import Image
# THIS IS THE MAGIC VALUE THAT MAKES EVERYTHING GLITCHED
@glasnt
glasnt / regional.py
Last active August 25, 2016 16:22
🇷​🇪​🇬​🇮​🇴​🇳​🇦​🇱​ ​🇮​🇳​🇩​🇮​🇨​🇦​🇹​🇴​🇷​ ​🇨​🇭​🇦​🇷​🇦​🇨​🇹​🇪​🇷​🇸​ ​🇦​🇸​ ​🇦​ ​🇸​🇪​🇷​🇻​🇮​🇨​🇪
"""
Usage: python3 regional.py list of words
Prints a representation of the words as Regional Identifiers, and copies the output directly to keyboard for you
This is because some terminals think that zero width spaces are silly.
Currently supports: A-Z
Requires: Python 3
Now less complex, thanks @bmispelon!
"""
<div style="font-family: Monaco">
Monaco<br>
<table><tr><td>▁ ▂ ▃ ▅ ▆ ▇</td><td>▁▂▃▅▆▇</td></tr>
<tr><td>▁▂▃▄▅▆▇█</td><td>▁▂▃▄▅▆▇█</td></tr></table>
</div>
<div style="font-family: Menlo">
Menlo
<table><tr><td>▁ ▂ ▃ ▅ ▆ ▇</td><td>▁▂▃▅▆▇</td></tr>
@glasnt
glasnt / ncpus.py
Last active November 15, 2020 21:49
Get Number of CPUs for Any System, if Python is about
# Based on : https://groups.google.com/d/msg/sage-devel/1lIJ961gV_w/y-2uqPCyzUMJ
import os
def ncpus():
#for Linux, Unix and MacOS
if hasattr(os, "sysconf"):
if "SC_NPROCESSORS_ONLN" in os.sysconf_names:
#Linux and Unix
ncpus = os.sysconf("SC_NPROCESSORS_ONLN")
if isinstance(ncpus, int) and ncpus > 0:
return ncpus