Skip to content

Instantly share code, notes, and snippets.

View nelix's full-sized avatar
🎯
Focusing

Nathan Hutchision nelix

🎯
Focusing
View GitHub Profile
@0xjjpa
0xjjpa / chrome.md
Created December 9, 2012 04:37
Understanding Google Chrome Extensions

#Introduction

Developing Chrome Extensions is REALLY fun if you are a Front End engineer. If you, however, struggle with visualizing the architecture of an application, then developing a Chrome Extension is going to bite your butt multiple times due the amount of excessive components the extension works with. Here are some pointers in how to start, what problems I encounter and how to avoid them.

Note: I'm not covering chrome package apps, which although similar, work in a different way. I also won't cover the page options api neither the new brand event pages. What I explain covers most basic chrome applications and should be enough to get you started.

Table of Contents

  1. Understand the Chrome Architecture
  2. Understand the Tabs-Extension Relationship
  3. Picking the right interface for the job
@benfoxall
benfoxall / unusedcss.js
Created June 25, 2013 11:44
quick function to find which selectors aren't being used.
function each(items,fn){[].forEach.call(items,fn)}
each(document.styleSheets, function(sheet){
each(sheet.cssRules, function(r){
try{
// look for the first matching element
if(!document.querySelectorAll(r.selectorText)[0])
console.log("Unused Selector: ", r.selectorText);
} catch (e){
{
"manifest_version": 2,
"name": "Chrome Socket API Server",
"description": "listen & accept for socket",
"version": "0.1",
"app": {
"background": {
"scripts": ["server.js"]
}
},

Displaying images in the terminal with tput and echo

output

Requires ImageMagick, easily available from your favorite package manager. Tested on Linux and OSX
convert image.png -resize 40 txt:-|sed -E 's/://;s/\( ? ?//;s/, ? ?/,/g;s/\)//;s/([0-9]+,[0-9]+,[0-9]+),[0-9]+/\1/g;s/255/254/g;/mage/d'|awk '{print $1,$2}'|sed -E 's/^0,[0-9]+ /print "echo;tput setaf "\;/;s/^[0-9]+,[0-9]+ /print "tput setaf ";/;s/(.+),(.+),(.+)/\1\/42.5*36+\2\/42.5*6+\3\/42.5+16/'|bc|sed 's/$/;echo -n "  ";/'|tr '\n' ' '|sed 's/^/tput rev;/;s/; /;/g;s/$/tput sgr0;echo/'|bash
@threepointone
threepointone / project.js
Last active March 22, 2016 10:20
project: Facebook's reconcilliation algorithm in regular js, applied to dom nodes License: MIT
"use strict";
var _ = require('underscore'),
slice = [].slice;
var mutations = {
append: append,
remove: remove,
replace: replace,
setAttr: setAttr
@xem
xem / codegolf.md
Last active January 2, 2025 16:05
JS code golfing

codegolf JS

Mini projects by Maxime Euzière (xem), subzey, Martin Kleppe (aemkei), Mathieu Henri (p01), Litterallylara, Tommy Hodgins (innovati), Veu(beke), Anders Kaare, Keith Clark, Addy Osmani, bburky, rlauck, cmoreau, maettig, thiemowmde, ilesinge, adlq, solinca, xen_the,...

(For more info and other projects, visit http://xem.github.io)

(Official Slack room: http://jsgolf.club / join us on http://register.jsgolf.club)

@xmlking
xmlking / Enum.es6.js
Last active June 25, 2019 18:09
JavaScript Enums with ES6, Type Checking and Immutability
export class EnumSymbol {
sym = Symbol.for(name);
value: number;
description: string;
constructor(name: string, {value, description}) {
if(!Object.is(value, undefined)) this.value = value;
if(description) this.description = description;
@jashkenas
jashkenas / semantic-pedantic.md
Last active November 22, 2024 04:13
Why Semantic Versioning Isn't

Spurred by recent events (https://news.ycombinator.com/item?id=8244700), this is a quick set of jotted-down thoughts about the state of "Semantic" Versioning, and why we should be fighting the good fight against it.

For a long time in the history of software, version numbers indicated the relative progress and change in a given piece of software. A major release (1.x.x) was major, a minor release (x.1.x) was minor, and a patch release was just a small patch. You could evaluate a given piece of software by name + version, and get a feeling for how far away version 2.0.1 was from version 2.8.0.

But Semantic Versioning (henceforth, SemVer), as specified at http://semver.org/, changes this to prioritize a mechanistic understanding of a codebase over a human one. Any "breaking" change to the software must be accompanied with a new major version number. It's alright for robots, but bad for us.

SemVer tries to compress a huge amount of information — the nature of the change, the percentage of users that wil

@insin
insin / app.jsx
Last active August 29, 2015 14:06
R E A C T O M E T E R (Live version: :http://bl.ocks.org/insin/raw/efb444d8e0390da2c7ec/)
/** @jsx React.DOM */
'use strict';
var Ometer = React.createClass({
propTypes: {
leading: React.PropTypes.string
, highlight: React.PropTypes.func
, spacing: React.PropTypes.bool
, suffix: React.PropTypes.string
@threepointone
threepointone / oia_csp.js
Last active March 22, 2016 10:19
an implementation of rob pike's parallel search slide in oia
oia(lets [go chan put take timeout alts] (require 'js-csp/lib/csp') (do
(fn fake [kind]
(fn [c query]
(go (gen []
(yield (take (timeout (js Math.random()*200))))
(yield (put c [kind query]))))))
(def web1 (fake :web1))
(def web2 (fake :web2))