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_sql.txt
Last active December 20, 2023 01:11
simple SQL cheatsheet
# props to codecademy.org for great interactive intro to SQL
# CREATE
CREATE TABLE mytable...
CREATE TABLE mytable(id INTEGER PRIMARY KEY, name TEXT);
# a "foreign key" is a reference to a "primary key" in another table
# INSERT
INSERT INTO mytable ...
@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 / Makefile
Last active February 4, 2023 09:02
configure GCE instance with Nvidia drivers and NoMachine NX
# other options include teradici, paperspace and fram.me
# variables
instance = instance5
image = ubuntu-1604-xenial-v20171107b
# get update to this file
update:
curl -L https://gist.github.com/smolin/ea1f506b74e90bcb729007c50dbe25b7/raw/ > Makefile
@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 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 / notes on git and github.txt
Last active January 12, 2021 17:43
notes on git and github
# Github
## fatal: The upstream branch of your current branch does not match the name of your current branch.
git branch -u origin/$(git rev-parse --abbrev-ref HEAD)
# Undo