Skip to content

Instantly share code, notes, and snippets.

@ntrepid8
ntrepid8 / gen_server_tpl.ex
Created November 2, 2016 16:06
Elixir GenServer Template
defmodule GenServerTpl do
@moduledoc """
A GenServer template for a "singleton" process.
"""
use GenServer
# Initialization
def start_link(opts \\ []) do
GenServer.start_link(__MODULE__, opts, [name: __MODULE__])
end
@ntrepid8
ntrepid8 / muslrust-cross-notes.md
Last active October 7, 2016 05:24
muslrust-cross-notes

MuslRust-Cross Notes

There are several primary steps:

  1. build toolchain with crosstool-ng
  2. compile libunwind and add to toolchain
  3. compile std with the new toolchain
  4. link rust-cross toolchain with rustup
  5. build rust binaries :)
@ntrepid8
ntrepid8 / autossh-jump-rtunnel.service
Last active October 7, 2020 01:45
AutoSSH reverse tunnel service config for systemd
[Unit]
Description=AutoSSH reverse tunnel service for jump.you.io 100022 -> 22
After=network.target
[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -o "ExitOnForwardFailure=yes" -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -NR 10022:127.0.0.1:22 [email protected] -i /home/root/.ssh/id_rsa
[Install]
WantedBy=multi-user.target
@ntrepid8
ntrepid8 / bash-prompt.md
Created July 25, 2016 14:05
A bash prompt example

To get a bash promp that looks like this:

bash-prompt-example

Use this code in your .bashrc file:

source /etc/bash_completion.d/git-prompt
if [ "$color_prompt" = yes ]; then
 #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
@ntrepid8
ntrepid8 / .screenrc-main-example
Created July 13, 2016 16:22 — forked from ChrisWills/.screenrc-main-example
A nice default screenrc
# GNU Screen - main configuration file
# All other .screenrc files will source this file to inherit settings.
# Author: Christian Wills - [email protected]
# Allow bold colors - necessary for some reason
attrcolor b ".I"
# Tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
@ntrepid8
ntrepid8 / rust_examples.md
Last active January 22, 2019 06:57
Examples of things I need while learning Rust.

Rust Examples

Disclaimer: there may be errors in these examples. Copy them at your own risk.

Some snippets and examples I want to be able to refer to while learning the Rust Language. Having the snippets here makes it easier for me to remember them.

Convert Vec<T> to Vec<String>

I have found it useful to be able to convert a Vec<T> into a Vec<String>, especially for tests where I want to convert a Vec<str> into a Vec<String> for use elsewhere in the application.

@ntrepid8
ntrepid8 / Vagrantfile
Last active August 7, 2016 17:03
A nice base Vagrantfile for debian/jessie64 on Virtualbox.
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# Every Vagrant development environment requires a box. You can search for
require 'Unirest'
require 'json'
puts "testing"
begin
url = "http://stage.maasive.net/v2.4/5379f153b2c4271b06d88351/plays/"
parameters = {
:user_score=>5,
:alien_score=>1,
@ntrepid8
ntrepid8 / fit_bit_oauth.py
Created March 24, 2014 15:54
FitBit OAuth
import requests
import time
import random
from hashlib import sha1
import hmac
import binascii
from getpass import getpass
from urllib import urlencode, quote, quote_plus
from urlparse import parse_qs
from pprint import pprint, pformat
class MessagesHandler(tornado.web.RequestHandler):
@tornado.gen.coroutine
def get(self):
db = self.settings['db']
rb = []
cursor = db.messages.find().sort([('_id', -1)])
messages = yield cursor.to_list(length=50)
while messages:
[rb.append({'id': m['_id'], 'msg': m['msg']}) for m in messages]
messages = yield cursor.to_list(length=50)