Skip to content

Instantly share code, notes, and snippets.

View Dockerfile
FROM alpine:latest
ENV MYSQL_CONNECTOR_VERSION 2.1.3
ENV MYSQL_CONNECTOR_ARCHIVE mysql-connector-python-${MYSQL_CONNECTOR_VERSION}.tar.gz
ENV MYSQL_KEYID 5072E1F5
COPY ${MYSQL_CONNECTOR_ARCHIVE}.asc ${MYSQL_CONNECTOR_ARCHIVE}.asc
RUN apk add --no-cache --virtual .deps curl mysql-dev gnupg file gcc python-dev musl-dev g++ && \
apk add --no-cache python && \
View counterstring.js
function counterstring(length) {
var curNum = length;
var outLen = 0;
var numbers = [];
var curStr;
while (outLen < length) {
curStr = curNum.toString() + "*";
curNum -= curStr.length;
if (outLen + curStr.length <= length) {
@davidsm
davidsm / ws.js
Created Dec 16, 2015
Simple wrapper for a Websocket connection that accepts and sends JSON data
View ws.js
exports.websocket = {
connect: function (address) {
var ws = new WebSocket(address);
var promise = new Promise(function (resolve, reject) {
ws.onopen = function (e) {
var wsObj = {
socket: ws,
handlers: {}
};
@davidsm
davidsm / replace-all.el
Created Jul 24, 2015
Emacs string replace function that works on the entire buffer regardless of cursor position
View replace-all.el
(provide 'mystuff)
(defun replace-all (from to)
(interactive "sReplace: \nsWith: ")
(save-excursion
(goto-char (point-min))
(replace-string from to)
)
)
View .emacs
;; Useful stuff for .emacs
;;;;;
;; Key-bindings
;;;;;
(global-set-key (kbd "C-x C-b") 'ibuffer)
(global-set-key (kbd "C-c C-q") 'comment-or-uncomment-region)
;;;;;
View gist:daeb0787dcfb3c9982a0
## .tmux.conf
set -g status-bg default
set -g status-fg white
set -g status-left "#[fg=green]#H"
set-window-option -g window-status-current-bg blue
set -g status-interval 10
bind M-w run-shell "tmux save-buffer - | xclip -i"
@davidsm
davidsm / kv
Created Jul 9, 2014
yasnippet for variable number of key-value pairs (concept shamefully stolen from https://github.com/capitaomorte/yasnippet/issues/348)
View kv
# -*- mode: snippet -*-
# name: keyvalue
# key: kv
# type: command
# --
(let ((yas-good-grace nil)
(count (* 2 (read-number "Number of elements: "))))
(yas-expand-snippet
(concat "{\n"
"\t"