Skip to content

Instantly share code, notes, and snippets.

View juliozuppa's full-sized avatar

Julio Cesar Zuppa juliozuppa

  • Curitiba, PR, Brasil
View GitHub Profile
/**
* Repete a string informada no parâmetro str
* a quantidade de vezes informada no parâmetro num
* @param {string} str - a String a ser repetida
* @param {int} num - o número de vezes a repetir
* @returns {string}
*/
function repeat(str, num) {
var arr = [], i = 0;
while (i < num) { arr[i++] = str; }
/**
* Repete a string informada no parâmetro str
* a quantidade de vezes informada no parâmetro num
* @param {string} str - a String a ser repetida
* @param {int} num - o número de vezes a repetir
* @returns {string}
*/
function repeat(str, num) {
var arr = [], i = 0;
while (i < num) { arr[i++] = str; }
var timer = function(name) {
var start = new Date();
return {
stop: function() {
var end = new Date();
var time = end.getTime() - start.getTime();
console.log('Timer:', name, 'finished in', time, 'ms');
}
}
};
// var x let (escopo de bloco/variável local)
// let ECMAS6
var x = 45;
if(true) {
let x = 10;
console.log(x); // 10
}
console.log(x); // 45
var x = 45;
function docReady(fn) {
if (window.addEventListener) {
window.addEventListener('load', fn, false);
} else if (window.attachEvent) {
window.attachEvent('onload', fn);
}
}
@juliozuppa
juliozuppa / loop.less
Created March 29, 2017 20:53 — forked from danro/loop.less
LESS css loop example
.loop (0) {}
.loop (@index) when (@index > 0) {
.classname-@{index} {
top: @index * 1px;
}
.loop (@index - 1);
}
#example {
.loop(5);
@juliozuppa
juliozuppa / gist:cf0285f61e8ca0769749b591d9975932
Created March 29, 2017 20:52 — forked from edwinwebb/gist:5155504
A simple less loop with comments and simple from, to syntax.
/* Define two variables as the loop limits */
@from : 0;
@to : 10;
/* Create a Parametric mixin and add a guard operation */
.loop(@index) when(@index =< @to) {
/* As the mixin is called CSS is outputted */
div:nth-child(@{index}) {
top: unit(@index * 100, px);
@juliozuppa
juliozuppa / html_imagem_base64.php
Created March 13, 2017 12:40
html imagem base64
<?php
// <img src="data:image/png;base64,...> data:image/jpeg;charset=utf-8;base64,
// http://danielmclaren.com/node/90
$image = 'http://images.itracki.com/2011/06/favicon.png';
// Read image path, convert to base64 encoding
$imageData = base64_encode(file_get_contents($image));
// Format the image SRC: data:{mime};base64,{data};
@juliozuppa
juliozuppa / jquery_seletores.txt
Last active March 1, 2017 18:09
jquery_seletores
Contém:
$("input[id*='DiscountType']")
Não contém:
$("input[id!='DiscountType']")
Começa com:
$("input[id^='DiscountType']")
Termina com:
// Conectar ao bitbucket na porta 443 (caso a 22 esteja bloqueada)
# ~/.ssh/config
Host bitbucket.org
IdentityFile ~/.ssh/id_rsa
# o host é:
ssh://[email protected]:443/
# configurar agent no keepass
https://github.com/mendhak/keepass-and-keeagent-setup