Skip to content

Instantly share code, notes, and snippets.

View amowu's full-sized avatar
🧑‍💻

Amo Wu amowu

🧑‍💻
View GitHub Profile
@amowu
amowu / helpers.jsx
Created March 19, 2017 15:02 — forked from carl0zen/helpers.jsx
Styled Components helpers
import styled, { css } from "styled-components";
import {
borderProps,
marginProps,
backgroundColorProps,
paddingProps,
alignmentProps,
positioningProps,
sizeProps,
:first-child i === 0
:last-child i === arr.length - 1
:only-child arr.length === 1
:nth-child(even) i % 2
:nth-child(odd) !(i % 2)
:nth-child(n) i === n - 1
:nth-last-child(n) i === arr.length - n
@mixin for-size($range) {
$phone-upper-boundary: 600px;
$tablet-portrait-upper-boundary: 900px;
$tablet-landscape-upper-boundary: 1200px;
$desktop-upper-boundary: 1800px;
@if $range == phone-only {
@media (max-width: #{$phone-upper-boundary - 1}) { @content; }
} @else if $range == tablet-portrait-up {
@media (min-width: $phone-upper-boundary) { @content; }
@amowu
amowu / frozen-objects.js
Created January 15, 2017 08:38 — forked from ericelliott/frozen-objects.js
Frozen object
const a = Object.freeze({
foo: 'Hello',
bar: 'world',
baz: '!'
});
a.foo = 'Goodbye';
// Error: Cannot assign to read only property 'foo' of object Object
@amowu
amowu / restful.module.js
Created September 4, 2016 05:29 — forked from seyDoggy/restful.module.js
An AngularJS RESTful Constructor
/**
* @ngdoc module
* @name Restful
* @description
*
* Restful is a base class from which to extend and create more CRUD services
* without the need to repeat the same CRUD operations and implementation
* with each additional service.
*
* The Restful factory takes one argument, a configuration object.
@amowu
amowu / svgfixer.js
Created August 17, 2016 03:27 — forked from leonderijke/svgfixer.js
Fixes references to inline SVG elements when the <base> tag is in use.
/**
* SVG Fixer
*
* Fixes references to inline SVG elements when the <base> tag is in use.
* Firefox won't display SVG icons referenced with
* `<svg><use xlink:href="#id-of-icon-def"></use></svg>` when the <base> tag is on the page.
*
* More info:
* - http://stackoverflow.com/a/18265336/796152
* - http://www.w3.org/TR/SVG/linking.html
@amowu
amowu / package.json
Created May 14, 2016 09:19 — forked from addyosmani/package.json
npm run-scripts boilerplate
{
"name": "my-app",
"version": "1.0.0",
"description": "My test app",
"main": "src/js/index.js",
"scripts": {
"jshint:dist": "jshint src/js/*.js'",
"jshint": "npm run jshint:dist",
"jscs": "jscs src/*.js",
"browserify": "browserify -s Validating -o ./dist/js/build.js ./lib/index.js",
@amowu
amowu / README.md
Created October 27, 2015 11:06 — forked from zenorocha/README.md
A template for Github READMEs (Markdown) + Sublime Snippet

Project Name

TODO: Write a project description

Installation

TODO: Describe the installation process

Usage

function getZodiacSign(date) {
if(!(date instanceof Date)) date = new Date();
var dateStr = +[
date.getMonth() + 1,
('0' + date.getDate()).slice(-2)
].join('')
,signs = [
[120, 'Capricorn'],
[219, 'Aquarius'],
history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head