Skip to content

Instantly share code, notes, and snippets.

View marcelklehr's full-sized avatar

Marcel Klehr marcelklehr

View GitHub Profile
@marcelklehr
marcelklehr / createDummyBookmarks.js
Last active May 13, 2018 22:08
Create 30,000 dummy bookmarks neatly organized into a hierarchy of folders. useful for testing. Or for frying your devices. (DON'T DO THIS AT HOME!)
function tree(start, end, indent) {
if (!indent) indent = ''
if (end-start <= 5) {
for (var i=start; i < end; i++) {
console.log(indent+'<DT><A HREF="http://url'+i+'.net/" TAGS="tag'+ (i % 100) +'">Description '+i+'</A>')
}
return
}
var step = Math.round((end-start) / 5)
for (var i=start; i < end; i+=step) {
@pascaldekloe
pascaldekloe / utf8.js
Last active September 9, 2023 05:21
JavaScript UTF-8 encoding and decoding with TypedArray
// This is free and unencumbered software released into the public domain.
// Marshals a string to an Uint8Array.
function encodeUTF8(s) {
var i = 0, bytes = new Uint8Array(s.length * 4);
for (var ci = 0; ci != s.length; ci++) {
var c = s.charCodeAt(ci);
if (c < 128) {
bytes[i++] = c;
continue;
@wmertens
wmertens / full stack redux.md
Last active February 8, 2022 22:46
making an awesome server with the redux model, Work In Progress

Thought experiment: Redux-like stateless server

Description

We describe a model for client-server processing where the Redux model is used to minimize stateful code. This should allow live-reloading server code, and make it possible to share code (e.g. optimistic updating) between client and server.

Dramatis Personae

  • Assume a server consisting of multiple worker processes that do not share memory and may be running on multiple hosts.
    • Workers have middleware, root reducers and an app state object
  • Workers can be dynamically added and removed
@WebFikirleri
WebFikirleri / snow.js
Created January 2, 2015 08:46
JavaScript Snow Effect
<script type="text/javascript">
//<![CDATA[
var snowmax=300
var snowtype=new Array("Times","Arial","Times","Verdana")
var snowcolor=new Array("#f2f8fa","#eff5f7","#dcedf1","#ffffff","#BFE4FF")
var snowletter="*"
var sinkspeed=0.6
var snowmaxsize=30
var snowminsize=10
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@willconant
willconant / fiber.js
Created November 14, 2011 17:23
Tim Caswell's Fiber idea implemented with Mozilla Javascript 1.7 generators
/* in this case, there is no explicit wait() function, instead, fiberized functions use the yield keyword */
module.exports = function(generatorFunction) {
var iterator;
function resume() {
iterator.send(arguments);
}
iterator = generatorFunction(resume);
iterator.next();
};