Skip to content

Instantly share code, notes, and snippets.

View Zodiase's full-sized avatar

Xingchen Hong Zodiase

View GitHub Profile
@Zodiase
Zodiase / any.js
Last active January 6, 2017 19:54
Blaze Useful Template Helpers
import { Template } from 'meteor/templating';
/**
* Returns true when any of the provided arguments is true.
* Example:
* > {{#if some varA varB varC}}
* > At least something is true.
* > {{/if}}
*/
Template.registerHelper('some', (...args) => args.some(Boolean));
@Zodiase
Zodiase / style.css
Last active December 5, 2016 16:21
Github code printing CSS
@media print {
/* Hide everything other than code. */
body.page-blob .header[role=banner],
body.page-blob [role=main] .pagehead.repohead,
body.page-blob [role=main] .repository-content > :not(.file),
body.page-blob [role=main] .repository-content > .file > .file-header > .file-actions,
body.page-blob .site-footer-container {
display: none;
}
@Zodiase
Zodiase / .gitignore
Last active November 9, 2016 18:48
Selenium-Webdriver Example
node_modules
/**
* @param {function} func - The function to call. The payload of the promise.
* @param {Array.<*>} args - The list of arguments for `func`.
* @param {*} ctx - The context for `func`.
*/
function makePromise(func, args, ctx) {
return new Promise(function (resolve, reject) {
try {
func.apply(ctx, Array.prototype.concat.call(args, function (err, result) {
if (err) { reject(err); } else { resolve(result); }
// Omit the last argument (the callback) of the original function and use promise instead.
function wrapAsPromise (func) {
var expectedArgCount = func.length - 1;
return function () {
// Only the last argument (the callback) can be missing.
switch (true) {
case arguments.length < expectedArgCount:
throw new Error('Not enough arguments given. Expecting ' + expectedArgCount + '.');
break;
case arguments.length < expectedArgCount:
@Zodiase
Zodiase / document.wflow
Created August 8, 2016 11:06
Zip Each - Automator Workflow
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AMApplicationBuild</key>
<string>419</string>
<key>AMApplicationVersion</key>
<string>2.6</string>
<key>AMDocumentVersion</key>
<string>2</string>
@Zodiase
Zodiase / Dockerfile
Last active October 18, 2016 21:10
TerraRef BD Hyperspectral Extractor notes
# Dockerfile for the TerraRef hyperspectral image conversion extractor
# August 17, 2016
FROM ubuntu:14.04
MAINTAINER Yan Y. Liu <yanliu@illinois.edu>
# install common libraries and python modules
USER root
RUN apt-get update
RUN apt-get upgrade -y -q
RUN apt-get install -y -q build-essential m4 swig antlr libantlr-dev udunits-bin libudunits2-dev unzip cmake wget git libjpeg-dev libpng-dev libtiff-dev
@Zodiase
Zodiase / chase-text2csv.js
Last active June 20, 2016 17:05
Parse the text data from Chase Checking or Saving activities and save as a CSV file.
'use strict';
const nodePath = process.argv[0],
exePath = process.argv[1],
inputPath = process.argv[2],
fs = require('fs');
if (typeof inputPath === 'undefined') {
throw new Error('Need to specify input file path.');
}
@Zodiase
Zodiase / 1.Starting-up.md
Last active April 11, 2016 23:48
Factorio Layout Examples

Minimal self-sustaining mining

image

Burner inserters will pickup coals to keep themselves running while supplying others.

@Zodiase
Zodiase / promise-example-parallel.js
Last active April 4, 2016 20:41
Examples of using Promise.
// Start from a Promise.
var foo = new Promise(function (resolve, reject) {
// Has to resolve to run callbacks in `.then()`.
resolve(1);
});
foo.then(function (result) {
// Received final resolve value from the Promise.
// result === 1;
console.log('result 1', result);