Skip to content

Instantly share code, notes, and snippets.

View Pyrolistical's full-sized avatar

Pyrolistical

View GitHub Profile
@Pyrolistical
Pyrolistical / node.magic_dom.js
Created December 5, 2011 02:55
WIP of amix/node.magic_dom which passes jslint
var MagicDOM = {
createDOM: function (name, attrs) {
var i = 0,
attr;
var elm = new Element(name);
var first_attr = attrs[0];
if (MagicDOM._isDict(attrs[i])) {
var z;
for (z = 0; z < first_attr.length; j++) {
@Pyrolistical
Pyrolistical / cpwd
Created December 26, 2011 01:35
contextural pwd - shows at most the grandparent of the current directory
#!/bin/bash
nicepwd=`pwd | sed "s|$HOME|~|"`;
# count the number of slashes in pwd
slashes=`pwd | perl -pe 's/[^\/]//g' | wc -m`
if [ $slashes -le 2 ]; then
echo "$nicepwd";
else
@Pyrolistical
Pyrolistical / bug.html
Created December 6, 2013 19:24
getBBox-rounded-rect bug
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="snap.svg.js"></script>
</head>
<body>
<svg id="main" xmlns="http://www.w3.org/2000/svg" version="1.1" height=100%>
</svg>
<script>
@Pyrolistical
Pyrolistical / functions.js
Last active December 28, 2017 04:10 — forked from RedBeard0531/functions.js
Mongo map reduce functions to calculate sum, min, max, count, average, population variance, sample variance, population standard deviation, sample standard deviation Public Domain License
function map() {
emit(1, {
sum: this.value, // the field you want stats for
min: this.value,
max: this.value,
count: 1,
diff: 0
});
}
@Pyrolistical
Pyrolistical / bug.groovy
Created January 31, 2014 19:47
Spock framework VerifyError: (class: BuggedTest, method: $spock_feature_0_0 signature: ()V) Stack size too large bug
@Grab("org.spockframework:spock-core:0.7-groovy-2.0")
import spock.lang.Specification
class BuggedTest extends Specification {
def thing = []
def "repo the bug"() {
given:
#!/usr/bin/env bash
##############################################################################
##
## maven-settings-decoder start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and MAVEN_SETTINGS_DECODER_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
@Pyrolistical
Pyrolistical / hlight
Created November 28, 2014 00:57
highlights text from stdin
#!/bin/bash
grep --color "$1\|\$" -
@Pyrolistical
Pyrolistical / ts
Created November 28, 2014 00:59
timestamp each line from stdin
#!/bin/bash
DATECMD='gdate +%s%N'
process_stdout() {
while read line; do
echo -e `$DATECMD`"\t$line"
done
}
@Pyrolistical
Pyrolistical / .profile
Created December 24, 2014 01:19
best .profile
RIGINAL_PATH='/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'
source `brew --prefix git`/etc/bash_completion.d/git-prompt.sh
source `brew --prefix git`/etc/bash_completion.d/git-completion.bash
export JAVA_HOME=`/usr/libexec/java_home`
export MAVEN_HOME='/usr/local/opt/maven/libexec/'
export PATH="$ORIGINAL_PATH:/Users/rchen/dev/tools/bin"
@Pyrolistical
Pyrolistical / less-nested.js
Created April 29, 2016 18:05
example how to reduce nesting
const getUserByEmail = (connection, userEmail) => {
const userPromise = connection
.queryAsync(‘SELECT `id` FROM `user` WHERE `email` = ?’, [
userEmail
])
.then(R.head);
const permissionsPromise = userPromise
.then(R.unless(R.isNil, (user) => connection
.queryAsync(‘SELECT `id`, `name` FROM `permission` WHERE `user_id` = ?’, [