Skip to content

Instantly share code, notes, and snippets.

View dsamarin's full-sized avatar

Devin Samarin dsamarin

View GitHub Profile
<!doctype html>
<html>
<head>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Rethink+Sans:wght@400;600&display=swap" rel="stylesheet">
</head>
<body><div>
<div class="row">
<div class="status"><div class="status-dot"></div></div>
@dsamarin
dsamarin / UndoStack.js
Created July 5, 2012 00:37
Easy undo-redo in JavaScript.
function UndoItem (perform, data) {
this.perform = perform;
this.data = data;
}
/**
* UndoStack:
* Easy undo-redo in JavaScript.
**/
@dsamarin
dsamarin / Complex.js
Created October 3, 2011 03:11
Complex numbers in JavaScript
var Complex = function(real, imag) {
if (!(this instanceof Complex)) {
return new Complex (real, imag);
}
if (typeof real === "string" && imag == null) {
return Complex.parse (real);
}
this.real = Number(real) || 0;
@dsamarin
dsamarin / user-permissions.sql
Last active October 29, 2019 09:27
MySQL new database, user, grant permissions cheatsheet
-- =========
-- = Users =
-- =========
-- Create new user
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
-- Delete user
DROP USER 'username'@'localhost';
@dsamarin
dsamarin / all-orders-placed-by-a-customer.sql
Created October 9, 2019 08:31 — forked from dan81989/all-orders-placed-by-a-customer
Let’s say we want to find all orders placed by a particular customer. We can do this by joining the customers and orders tables together using the relationship established by the customer_id key.
SELECT order_date, order_amount
FROM customers
JOIN orders
ON customers.customer_id = orders.customer_id
WHERE customer_id = 3
// JoinNonEmpty concatenates the elements of a to create a single string. The separator string
// sep is placed between elements in the resulting string, and ignores empty strings.
func JoinNonEmpty(a []string, sep string) string {
switch len(a) {
case 0:
return ""
case 1:
return a[0]
}
n := 0
#!/bin/bash
SSH_HOST=dsamar.in
SSH_SOCKET=~/.ssh/ihs.dsamar.in.sock
SSH_TUNNEL=3306:localhost:3306
ssh -fMnNT -S "$SSH_SOCKET" -L "$SSH_TUNNEL" "$SSH_HOST"
gnucash mysql://ihs@127.0.0.1/ihs
ssh -S "$SSH_SOCKET" -O exit "$SSH_HOST"
@dsamarin
dsamarin / keybase.md
Created June 16, 2018 17:34
keybase.md

Keybase proof

I hereby claim:

  • I am dsamarin on github.
  • I am dsamarin (https://keybase.io/dsamarin) on keybase.
  • I have a public key whose fingerprint is D66E EE9F 9E05 4755 E78A 94FB D88E 7EEB 39AC FFEC

To claim this, I am signing this object:

public class System {
private static final System mInstance = new System();
static {
java.lang.System.loadLibrary("mylib");
}
private System() {
construct();
}
@dsamarin
dsamarin / licenses.txt
Created August 15, 2017 03:47
Licenses used in dependencies of Soundmesh Desktop
@material/animation@0.3.1 [license(s): Apache-2.0]
└── package.json: Apache-2.0
@material/auto-init@0.1.3 [license(s): Apache-2.0]
└── package.json: Apache-2.0
@material/base@0.2.3 [license(s): Apache-2.0]
└── package.json: Apache-2.0
@material/button@0.3.11 [license(s): Apache 2.0]