Skip to content

Instantly share code, notes, and snippets.

View demoive's full-sized avatar

Paulo Ávila demoive

  • Barcelona
View GitHub Profile
@demoive
demoive / bash_colors.sh
Last active August 29, 2015 14:01
Displays all the bash colors to the screen
### Bash colors and formatting
# To set the formatting/color, use the following:
# - escape character (\e, \033, \x1B)
# - open square bracket
# - attributes (semicolon-separated)
# - the letter m
#
# \033[<attribute>;...m
@demoive
demoive / .hg_template
Last active December 2, 2015 01:38
Template file for Mercurial smartlog
changeset = "{shortest(node)} {label('blue', '{author|user}')}{if(phabdiff, label('bold', \" {phabdiff}\"))}{bookmarks} {label('cyan', '({date|age})')}\n{desc|firstline}{ifeq(rev, revset('.'), '{files}{file_mods}{file_adds}{file_dels}')}\n\n"
# CURRENTLY, for some reason, the ifeq() condition doesn't work
# I think it's because we're doing the check with "current" inside this "bookmark variable"
bookmark = " {ifeq(bookmark, current, label('yellow', '{bookmark}*'), label('green', '{bookmark}'))}"
#start_files = "ALL:\n"
start_files = "\n\n {sub(\"(\d+):\s+\+(\d+)\/-(\d+)\", label('magenta underline', '\\1 files changed: +\\2/-\\3:'), diffstat)}"
file = ""
end_files = ""
@demoive
demoive / .hgrc
Last active December 3, 2015 00:06
My config settings for Mercurial
[ui]
username = Paulo Avila #<>
status.modified = blue bold # M
status.added = green bold # A
status.removed = red bold # R
#status.clean = # C
#status.deleted = cyan bold #
#status.missing = # !
#status.untracked = blue bold # ?
@demoive
demoive / gist:4500046
Last active December 10, 2015 22:08
Snippet - eval() Equivalent Equivalent to eval("CODE TO BE EVALED");
(new Function("return " + "CODE TO BE EVALED"))();
@demoive
demoive / gist:4500063
Last active December 10, 2015 22:08
Snippet - setInterval Variant
(function INTERVAL() {
// do stuff
setTimeout(INTERVAL, 5);
}());
@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:4500041
Last active December 10, 2015 22:08
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 / gist:4563398
Last active December 11, 2015 06:59
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 / gist:4648979
Last active December 11, 2015 19:29
Snippet - CSS Hide text
.hide-text {
display: block;
white-space: nowrap;
text-indent: 100%;
overflow: hidden;
}
.hide {
position: absolute;
clip: rect(1px, 1px, 1px, 1px);
@demoive
demoive / console-animations.js
Last active December 14, 2015 11:08
These "micro programs" mimic animations when run in a console. They are experiments based on a personal challenge to do "something interesting" in under 150 characters.
// growing (alternating characters) line
c=0;b="";setInterval("console.log(b=b+(c++%2?'-':'|'))",100)
// same, but w/o setInterval() ∴ w/o eval()
c=0;b="";(function f(){console.log(b=b+(c++%2?'-':'|'));setTimeout(f,100)}())
// wave
i=j=0;s="";setInterval("if(!(i++%25))++j;console.log(j%2?s+='*':s=s.substr(1))",15)
// same, but w/o setInterval() ∴ w/o eval()