Skip to content

Instantly share code, notes, and snippets.

View marcuswestin's full-sized avatar

Marcus Westin marcuswestin

  • New York
View GitHub Profile
let addItem = handler() { Global.items.push(Local.text) }
let containerStyle = { padding: 5, margin: 5, border: '1px solid' }
<div style=containerStyle>
<input data=Global.foo />
<br /> "Global.foo: " Global.foo
</div>
<div style=containerStyle>
"Add item with text: " <input data=Local.text />
<div class="rooms">
<input data=Local.newRoomName />
<button>"Create new room"</button onclick=handler() {
Global.rooms.unshift(new { name:Local.newRoomName, messages:[] })
Local.newRoomName.set('')
}>
for room in Global.rooms {
<div class="room">
<div class="name">room.name</div onclick=handler() { Local.currentRoom = room }>
</div>
<div class="rooms">
<input data=Local.newRoomName />
<button>"Create new room"</button onclick=handler() {
Global.rooms.unshift(new { name:Local.newRoomName, messages:[] })
Local.newRoomName.set('')
}>
for (room in Global.rooms) {
<div class="room">
<div class="name">room.name</div onclick=handler() { Local.currentRoom = room }>
</div>
@marcuswestin
marcuswestin / gist:726413
Created December 3, 2010 01:01
A chat application written in fun with multiple chat rooms
import Local
import Global
<div class="rooms">
<input data=Local.newRoomName />
<button>"Create new room"</button onclick=handler() {
let newRoom = new { name:Local.newRoomName, messages:[] }
Global.rooms.unshift(newRoom)
Local.newRoomName.set('')
}>
# The embed code is compressed and minified using the closure compiler.
# Please run ./compile to build the embed code.
#
# Lines starting with #<space> will be removed during compilation.
# Lines starting with #<A> will be included only for target A.
# A line can be included in multiple targets if the target names
# are separated with '|', e.g. #spacebook|myface alert('hello');
/**
* If the code is included twice, the second instance will not adversely
@marcuswestin
marcuswestin / Selenium-SauceLabs-NodeJS.js
Created March 21, 2011 21:29
Get started using Selenium with SauceLabs and NodeJS
require('soda').createSauceClient({ 'username': 'username-string', 'access-key': 'access-key-string',
'url': 'http://example.saucelabs.com/', 'max-duration': 300,
'os': 'Windows 2003', 'browser': 'firefox', 'browser-version': '3.6',
'name': 'This is an example test' }).chain.session()
.open('/')
.getTitle(function(title){
require('assert').ok(~title.indexOf('Cross browser testing with Selenium - Sauce Labs'), 'Title did not include the query');
})
.testComplete()
.end(function(err){
var textEl = document.createElement('div'),
container = document.createElement('div'),
lineHeight = 25 // pixels of a single line
container.appendChild(textEl)
function showText(text) {
// hide the text while we test its layout. visibility='hidden' still keeps the element in the DOM, in contrast to display='none'
textEl.style.visibility = 'hidden'
textEl.innerHTML = text
textEl.style.textAlign = (textEl.offsetHeight > lineHeight
? 'left' // overflowing onto two lines
@marcuswestin
marcuswestin / little_server.js
Created May 17, 2011 03:25
Little require server
var port = 8080
require('require/server').mount(require('http').createServer(function(req, res) {
if (req.url == '/') {
res.end('<body><script src="/require/little_client"></script></body>')
}
}), { port:port }).listen(port)
var raphael = require('raphael')
var paper = raphael(100, 100, 200, 200),
circle = paper.circle(100, 100, 100)
circle.attr("fill", "#f00")
circle.attr("stroke", "#fff")
@marcuswestin
marcuswestin / get-started-with-cliend-side-npm.sh
Created May 17, 2011 04:29
Get started with client-side NPM modules
mkdir app
cd app
echo '{ "name":"app" }' > package.json
sudo npm install require
sudo npm install raphael
curl -O https://gist.github.com/raw/975866/little_server.js
curl -O https://gist.github.com/raw/975868/little_client.js
node little_server.js