Skip to content

Instantly share code, notes, and snippets.

View claudiopro's full-sized avatar
🐠

Claudio Procida claudiopro

🐠
View GitHub Profile
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 8, 2024 02:11
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@mattheworiordan
mattheworiordan / jquery.focus.test-fix.js
Created August 23, 2011 22:47
Fix for :focus pseudo selector when browser does not have focus
/**
* JQuery tries to use native CSS selectors instead of the Sizzle selector
* engine for performance reasons.
*
* This causes problems when trying to test intefaces using the
* :focus pseudo selector as unless the web page and browser window
* has the focus, all elements are considered to be without focus.
* Checking for :focus in Selenium or Capybara tests therefore fail if
* using JQuery or Sizzle.
*
@tonious
tonious / hash.c
Last active February 17, 2023 02:25
A quick hashtable implementation in c.
/* Read this comment first: https://gist.github.com/tonious/1377667#gistcomment-2277101
* 2017-12-05
*
* -- T.
*/
#define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */
#include <stdlib.h>
#include <stdio.h>
@bzerangue
bzerangue / currency-symbols.xml
Last active February 28, 2022 11:52
World currencies with their symbols
<?xml version="1.0" encoding="UTF-8"?>
<!--
## SOURCE: xe.com
-->
<currency-symbol count="115">
<entry code="ALL" unicode-decimal="76, 101, 107" unicode-hex="4c, 65, 6b">Albania Lek</entry>
<entry code="AFN" unicode-decimal="1547" unicode-hex="60b">Afghanistan Afghani</entry>
<entry code="ARS" unicode-decimal="36" unicode-hex="24">Argentina Peso</entry>
<entry code="AWG" unicode-decimal="402" unicode-hex="192">Aruba Guilder</entry>
<entry code="AUD" unicode-decimal="36" unicode-hex="24">Australia Dollar</entry>
@SunboX
SunboX / inlineworker.js
Created June 24, 2013 12:21
Create web workers without a separate worker JS files. Source: http://jsbin.com/owogib/8/
function worker() {
setInterval(function() {
postMessage({foo: "bar"});
}, 1000);
}
var code = worker.toString();
code = code.substring(code.indexOf("{")+1, code.lastIndexOf("}"));
var blob = new Blob([code], {type: "application/javascript"});
@btm1
btm1 / set-repeat.js
Created September 28, 2013 20:17
Set repeat is an AngularJS directive to iterate over a group of elements only one time and not add any watch listeners. It works the same way as ng-repeat and uses angular templating engine to render it's results. i.e. set-repeat="message in messages" where messages is an array of objects. This iteration will not update if the length of the arra…
angular.module('setRepeat',[]).directive('setRepeat', function () {
return {
transclude: 'element',
priority: 1000,
compile: compileFun
};
function compileFun(element, attrs, linker) {
var expression = attrs.setRepeat.split(' in ');
@rbuckton
rbuckton / Promise.finally.md
Last active December 18, 2016 15:53
Proposal for addition of Promise.prototype.finally

NOTE I have yet to update this proposal, but I find @domenic's version here to be a much improved implementation:

Promise.prototype.finally = function (callback) {
    return this.then(
        value => this.constructor.resolve(callback()).then(() => value),
        reason => this.constructor.resolve(callback()).then(() => throw reason)
    );
};
@mikaelbr
mikaelbr / gulpfile.js
Last active February 8, 2021 00:32 — forked from Sigmus/gulpfile.js
Gulp + Browserify + Reactify + OS Notification
var source = require('vinyl-source-stream');
var gulp = require('gulp');
var gutil = require('gulp-util');
var browserify = require('browserify');
var reactify = require('reactify');
var watchify = require('watchify');
var notify = require("gulp-notify");
var scriptsDir = './scripts';
var buildDir = './build';
@jchild3rs
jchild3rs / gist:470be49a4bc4caf3ca8a
Last active April 8, 2020 15:54
Hologram Gulp Plugin
/*
// Usage:
gulp.task('docs', function(cb) {
gulp.src('path/to/your/src')
.pipe(hologram(cb));
});
*/
var gulp = require('gulp'),
notify = require('gulp-notify'),
@paulirish
paulirish / what-forces-layout.md
Last active May 6, 2024 07:54
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent