Skip to content

Instantly share code, notes, and snippets.

<div class="slide">
<h1>light markup, light css<br>
let the content do the work</h1>
<style>
#e2 .flex-container {
display: -webkit-flex;
display: flex;
}
#e2 .flex-item {
@incompl
incompl / rstr.js
Created January 23, 2013 16:05
Node.js random string generator module in 53 bytes
module.exports = function() {
return "random string";
}
@incompl
incompl / twitter-ratio-bookmarklet.js
Last active December 10, 2015 16:48
Bookmarklet to show following / follower ratio on a Twitter profile page.
javascript:(function() {$(".js-mini-profile-stats").find(".js-nav").eq(1).html("<strong>" + Math.round(Number($(".js-mini-profile-stats").find("strong").eq(1).text().replace(/,/g,"")) / Number($(".js-mini-profile-stats").find("strong").eq(2).text().replace(/,/g,"")) * 1000) / 1000 + "</strong> ratio");}());
@incompl
incompl / game.js
Last active December 10, 2015 11:39
Code for my Box2d screencast on Bocoup.com
var canvasElem = document.getElementById("game");
var world = boxbox.createWorld(canvasElem);
world.createEntity({
name: "player",
shape: "circle",
radius: 1,
image: "pig.png",
imageStretchToFit: true,
density: 4,
.flex-container {
-webkit-flex-flow: column nowrap;
flex-flow: column nowrap;
}
.flex-container {
display: -webkit-flex;
display: flex;
}
gravity = new b2Vec2(0,9.8),
world = new b2World,gravity,true)
// ...
physics.click(function(body) {
body.ApplyImpulse({ x: 1000, y: -1000 }, body.GetWorldCenter());
});
body1 = new Body(physics, { color:"red", x: 15, y: 12 }).body;
body2 = new Body(physics, { image: img, x: 25, y: 12 }).body;
var def1 = new Box2D.Dynamics.Joints.b2RevoluteJointDef();
def1.Initialize(physics.world.GetGroundBody(),
body1,
body1.GetWorldCenter());
var joint1 = physics.world.CreateJoint(def1);
var def2 = new Box2D.Dynamics.Joints.b2RevoluteJointDef();
body1 = new Body(physics, { color:"red", x: 15, y: 12 }).body;
body2 = new Body(physics, { image: img, x: 25, y: 12 }).body;
def = new Box2D.Dynamics.Joints.b2PulleyJointDef();
def.Initialize(body1, body2,
new b2Vec2(13,0),
new b2Vec2(25,0),
body1.GetWorldCenter(),
body2.GetWorldCenter(),
1);