Skip to content

Instantly share code, notes, and snippets.

View demoive's full-sized avatar

Paulo Ávila demoive

  • Barcelona
View GitHub Profile
@demoive
demoive / gist:4563398
Last active February 9, 2025 17:16
CDNJS Combo Loader

CDNJS Combo Loader

A proposal for CDNJS to support combined requests allowing their resources to be served in a reduced number of HTTP connections (inspiration by YUI's combo loading service).

[UPDATE: This has been offically declined in issue 791 for CDNJS. I'm keeping the proposal in this gist for posterity].

Example

Instead of four separate requests:

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
@demoive
demoive / Preferences.sublime-settings
Last active December 10, 2015 22:08
My Preferences.sublime-settings
{
"color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme",
"font_face": "monaco",
"font_size": 12.0,
"ignored_packages":
[
"Vintage"
],
"rulers":
[
@demoive
demoive / gist:4500063
Last active February 9, 2025 17:16
Snippet - setInterval Variant
(function INTERVAL() {
// do stuff
setTimeout(INTERVAL, 5);
}());
@demoive
demoive / gist:4500046
Last active February 9, 2025 17:16
Snippet - eval() Equivalent Equivalent to eval("CODE TO BE EVALED");
(new Function("return " + "CODE TO BE EVALED"))();
@demoive
demoive / gist:4500041
Last active February 9, 2025 17:17
Snippet - Code Injection Injects some new code to the end of a pre-existing function, essentially redefining it.
if (typeof(MYFUNC) === "function") {
eval(String(MYFUNC).replace(/\}\s*$/, ";NEWCODE;}"));
}
@demoive
demoive / slugify.js
Last active February 9, 2025 17:17
Converts a string to a "URL-safe" slug
/**
* Converts a string to a "URL-safe" slug.
* Allows for some customization with two optional parameters:
*
* @param {string} Delimiter used. If not specified, defaults to a dash "-"
* @param {array} Adds to the list of non-alphanumeric characters which
* will be converted to the delimiter. The default list includes:
* ['–', '—', '―', '~', '\\', '/', '|', '+', '\'', '‘', '’', ' ']
*/
if (!String.prototype.slugify) {