Skip to content

Instantly share code, notes, and snippets.

View fredyang's full-sized avatar

Fred Yang fredyang

View GitHub Profile
@fredyang
fredyang / test-parallel-function.js
Last active February 15, 2019 18:54
a parallel wrapper function
//run this in node.js, firefox only, not in browser chrome for now
const parallel = async (...items) => {
const temp = [];
for (const item of items) {
temp.push(await item);
}
return temp;
};
const someResult = async () => {
# Thanks to this post:
# http://blog.ikato.com/post/15675823000/how-to-install-consolas-font-on-mac-os-x
$ brew install cabextract
$ cd ~/Downloads
$ mkdir consolas
$ cd consolas
$ curl -O http://download.microsoft.com/download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26/PowerPointViewer.exe
$ cabextract PowerPointViewer.exe
$ cabextract ppviewer.cab
@fredyang
fredyang / SassMeister-input.scss
Created January 27, 2016 16:36
Generated by SassMeister.com.
// ----
// libsass (v3.3.2)
// ----
//nested rules
#main p {
color: #00ff00;
width: 97%;
.redbox {
@fredyang
fredyang / SassMeister-input.scss
Created December 31, 2015 22:27
Generated by SassMeister.com.
// ----
// libsass (v3.3.2)
// ----
//case 1
.modal {
&__header { color: red};
}
@fredyang
fredyang / SassMeister-input.scss
Created October 1, 2015 04:29
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
.sidebar {
width: 300px;
@media screen and (orientation: landscape) {
width: 500px;
}
}
@fredyang
fredyang / jasmine_spec.js
Created June 26, 2015 15:12
jasmine test template
'use strict';
describe('A suite', function () {
it('contains spec with an expectation', function () {
expect(true).toBe(true);
});
});
describe('A suite is just a function', function () {
var a;
@fredyang
fredyang / random.js
Created April 1, 2015 14:35
angular filter to select on item froom array
'use strict';
app.filter('random', function () {
function randomInt(min, max) {
return Math.round(Math.random() * (max - min) + min);
}
return function (items) {
var i = randomInt(0, items.length - 1);
function evalObjectPath(hostObj, pathExpression) {
var parts = pathExpression.split('.');
for (var i = 0; i < parts.length; i++) {
var value = hostObj[parts[i]];
if (value === undefined) {
return hostObj;
} else {
hostObj = value;
}
}
@fredyang
fredyang / SassMeister-input.scss
Created January 19, 2015 04:43
Generated by SassMeister.com.
// ----
// Sass (v3.4.9)
// Compass (v1.0.1)
// ----
$themes: (
brand1: (
color: yellow
@fredyang
fredyang / gist:3e89b3ec8ad63ae3fc1c
Created January 2, 2015 19:44
test an object is scope
function isScope(obj) {
return obj && obj.$evalAsync && obj.$watch;
}