Skip to content

Instantly share code, notes, and snippets.

@simX
simX / export_notes
Created March 14, 2013 23:19
Quick AppleScript to export all your notes from Apple's built-in Notes.app application
tell application "Notes"
set note_body_list to (get body of every note)
end tell
set note_count to (count of note_body_list)
set blah_folder to choose folder
set blah_path to POSIX path of blah_folder
repeat with i from 1 to note_count
set filename_string to ((blah_path & "note" & (i as string) & ".html") as text)
func testReservationListPositions() {
let moc = CoreDataStack.sharedStack().mainObjectContext
let reservationListVC = ReservationListViewController()
do {
let reservation1 = try ReservationFactory.generateWithTemplate(ReservationFactory.Template(), parentContext: moc)
} catch {
print(error)
}
@sebmarkbage
sebmarkbage / Infrastructure.js
Last active May 2, 2024 03:11
SynchronousAsync.js
let cache = new Map();
let pending = new Map();
function fetchTextSync(url) {
if (cache.has(url)) {
return cache.get(url);
}
if (pending.has(url)) {
throw pending.get(url);
}
@turingbirds
turingbirds / GNUPG Cheatsheet.md
Last active May 2, 2024 03:11
GPG (GNUPG) Cheatsheet

GNUPG CHEATSHEET

Setting up: key generation

This generates a public/private keypair.

$ gpg --gen-key

$ gpg --list-secret-keys

@nilsandrey
nilsandrey / String.format.js
Last active May 2, 2024 03:10
string.format in Javascript.
// <https://stackoverflow.com/a/4673436/2100126>
// First, checks if it isn't implemented yet.
if (!String.prototype.format) {
String.prototype.format = function() {
var args = arguments;
return this.replace(/{(\d+)}/g, function(match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;
@matsuken92
matsuken92 / 01_preparation.py
Last active May 2, 2024 03:08
ROC Curve Animation
%matplotlib inline
import sys
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as st
from matplotlib import animation as ani
import sklearn.metrics as mt
@nilsandrey
nilsandrey / SendToTypefull-bookmarklet.js
Last active May 2, 2024 03:08
Use this code on a new bookmark to send current page to a new Typefully draft.
javascript:(function(){f='https://typefully.com/?new='+encodeURIComponent(document.title)+'%250A'+encodeURIComponent(window.location.href);a=function(){if(!window.open(f))location.href=f};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()
@nokotan
nokotan / extract-comments.py
Created February 26, 2021 16:32
Extract Comments in C/C++ Source File
#!/usr/bin/python3
from clang.cindex import Index, Config, CursorKind
import json as JsonUtil
import os, io, sys
class MyTreeWalker:
def __init__(self):
@almonk
almonk / SnappyWindow.swift
Last active May 2, 2024 03:05
SnappyWindow – A NSWindow that acts like the PIP Video Window from Safari
//
// SnappyWindow.swift
// A NSWindow that snaps to corners
//
// Created by Alasdair Monk on 03/02/2021.
//
import Foundation
import Cocoa
@caseywatts
caseywatts / bookmarkleting.md
Last active May 2, 2024 03:04
Making Bookmarklets

This is one chapter of my "Chrome Extension Workshops" tutorial, see the rest here: https://gist.github.com/caseywatts/8eec8ff974dee9f3b247

Unrelated update: my book is out! Debugging Your Brain is an applied psychology / self-help book

Making Bookmarklets

I'm feeling very clever. I've got this sweet line of javascript that replaces "cloud" with "butt". My mom would LOVE this, but she doesn't computer very well. I'm afraid to show her the Developer Console and have her type/paste this in. But she IS pretty good at bookmarks, she knows just how to click those!

A bookmark normally takes you to a new web page. A bookmarklet is a bookmark that runs javascript on the current page instead of taking you to a new page. To declare that it is a bookmarklet, the "location" it points to starts with javascript:.