Skip to content

Instantly share code, notes, and snippets.

@DCRichards
DCRichards / gist:d3bc4f3b610074f0db5f
Created January 22, 2015 21:19
Data logging in a Pebble Background Worker
#include <pebble_worker.h>
DataLoggingSessionRef data_logger;
int num_samples = 1;
static void data_handler(AccelData *data, uint32_t samples) {
data_logging_log(data_logger, data, samples);
}
static void worker_init() {
@DCRichards
DCRichards / Dog.java
Last active August 29, 2015 14:16
A simple dog class
public class Dog {
String name;
public Dog(String name) {
this.name = name;
System.out.println("Hello, I'm " + name);
}
public void bark() {
@DCRichards
DCRichards / branchFromIssue.js
Created August 30, 2016 21:23
Create a git branch from a GitHub issue
javascript: (function(){var e=prompt("Enter the prefix for your branch (eg. bug, feature)","feature")||"feature",t=document.getElementsByClassName("js-issue-title")[0].innerText||"my-new-feature";t=t.replace(/\s/g,"-"),t=t.replace(/[^a-zA-Z0-9-]/g,""),t=t.toLowerCase();var r=e+"/"+t;alert("git push origin dev:"+r+" && git checkout -t origin/"+r)}());
@DCRichards
DCRichards / main.go
Created February 16, 2018 13:05
Golang profiling 1
package main
import (
"log"
"net/http"
pp "net/http/pprof"
"time"
)
func main() {
@DCRichards
DCRichards / add-ssh.sh
Created March 28, 2018 13:39
Adding an SSH key
cp id_rsa_mylib ~/.ssh
cp id_rsa_mylib.pub ~/.ssh
ssh-add ~/.ssh/id_rsa_mylib
@DCRichards
DCRichards / ssh-keygen.sh
Created March 28, 2018 13:42
Generate SSH key
ssh-keygen -t rsa -b 4096 -C "user@host or just a comment"
FROM golang:1.9
# (other stuff omitted for brevity)
# Add your keys to the container
COPY ssh /root/.ssh
# Start the SSH Agent, add the SSH Key and then ensure our dependencies
RUN eval "$(ssh-agent)" && ssh-add /root/.ssh/id_rsa && dep ensure
pipeline:
test:
image: golang:1.9-alpine
pull: true
commands:
- apk --update add git openssh
- go get -u github.com/golang/dep/cmd/dep
- cp -R ssh /root/.ssh
# We need this or we'll be warned about our private key security.
- chmod 0400 /root/.ssh/id_rsa
git ls-remote git@bitbucket.org:you/greatlib.git
#!/bin/sh
set -e
eval "$(ssh-agent)"
ssh-add /root/.ssh/id_rsa
exec "$@"