Skip to content

Instantly share code, notes, and snippets.

@lambdamusic
lambdamusic / keynote.scpt
Last active Jan 8, 2021
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 / Snipplr-62778.py
Created Feb 7, 2013
Django: Override the change_view in the admin
View Snipplr-62778.py
# in your models.py, or admin.py
from django.http import HttpResponseRedirect
from django.utils.encoding import force_unicode
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
class Admin(ModelAdmin):
View 1-introducing-datasets.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lambdamusic
lambdamusic / README.md
Last active Nov 30, 2020
Nature.com archive statistics
View README.md
@lambdamusic
lambdamusic / inspectCSV.py
Last active Nov 30, 2020
Script that reads a csv file and serializes it into a list of dictionaries {column: value} The dicts can then be used for counting or to create other stats.
View inspectCSV.py
#!/usr/bin/env python
# encoding: utf-8
"""
csvreader.py
2013-08-27
Script that reads a csv file and serializes it into a list of dictionaries {column: value}
The dicts can then be used for counting or to create other stats.
@lambdamusic
lambdamusic / generate_noise.py
Created Mar 10, 2013
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"
@lambdamusic
lambdamusic / Snipplr-56709.py
Created Feb 7, 2013
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 Mar 10, 2020
Access osx dictionary in python
View define.py
#!/usr/bin/env python
"""
Modified from
http://macscripter.net/viewtopic.php?id=26675
http://apple.stackexchange.com/questions/90040/look-up-a-word-in-dictionary-app-in-terminal
HowTo
@lambdamusic
lambdamusic / gist-backup.py
Last active Aug 24, 2019 — forked from fedir/gist-backup.py
Clone or update all user's gists #backup #github #gists #management
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 / python_request_create_gist.py
Last active Jul 28, 2019 — forked from joshisumit/python_request_create_gist.py
Create GIST from your python code with python requests module and OAuth token.
View python_request_create_gist.py
'''
HTTP Reuests has following parameters:
1)Request URL
2)Header Fields
3)Parameter
4)Request body
PREREQUISITE
* head over to https://github.com/settings/tokens and generate a new token with 'gists' permissions