Skip to content

Instantly share code, notes, and snippets.

@unixpickle
unixpickle / cat.svg
Created August 27, 2018 00:51
conCATenation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@smoser
smoser / README.md
Last active December 7, 2018 16:54
curtin install to second disk in a vm via uvtool (uvt-kvm)

Curtin development on uvt-kvm

uvtool (uvt-kvm) provides the ability to easily launch an ubuntu guest of kvm.

This can be used for testing curtin from bzr or from the Ubuntu archive.

For more information on getting started with uvtool, see Ubuntu doc. Once that is set up you can follow along here.

Note that much of this document is not uvt-kvm specific. That is just used as an easy way to get an Ubuntu vm with a spare disk. You could just as easily do this on a cloud instance (OpenStack, Azure, DigitalOcean).

@unixpickle
unixpickle / search.js
Created June 7, 2017 19:32
Search JavaScript objects
function searchValue(needle, haystack, depth) {
var recur;
recur = (findVal, obj, path, res, depth) => {
if (obj === findVal) {
res.push(path);
}
if (depth === 0) {
return;
}
if ('object' === typeof obj && obj !== null) {
@zwaldowski
zwaldowski / safari-inline-video.sh
Last active December 10, 2020 07:31
Safari Inline Video
defaults write com.apple.Safari WebKitMediaPlaybackAllowsInline -bool false
defaults write com.apple.SafariTechnologyPreview WebKitMediaPlaybackAllowsInline -bool false
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2AllowsInlineMediaPlayback -bool false
defaults write com.apple.SafariTechnologyPreview com.apple.Safari.ContentPageGroupIdentifier.WebKit2AllowsInlineMediaPlayback -bool false
@unixpickle
unixpickle / alloc.go
Created August 3, 2016 02:06
Test memory allocation
package main
import (
"fmt"
"os"
"strconv"
)
func main() {
if len(os.Args) != 2 {
@unixpickle
unixpickle / proxy.go
Last active July 19, 2016 14:33
Tiny TCP proxy
package main
import (
"io"
"log"
"net"
"time"
)
var ListenHost = ":1234"
@unixpickle
unixpickle / writeup.md
Last active April 17, 2016 13:57
Image Unblur

This example shows how we might blur and unblur 4x4 images. Let b0 through b15 be pixels in a blurred image. For example, the pixel at coordinates (2,3) is b14, since 14 is 2+3*4. Likewise, let the pixels of an unblurred image be x0 through x15.

Whenever we blur an image x into a blurred image b, we average each pixel of x with the pixels around it, giving the corresponding pixel of b. For example:

b5 = 1/5*x1 + 1/5*x4 + 1/5*x5 + 1/5*x6 + 1/5*x9

The output pixel b5 is at (1,1), so we compute it by averaging the pixels at (1,0), (1,2), (2,1), (0,1), and (1,1). This formula is similar for all the other pixels. Thus, we get:

@mchow01
mchow01 / TWTR-tracker.py
Last active July 6, 2020 21:12
Twitter Stream Tracker + Inserting Data into (MySQL) Database
import tweepy
import MySQLdb
import sys
import os
import logging
# Tweepy API doc here: http://pythonhosted.org/tweepy/html/api.html
# Keys
consumer_key = os.getenv("TWITTER_CONSUMER_KEY")
//Given this:
NSArray *objects = @[@1, @2, @3]
//These are equivalent in behavior
NSNumber *first = [objects objectAtIndex:0]
NSNumber *second = (NSNumber *)CFArrayGetValueAtIndex(objects, 0)
//But is the code that runs the same? Not so much… in the first one we do…
objc_msgSend(objects, <selector reference>, 0)
-> http://sealiesoftware.com/msg/x86-mavericks.html
@unixpickle
unixpickle / data.csv
Last active January 24, 2016 03:10
Actor identification tree
Name Age Children Sings Acts Active HasBeenMarried Female
Leonardo DiCaprio 41 0 false true true false false
Johnny Depp 52 2 false true true true false
Brad Pitt 52 6 false true true true false
Tom Cruise 53 3 false true true true false
Tom Hanks 59 4 false true true true false
Christian Bale 41 2 false true true true false
Will Smith 47 0 false true true true false
Denzel Washington 61 4 false true true true false
Robert Downey Jr. 50 3 false true true true false