Skip to content

Instantly share code, notes, and snippets.

@js-dot-js
js-dot-js / _index.html
Last active Oct 29, 2019
Poor Man's React
View _index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Poor Man's React</title>
<link rel="stylesheet" href="./css/styles.css" />
</head>
<body>
@js-dot-js
js-dot-js / grunt_do.coffee
Created Feb 1, 2016
Publishing workflow for Grunt
View grunt_do.coffee
fs = require('fs')
# Transform sentence case to a filename
fileize = (date, title, extension) ->
characters = /("|'|!|\?|:|\s\z)/ig
whitespace = /\s/ig
"#{date}-#{title.replace(characters, '').replace(whitespace, '-').toLowerCase()}.#{extension}"
module.exports = (grunt) ->
grunt.initConfig
@js-dot-js
js-dot-js / local_auth.postman_collection.json
Created May 8, 2015
Postman collection for local auth with angular-fullstack Yeoman generator
View local_auth.postman_collection.json
{
"id": "e0ff964f-6dd8-6c2a-1444-6afa58ff1500",
"name": "Local Auth",
"description": "",
"order": [
"1e7c070f-2ad5-a777-8aea-da9e4a1b75bf",
"4423ded8-e38e-d852-9dd6-9177368e6d09"
],
"folders": [],
"timestamp": 1431125920517,
@js-dot-js
js-dot-js / post-receive.sh
Last active Aug 29, 2015
Git push-to-deply post-receive hook
View post-receive.sh
#!/bin/sh
# $HOME/opt/git/example.git/hooks/post-receive
#
# The "post-receive" script is run after receive-pack has accepted a pack
# and the repository has been updated. It is passed arguments in through
# stdin in the form
# <oldrev> <newrev> <refname>
# For example:
# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
#
@js-dot-js
js-dot-js / fastest_fizzbuzz.js
Created Sep 5, 2013
The fastest JavaScript fizzbuzz I've seen. Ported from https://gist.github.com/ggilder/2893724, which also explains what's going on.
View fastest_fizzbuzz.js
var acc = 810092048;
var aMillion = 1000000;
var number = 1;
var log = function(value) {
console.log(value);
};
function bitwiseFizzBuzz(i) {
var c = acc & 3, a = 'fizzbuzz';
@js-dot-js
js-dot-js / overloaded.coffee
Created Jul 16, 2013
MVC where the controller is a mediator and the views are both observers and colleagues.
View overloaded.coffee
class List
constructor: () ->
# A list of pointers
@items = []
# Objects passed in by pointer
@objects = {}
# Returns the number of objects in the list
count: () ->
@js-dot-js
js-dot-js / story_time.html
Last active Dec 19, 2015
The definitive format for user stories. Add as many scenarios as needed.
View story_time.html
<!DOCTYPE html>
<html ng-app="storyTime">
<head>
<title>Story time</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
<style>body {padding: 50px;} .navbar .brand {margin-left: 0;}</style>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script>
View sweet_python.txt
macro python {
// Print
case print $params (,) ... => {
console.log(( $params (,) ... ))
}
// Function definition
case def $name:ident ( $params (,) ... ) : $a $b ... => {
function $name( $params (,) ... ) { python $a $b ... }
}
// Function call
View common-media-queries.css
/* This is a small sampling of the various approaches to media queries. The
point is: they're all over the board. Part of the "issue" (if you can call
it that) may be due to the intended audience of each site/framework. Another
may be that it's really difficult to test for a lot of different devices.
Regardless, it would be really nice if there was standard baseline that
could be used as a starting point for maximum compatibility and coverage. */
/* ==========================================================================
Frameworks
========================================================================== */
@js-dot-js
js-dot-js / xrayquire_tree.js
Created Aug 14, 2012
Generate dependency tree for RequireJS apps with xrayquire
View xrayquire_tree.js
xrayquire = {
// ...
getTree: function (contextName) {
var context = requirejs.s.contexts[contextName || '_'],
xray = getX(context),
traced = xray.traced,
tree = {};
sortTraceOrder(xray.traceOrder);