Skip to content

Instantly share code, notes, and snippets.

View send2moran's full-sized avatar
🎯
Focusing

Moran Helman send2moran

🎯
Focusing
  • Tel Aviv, Israel
View GitHub Profile
<!--
scaling background, as seen on normative.com
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Scaling Background</title>
<meta name="warning" content="HC SVNT DRACONES" />
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.6.0/build/reset/reset-min.css" />
# These are my notes from the PragProg book on CoffeeScript of things that either
# aren't in the main CS language reference or I didn't pick them up there. I wrote
# them down before I forgot, and put it here for others but mainly as a reference for
# myself.
# assign arguments in constructor to properties of the same name:
class Thingie
constructor: (@name, @url) ->
# is the same as:
@nowk
nowk / array_helpers.js
Last active August 29, 2015 13:59
Kata Array Helpers
/* jshint node: true */
var assert = require("chai").assert;
var origNumbers = [1, 2, 3, 4, 5];
var numbers = [1, 2, 3, 4, 5];
/*
* square each item in array
@drmikecrowe
drmikecrowe / app.js
Last active October 27, 2021 04:28
Sharing constants between node.js app and web app
//** In web app **//
var current = constants.STATE_WAITING;
anonymous
anonymous / spread mixin
Created August 14, 2014 09:46
.spread(@offsetTop:0, @offsetRight:0, @offsetBottom:0, @offseLeft:0) {
position: absolute;
top: @offsetTop;
right: @offsetRight;
bottom: @offsetBottom;
left: @offseLeft;
}
@mathisonian
mathisonian / index.md
Last active March 22, 2023 05:31
requiring npm modules in the browser console

demo gif

The final result: require() any module on npm in your browser console with browserify

This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.

Update: There are much better ways of accomplishing the same, and the script has been updated to use a much simpler method pulling directly from browserify-cdn. See this thread for details: mathisonian/requirify#5

inspiration

@STRML
STRML / gist:2117f574726bdf0b8d58
Created June 24, 2015 19:38
Relying on React as an external

The problem:

When writing a React component, you want to target all environments. It is easy to generate a build that will work on the server and browser with Webpack, and as a bonus you can use loaders (like babel-loader for ES6 code).

When you generate this bundle, you should rely on "react" as an external so it isn't included in the bundle. In all environments this is desired behavior so you don't duplicate "react" and break it. This is necessary both because it would make a much larger bundle than necessary, but also because React behaves badly when multiple copies are loaded.

If you do this, you'll end up with a UMD shim like:

(function webpackUniversalModuleDefinition(root, factory) {