Skip to content

Instantly share code, notes, and snippets.

Avatar

Tobias Koppers sokra

  • Germany
View GitHub Profile
View Map-vs-Set-vs-Native.js
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
var testArray = [];
for (var s = 0; s < 5000; s++) {
testArray.push(Math.floor(s * 0.1));
}
console.log('Testing used ids')
View Map-vs-native-cache.js
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
var testArray = [];
for (var s = 0; s < 5000; s++) {
testArray.push(Math.floor(Math.random() * 100));
}
console.log('Testing caching')
View index.html
<script src="1ea296932eacbe248905.js"></script>
<script src="0b3a074667143853404c.js"></script>
<script src="0dd8c061aff2a2791815.js"></script>
<script src="191b812fa5f7504151f7.js"></script>
<script src="08702f45497539ef6ea6.js"></script>
<script src="195c9326275620b0e9c2.js"></script>
<script src="19817b3a0378aedb2143.js"></script>
<script src="0e7a65e649387d773247.js"></script>
<script src="13167c9702de79d2f4fd.js"></script>
<script src="1154be40ff0e8dd16e9f.js"></script>
@sokra
sokra / 0--entry.js
Last active Sep 24, 2015
bespoke + react + webpack
View 0--entry.js
import React from "react";
import bespoke from "bespoke";
import "styles.css";
// use react components, markdown or plain html files in the slides folder
var slidesContext = require.context("./slides", true, /\.(js|md|html)$/);
// sort slides by name, name them like this: ./slides/3-section/7-slide.md
var slides = slidesContext.keys().sort().map((key) => slidesContext(key));
@sokra
sokra / 0 - MyComponent.jsx
Last active Apr 1, 2016
CSS Local scope with importing
View 0 - MyComponent.jsx
import React from "react";
import styles from "./MyComponent.css";
export class MyComponent {
render() {
return <div className={styles.root}>
<div className={styles.inner}>
<button className={styles.sendButton}>Send</button>
</div>
</div>
View webpack.js
// webpack is a module bundler
// This means webpack takes modules with dependencies
// and emits static assets representing those modules.
// dependencies can be written in CommonJs
var commonjs = require("./commonjs");
// or in AMD
define(["amd-module", "../file"], function(amdModule, file) {
// while previous constructs are sync
// this is async
@sokra
sokra / gist:4251038
Created Dec 10, 2012
jmpress.js templates
View gist:4251038
$.jmpress("template", "nav1", {
children: function(idx) {
var distanceX = 240;
var distanceY = 170;
var config = {
scale: 0.2,
y: -1,
x: ((idx%5) - 2) * (1/2),
rotateY: 360,
secondary: {