Skip to content

Instantly share code, notes, and snippets.

View smolin's full-sized avatar

Steve Molin smolin

View GitHub Profile
@smolin
smolin / cheat_ruby.rb
Last active February 22, 2017 02:33
a simple cheatsheet for ruby
# constants
MYCONSTANT = 123
# strings
myString = 'a b c'
myString = "a b c #{expression}'
# lists
myList = [1,2,3,4,5]
# some methods of list:
@smolin
smolin / cheat_java.txt
Created March 6, 2017 16:33
Simple Java Cheat Sheet
# Hello World
public class YourName {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
# Fundamental data types and examples
int 99 boolean true char 'a'
@smolin
smolin / howto_ssmtp.txt
Created August 11, 2017 20:07
send email from linux with ssmtp
These instructions will allow root to send email from the
system through a dedicated gmail account, as for example for
smartd monitoring.
Props to https://tecadmin.net/send-email-smtp-server-linux-command-line-ssmtp/
for the starting point for this information.
Sign up for a dedicated gmail account.
Turn on "allow less secure apps".
@smolin
smolin / howto_smartd.txt
Last active September 27, 2017 14:44
monitor a disk drive in linux using smartd and send reports with email
In /etc/smartd.conf, add a line like this before the line with DEVICESCAN in it:
/dev/sda -m your_email@domain.com -M test
The "-M test" says to send an email when smartd starts (in order to test the
email channel).
@smolin
smolin / buildDjango.ansible
Last active September 28, 2017 20:52
'django startproject' yields simplest working project; this Ansible playbook adds a bunch more steps, mostly from the official tutorial.
# Ansible Playbook
#
# This will create a new Django project with a single app; and will add files and set
# stuff up to demonstrate a Template, a Model, a Migration, and Url includes.
#
# you must have django-admin in your PATH, probably via virtualenv, to make this work
#
# By Steve Molin. GPL.
---
- hosts: all
@smolin
smolin / promises_in_nodejs.txt
Last active November 17, 2017 19:59
Promise patterns in node.js
After reading a lot of pages about Promises, this page finally started making sense for me. It's a looong read and quite advanced but there are some good nuggets that help clarify things:
https://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html
#. Always end a promise compose chain with
catch(console.log.bind(console))
#. Inside a .then() ALWAYS RETURN OR THROW never let it be 'undefined'
@smolin
smolin / notes on packer-terraform-gcloud
Last active December 19, 2017 18:26
notes on packer-terraform-gcloud
# status of various google services
https://status.cloud.google.com
# configurations, cf # cf https://stackoverflow.com/questions/35744901/how-to-change-the-active-configuration-profile-in-gcloud
#
# list known configurations:
gcloud config configurations list
#
# switch to a config:
gcloud config configurations activate MY_OLD_CONFIG
@smolin
smolin / notes on docker-vagrant-gcloud
Last active December 19, 2017 18:26
notes on docker-vagrant-gcloud
# see also https://gist.github.com/smolin/d91b76b0eb84665e0958a1e4cf157e19
(docker build .)
#
# nb: use project ID 'vc-dev-smolin-f263' NOT project name 'vc-dev-smolin':
docker tag alpine gcr.io/vc-dev-smolin-f263/alpine
# docker 'login' against a remote image repo (nb: this isn't really a login in
# traditional sense, it only makes available a credential for use in future
# interactions):
@smolin
smolin / nikon-d7500-menus.txt
Last active April 4, 2018 22:49
nikon d7500 menu index
U1 = M with back focus
U2 = ?
U1 = M with back focus
U2 = ?
AF assist light : pencil a9
AF fine-tune : setup 2.4
AF on shutter (back focus) : pencil a6
AF orientation store : pencil a5
@smolin
smolin / ansible-adhoc.sh
Last active July 11, 2018 14:53
Wrapper script for ansible-playbook to apply a role to a host without playbook or hosts file.
#!/bin/bash
#
# Originally by Konstantin Suvorov, see for more info:
# https://stackoverflow.com/questions/38350674/ansible-can-i-execute-role-from-command-line
#
# With modifications by Steve Molin
# Number (vs lexical) comparison
if [[ $# -lt 2 ]]; then