Skip to content

Instantly share code, notes, and snippets.

@lambdamusic
lambdamusic / bard-input-test.md
Last active November 28, 2023 20:24
bard input test
View bard-input-test.md
@lambdamusic
lambdamusic / 2023-07-04-notes-deep-work-the-book.md
Last active November 22, 2023 08:50
notes-deep-work-2016
View 2023-07-04-notes-deep-work-the-book.md

Notes from Deep Work by Cal Newport

A very biased collection of quotes and ideas from the book Deep Work by Cal Newport (2016).

Concept map

flowchart LR
    A((Deep Work)) -->|Versus| B(Shallow Work)
    B --> B1[Shallow work promotes more shallow work]
@lambdamusic
lambdamusic / Snipplr-29633.py
Created February 7, 2013 21:26
Python: MySQL-Python
View Snipplr-29633.py
import MySQLdb
conn = MySQLdb.connect(host=\"localhost\", user=\"root\", passwd=\"nobodyknow\", db=\"amit\")
cursor = conn.cursor()
stmt = \"SELECT * FROM overflows\"
cursor.execute(stmt)
# Fetch and output
result = cursor.fetchall()
@lambdamusic
lambdamusic / keynote.scpt
Last active October 10, 2023 23:12
Apple Keynote: export presenter notes
View keynote.scpt
-- HOWTO:
-- after saving it, open with Script Editor (default) and run it
-- PREREQUISITES:
-- make sure your Keynote presentation is open in the background
-- AFTER EXPORT:
-- if you can't open the file due to encoding errors, open with Sublime (or another a text editor) and then "File / Save with encoding / UTF8"
tell application "Keynote"
@lambdamusic
lambdamusic / gist-backup.py
Last active July 27, 2023 14:28 — forked from fedir/gist-backup.py
Clone or update all user's gists #gists
View gist-backup.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Forked from https://gist.github.com/fedir/5466075
Changes:
- allows to import Github gists into a local DASH database (https://kapeli.com/dash)
- gists are added to any existing snippet already in database
- filetypes are added, but support is very basic
@lambdamusic
lambdamusic / Snipplr-56709.py
Created February 7, 2013 21:28
Python: RGB Color Gradation Function
View Snipplr-56709.py
import string
def make_color_tuple( color ):
"""
turn something like "#000000" into 0,0,0
or "#FFFFFF into "255,255,255"
"""
R = color[1:3]
G = color[3:5]
B = color[5:7]
@lambdamusic
lambdamusic / define.py
Last active February 15, 2023 14:52
Access osx dictionary in python
View define.py
#!/usr/bin/env python
"""
# Version
2021-08-31
# Tested on
Python 3.9
@lambdamusic
lambdamusic / quote.md
Last active January 23, 2023 08:05
test-quote
View quote.md

template: quote.html title: "Additive manufacturing" source: "A Third Industrial Revolution | The Economist" url: http://www.economist.com/node/21552901 date: 2013-02-26 modified: 2015-05-04 review: false

@lambdamusic
lambdamusic / Snipplr-50835.py
Created February 7, 2013 21:28
Django: Strip/Remove HTML tags (django utils)
View Snipplr-50835.py
# To strip/remove HTML tags from an existing string we can use the strip_tags function.
# import the strip_tags
from django.utils.html import strip_tags
# simple string with html inside.
html = '<p>paragraph</p>'
print html # will produce: <p>paragraph</p>
stripped = strip_tags(html)
@lambdamusic
lambdamusic / generate_noise.py
Created March 10, 2013 17:01
Python: generate audio noise
View generate_noise.py
# from http://soledadpenades.com/2009/10/29/fastest-way-to-generate-wav-files-in-python-using-the-wave-module/
import wave
import random
import struct
import datetime
SAMPLE_LEN = 44100 * 300 # 300 seconds of noise, 5 minutes
print "Create file using wave and writeframes twice in each iteration"