Skip to content

Instantly share code, notes, and snippets.

@patterns
patterns / beagleboneblack.txt
Created February 25, 2017 12:53
Build Bitcoin full node on BeagleBone Black
#!/bin/sh
# Download latest Debian image for microSD from https://beagleboard.org/latest-images
# List drives before inserting microSD
df -h
# Insert microSD, then Look for the newly listed SD drive (disk2s1)
df -h
# Unmount the microSD
@patterns
patterns / btcgui-notes.txt
Created February 5, 2017 10:21
Documentation from BtcGui on starting up, and the related cert files.
Linux/BSD/POSIX/Source
Run the following command to start btcd:
$ btcd --testnet -u rpcuser -P rpcpass
Copy btcd's autogenerated rpc.cert to ~/.btcwallet/ so btcwallet can securely communicate with btcd over a TLS-encrypted websocket. This step is only necessary for the first time starting btcwallet or if
btcd's autogenerated cert and key are removed and regenerated.
$ mkdir ~/.btcwallet/
$ cp ~/.btcd/rpc.cert ~/.btcwallet/btcd.cert
@patterns
patterns / git-ghpages.sh
Last active April 5, 2017 05:00
Typical Git workflow for Github pages.
#!/bin/sh
# initial email config
git config --global --edit
# per commit modify name
git commit --amend --author="patterns <>"
# sync overwriting local branch
git fetch --all
git reset --hard origin/gh-pages
# typical github pages steps
@patterns
patterns / s3-upload.go
Created February 3, 2017 05:31
AWS S3 file storage example from the Go docs
package main
import (
"fmt"
"log"
"os"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
@patterns
patterns / youtube-dl.sh
Created February 3, 2017 04:28
Save sound from Youtube video URL
#!/bin/bash
#brew install youtube-dl
#brew install ffmpeg
youtube-dl --extract-audio --audio-format mp3 -k https://youtu.be/short-url-path
@patterns
patterns / extract-sound.sh
Created February 3, 2017 04:25
Use ffmpeg to extract audio from source video files
#!/bin/bash
INFILE="$1"
TMPOUTFILE="${INFILE%.*}"
OUTFILE="${TMPOUTFILE##*/}.m4a"
ffmpeg -i "${INFILE}" -vn -acodec copy "${OUTFILE}"
@patterns
patterns / splice-sound.sh
Created February 3, 2017 04:17
Use ffmpeg to splice sound file by specifying start time position (-ss) and duration (-t)
#!/bin/sh
ffmpeg -ss 00:00:00.000 -i Source.mp3 -t 44 -c copy cut00.mp4
@patterns
patterns / lib.go
Created October 28, 2016 10:41
Microsvc to compare adapters vs facade
package main
import (
"crypto/sha1"
"crypto/sha256"
"fmt"
)
// Adaptee is the existing functionality.
type Adaptee struct {
@patterns
patterns / readme.txt
Created October 27, 2016 05:31
Practice adapter pattern on SHA1 / SHA256 / .....
Reference https://msdn.microsoft.com/en-us/library/orm-9780596527730-01-04.aspx
Attempt of the pluggable adapter according to this excerpt:
// Existing way requests are implemented
class Adaptee {
public double Precise (double a, double b) {
return a/b;
}
}
@patterns
patterns / lru.py
Created October 24, 2016 20:45
My very first Python script ever!
#lru.py
#loop input until 'EXIT'
read_line = ""
data = []
while read_line.lower() != "exit":
read_line = raw_input()
if read_line.lower() != "exit":
data.append(read_line)