Skip to content

Instantly share code, notes, and snippets.

View n1k0's full-sized avatar
✏️
writing a github status

Nicolas Perriault n1k0

✏️
writing a github status
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="A sample react dropdown menu component" />
<script src="//fb.me/react-with-addons-0.10.0.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div id="menu"></div>
var casper = require("casper").create();
var arr1 = [], arr2 = [], arr3 = [];
casper.start("http://foo.bar/", function() {
arr1.push("plop1");
});
casper.thenOpen("http://bar.foo/", function() {
arr2.push("plop2");
});
@n1k0
n1k0 / views.js
Last active August 29, 2015 13:59
ugly
var l10n = {
translate: function(el) {
console.log("l10n.translate() called for ", el);
}
};
function makeL10n(ViewClass) {
var oldRender = ViewClass.prototype.render;
ViewClass.prototype.render = function renderL10n() {
oldRender.apply(this, arguments);
@n1k0
n1k0 / bbtest.html
Created February 3, 2014 11:50
Convenient way for a Backbone model view to listen to its model changes while being hold within a Collection
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<ul id="list">
<li>nope</li>
</ul>
<input type="button" id="btn" value="change">
@n1k0
n1k0 / poor-man-text-editor.md
Last active August 29, 2015 13:55
Paste this to your browser url bar

Poor man text editor

Paste this to your browser url bar:

data:text/html,

@n1k0
n1k0 / Preferences.sublime-settings
Created January 21, 2014 18:44
My Sublime Text 3 preferences
{
"bold_folder_labels": true,
"caret_style": "smooth",
"color_scheme": "Packages/User/Flatland Monokai (SL).tmTheme",
"default_encoding": "UTF-8",
"detect_slow_plugins": false,
"draw_minimap_border": false,
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"fade_fold_buttons": true,
(defn default-hash-map [default keys]
(into {} (map #(hash-map % default) (seq keys))))
;; user> (default-hash-map 0 [:a :b])
;; {:a 0, :b 0}
@n1k0
n1k0 / words.js
Last active December 20, 2015 22:39
module.exports = function Words(words) {
"use strict";
function frequencies(freq, word) {
freq[word] = word in freq ? freq[word] + 1 : 1;
return freq;
}
return {
get count() {
@n1k0
n1k0 / bob.js
Created August 11, 2013 18:21
"use strict";
function is_silence(message) { return message.length === 0; }
function is_shouting(message) { return message.toUpperCase() === message; }
function is_question(message) { return message.slice(-1) === '?'; }
module.exports = function Bob() {
var defaults = "Whatever.";
var reactions = [[is_silence, "Fine, be that way!"],
[is_shouting, "Woah, chill out!"],
@n1k0
n1k0 / test-http-headers.js
Created July 26, 2013 12:45
Testing HTTP headers using CasperJS
casper.test.begin('Testing HTTP headers', 1, function(test) {
casper.start('http://google.com/', function(res) {
test.assertEquals(res.headers.get('Content-Type'), 'text/html; charset=UTF-8');
});
casper.run(function() {
test.done();
});
});