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_logout
Last active December 15, 2015 02:21
My Bash Stuff
# .bash_logout
# Executed after logout of bash shells
clear
@demoive
demoive / 1-questions.md
Last active December 20, 2015 06:58
Front-end Developer Questions Customized list of questions/answers for front-end developer interviews. It is an offshoot of the great, user-contributed list located here: https://github.com/darcyclarke/Front-end-Developer-Interview-Questions/
  1. What is the "smallest" number possible in JavaScript?

  2. Explain why the following doesn't work as an IIFE. What needs to be changed to properly make it an IIFE? function foo(){ }();

  3. What is arr.length?

var arr = [];
arr[10] = 'ten';
function PrimeNumberGenerator() {
this.indx = 2;
}
PrimeNumberGenerator.prototype.next = function () {
var counter = 2;
while (counter < this.indx) {
if (this.indx % counter++ === 0) {
counter = 2;
@demoive
demoive / .vimrc
Last active December 18, 2015 07:19
My configuration file for Vim
syntax on " turns syntax highlighting on
colorscheme default " defines the color scheme of the syntax highlighting
set nocompatible " (cp) use Vim defaults (much better)
set hidden " (hid) hide buffers instead of closing them when they are abandoned
set ruler " (ru) show the cursor position at all times
set showcmd " (sc) display an incomplete command in the lower right
set history=100 " (hi) keep 50 lines of command history
set undolevels=100 " (ul) maximum number of changes that can be undone
set number " (nu) show line numbers
@demoive
demoive / vendorify.less
Last active December 17, 2015 16:49
A LESS mixin to generate vendor-specific (browser-specific/experimental) CSS properties.
.vendorify(@prop, @vals...) {
@property: e('@{prop}');
@values: `'@{arguments}'.replace(/^\[|\]$/g, '').split(', ').splice(1)`;
// v1.6.0 added interpolation allowing us to do this:
-o-@{property}: @values;
-ms-@{property}: @values;
-moz-@{property}: @values;
-webkit-@{property}: @values;
@{property}: @values;
@demoive
demoive / .htaccess
Created May 8, 2013 05:35
SSi18n configuration files Used for the seed: For the https://github.com/demoive/SSi18n
### General settings
#####################################
DirectoryIndex index.inc
Options +FollowSymlinks
Options -Indexes
### Enable GZIP compression
#####################################
@demoive
demoive / supplant.js
Last active December 16, 2015 20:58
Variable substitution on a string. Modified from Douglas Crockford's to use {{double curly braces}}.
/**
* Variable substitution on a string.
*
* Scans through a string looking for expressions enclosed within double curly braces.
* If an expression is found, use it as a key on the object,
* and if the key has a string or number value,
* it is substituted for the bracket expression and it repeats.
*
* Originally by Douglas Crockford: http://javascript.crockford.com/remedial.html
*/
@demoive
demoive / validoku.js
Last active December 15, 2015 00:59
Validates a Sudoku game. The input (vals) is assumed to be an array of arrays with numerical values from 1 through 9.
/**
* Validates a Sudoku game.
* The input <vals> is assumed to be an array of arrays with numerical values from 1 through 9.
*/
function validoku(vals) {
var val,
x, y, blockX,
uniqRow = {},
uniqCols = [{}, {}, {}, {}, {}, {}, {}, {}, {}], // this construct could be "built up" on each loop iteration, but it's done this way for clarity of example
uniqBlocks = [{}, {}, {}];
@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()
@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);