Skip to content

Instantly share code, notes, and snippets.

@idettman
idettman / to-array-copy.html
Created March 1, 2016 19:00
Shortcut to copy array or array like objects
Array.toArray = Array.prototype.slice.call;
Array.copy = Array.prototype.slice.call;
@idettman
idettman / shell copy file content to variable
Created March 15, 2016 00:56
shell copy file content to variable
# Read input file
var str input ; cat "/folder/somefile.txt" > $input
# Remove everything before "foo"
stex "]^foo^" $input > null
# Remove everything after "foo"
stex "^foo^[" $input > null
@idettman
idettman / maybe.js
Last active November 25, 2017 19:48
JavaScript maybe
function maybe(fn) {
let i = 0, length = 0
return function () {
length = arguments.length
if (length) {
for (i = 0; i < length; ++i) {
if (!arguments[i]) {
return;
}
}
@idettman
idettman / compose-variations.js
Last active February 18, 2017 08:00
JavaScript composition variations
function compose (a, b)
{
return function applyArguments (c)
{
return a(b(c));
}
}
/**
* @param {Function} a
@idettman
idettman / unary.js
Created March 18, 2016 06:17
JavaScript Unary Decorator
function unary(fn)
{
if (fn.length == 1)
{
return fn;
}
else return function(item)
{
return fn.call(this, item);
}
@idettman
idettman / tap.js
Created March 18, 2016 06:19
JavaScript K Combinator (Tap)
function tap(value)
{
return function(fn)
{
if (typeof(fn) === 'function')
{
fn(value);
}
return value;
}
INSERT INTO iad_blitz.test (c)
SELECT (MAX(self_selection.c) + 1)
FROM iad_blitz.test AS self_selection
WHERE NOT EXISTS (
SELECT self_does_not_exist.c
FROM iad_blitz.test AS self_does_not_exist
WHERE self_does_not_exist.c=4
);
VBoxManage hostonlyif ipconfig "VirtualBox Host-Only Ethernet Adapter" --ip XX.XX.XX.XX --netmask 255.255.255.0
angles,sin degrees:
rotate the camera along the Y axis 45 degrees, then rotate up the X axis by -35 degrees.
@idettman
idettman / ssh-using-proxy.sh
Created January 4, 2017 17:48
connect to ssh using proxy
ssh USERNAME@TARGETDOMAIN -o "ProxyCommand=nc -X connect -x PROXYHOST:PROXYPORT %h %p"