Skip to content

Instantly share code, notes, and snippets.

View argyleink's full-sized avatar
💀
calc(dev*design)

Adam Argyle argyleink

💀
calc(dev*design)
View GitHub Profile
@argyleink
argyleink / ice-reveal.module.js
Last active May 7, 2018 21:24
simple, safe, compose-able, testable logic container
const module = (deps) => {
const actuallyPrivate = 'foo'
return Object.freeze({
interface
})
const interface = () =>
console.log(deps, actuallyPrivate)
}
@argyleink
argyleink / word-break.css
Last active December 12, 2017 18:28
Cross browser word-break, so long urls and "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww" don't outgrow your containers.
.word-break {
-ms-word-break: break-all;
word-break: break-word;
word-wrap: break-word;
-webkit-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
}
@argyleink
argyleink / history.coffee
Created November 26, 2017 21:46
my code history
history = [
1999: 'VRML'
2000: 'HTML'
2000: 'CSS'
2000: 'JavaScript'
2000: 'XML'
2005: 'ActionScript2'
2007: 'Java'
2007: 'PHP'
2007: 'MySQL'
@argyleink
argyleink / likes.rxjs.ts.js
Created January 6, 2017 22:14
There an easier way? RXJS subject to increment likes on an array object
// this really what it takes to increment a counter on an item in my observable
// likes is a subject, broadcasting the updated array eventually to the source observable being rendered
this.likes
.map(
(message: Message): IMessagesOperation =>
(messages: Message[]) => {
return messages.map((m: Message) => {
// todo: check if user has already liked
if (m.id == message.id)
++m.likes
const el = function(options) {
let node = document.createElement(options.type || 'div')
if (options.id) node.id = options.id
if (options.class) node.className = options.class
if (options.text) node.textContent = options.text
if (options.html) node.innerHTML = options.html
return node
}

Booting Up A Development Server

Open a console. Terminal.app on Macs, your shell or whatever on PCs.

Python is easiest:

python -m SimpleHTTPServer 8000

Then go to http://localhost:8000/ in a web browser.

This is a small collection of scripts showing how to use require.js. It's only one of several ways of setting up a require.js project, but it's enough to get started.

At its core, require.js is about three things:

  1. Dependency management
  2. Modularity
  3. Dynamic script loading

The following files show how these are achieved.

@argyleink
argyleink / .htaccess mobile redirect
Last active December 19, 2015 21:39
Dead simple ipad (or whatever), redirect to custom index.html. I made this so that the viewport meta data can be present immediately for ipad, to prevent flashing of content. This is a great way around many JS hacks.
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "ipad" [NC]
RewriteRule ipad.html [L,QSA]
@argyleink
argyleink / SVG htaccess
Created July 17, 2013 15:58
Teach Apache to serve SVG
AddType image/svg+xml svg
AddType image/svg+xml svgz
@argyleink
argyleink / vendorPrefix.js
Created April 22, 2013 21:35
Require.js ready vendor prefix extractor
vendor.prefix = (function () {
'use strict';
var styles = window.getComputedStyle(document.documentElement, '')
, pre = (Array.prototype.slice
.call(styles)
.join('')
.match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o'])
)[1]
, dom = ('WebKit|Moz|MS|O').match(new RegExp('(' + pre + ')', 'i'))[1];