Skip to content

Instantly share code, notes, and snippets.

View franklinjavier's full-sized avatar

Frank franklinjavier

View GitHub Profile
@franklinjavier
franklinjavier / installing-browser-sync-on-windows.md
Last active December 27, 2022 00:22
Usando browser-sync no Windows

O browser-sync é um ótimo módulo nodejs. Sua principal funcionalidade é a sincronização de eventos entre os dispositivos conectados. Ou seja, se você scrolla a página, esse evento será replicado em todos os dispositivos magicamente \o/. Dessa forma, tornamos os testes de web apps muito mais produtivos.

  1. Baixar e instalar o Nodejs
  2. Abrir o programa "Node.js command prompt"
  3. Baixar o browser-sync, para isso basta digitar no terminal npm install -g browser-sync
  4. Por fim, execute o comando browser-sync start --proxy "http://www.uol.com.br"
@franklinjavier
franklinjavier / Loader-experiment.markdown
Created June 21, 2014 05:53
A Pen by Franklin Javier.
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: 'app/assets/img/',
src: ['**/*.{png,jpg,gif}'],
dest: 'dist/img/'
}]
}
}
@franklinjavier
franklinjavier / requirejs-with-commonjs-wrapper.js
Last active August 29, 2015 14:02
Better way to require AMD modules - SUGAR “simplified CommonJS wrapper”
define(function( require, exports ) {
'use strict';
var defaults = require('lodash-amd/modern/objects/defaults'),
flatten = require('lodash-amd/modern/arrays/flatten'),
commands = require('./plugins/core/commands');
...
@franklinjavier
franklinjavier / dataurl.js
Created May 30, 2014 13:50
Print out data URLs for all images / canvases on the page.
// dataurl.js
// https://github.com/bgrins/devtools-snippets
// Print out data URLs for all images / canvases on the page.
(function() {
console.group("Data URLs");
[].forEach.call(document.querySelectorAll("img"), function(i) {
var c = document.createElement("canvas");
@franklinjavier
franklinjavier / yeoman-generator-git.js
Created April 15, 2014 21:54
Using git with Yoeman generator
InfoGenerator.prototype.gitCommit = function gitCommit() {
var done = this.async();
this.log('\n\nInitializing Git repository. If this fail, try running ' +
chalk.yellow.bold('git init') +
' and make a first commit manually');
var async = require('async');
@franklinjavier
franklinjavier / convertvideo.sh
Last active August 29, 2015 13:56
Convert video using avconv
#!/bin/bash
# ./convertvideo.sh file file
#
# Ex:
# ./convertvideo.sh mp4 webm
# ./convertvideo.sh video.avi video.mp4
ls *$1 \
@franklinjavier
franklinjavier / save-credentials.sh
Last active August 29, 2015 13:56
Cache your Git credentials #password #git #cache
git config --global credential.helper # 15 minutes (default).
git config --global credential.helper 'cache --timeout=3600' # timeout in seconds
# 86400 = 1 day

I'm having trouble understanding the benefit of require.js. Can you help me out? I imagine other developers have a similar interest.

From Require.js - Why AMD:

The AMD format comes from wanting a module format that was better than today's "write a bunch of script tags with implicit dependencies that you have to manually order"

I don't quite understand why this methodology is so bad. The difficult part is that you have to manually order dependencies. But the benefit is that you don't have an additional layer of abstraction.


@franklinjavier
franklinjavier / Uint8Array.js
Created November 11, 2013 21:10
CORS image in canvas
(function() {
try {
var a = new Uint8Array(1);
return; //no need
} catch(e) { }
function subarray(start, end) {
return this.slice(start, end);
}