Skip to content

Instantly share code, notes, and snippets.

@alanhoff
alanhoff / readme.md
Last active February 24, 2017 09:39
Cross compile Rust

Packages

  • Windows x86_64: sudo apt-get install gcc-mingw-w64
  • ARM sudo apt-get install arm-linux-gnueabihf-cpp-4.8
  • PowerPC sudo apt-get install gcc-powerpc-linux-gnu

Config

Create a file inside PROJECT/.cargo/config with the followig content

@alanhoff
alanhoff / http-shield-proxy.js
Created May 13, 2015 19:43
Proxy que valida os dados
var httpProxy = require('http-proxy');
var proxy = httpProxy.createProxyServer();
var http = require('http');
var Mock = require('mock-req');
var Busboy = require('busboy');
var config = {
url: '/teste', // A rota a ser protegida
method: 'POST', // O método a ser protegido
content: 'multipart/form-data', // O tipo de conteúdo
'use strict';
exports.seed = function(knex, Promise) {
var players = knex('players');
var users = knex('users');
return new Promise(function(resolve, reject) {
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Doação de 0,69031 BTC feita por Filipe Deschamps
-----BEGIN PGP SIGNATURE-----
Version: Keybase OpenPGP v2.0.8
Comment: https://keybase.io/crypto
wsFcBAABCgAGBQJU8l8yAAoJEKafEHSe9dofDXsQAJm3iJj5Qij2yfmaFErsw+ih
XPuJGNOGTTKw7qcYmin9KcaPv7C976/X6wb9Cjn2S48bQTjx+5IoF7BVbDyXsy6D
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Doação de R$ 10,00 feita por Alan Hoffmeister
-----BEGIN PGP SIGNATURE-----
Version: Keybase OpenPGP v2.0.8
Comment: https://keybase.io/crypto
wsFcBAABCgAGBQJU8MhuAAoJEKafEHSe9dof6poP/i+fPda8i6SCq3bWmdInHGdC
Ecz1BLqrvQztfjTddStmpqM5hrveuj41tkqMLx/FvOs71TR5fMdW9hNbHBProlTh
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');
var image = new Image();
image.src = 'data:image/jpg;base64,seu_buffer_transformado_em_base64';
image.onload = function() {
ctx.drawImage(image, 0, 0);
};
<script type="text/javascript">
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = bundle; // pegar esse bundle no cookie
script.async = true;
var body = document.getElementsByTagName('body')[0];
body.appendChild(script);
</script>
@alanhoff
alanhoff / arr.js
Created December 30, 2014 19:03
Array assíncrona
var arr = [1, 2, 3, 4];
(function it(i){
if(arr[i] === undefined)
return console.log('Acabou!');
console.log('Estou no elemento', arr[i]);
// Quando estiver pronto chama o it de novo
setTimeout(it.bind(null, ++i), 1000);
@alanhoff
alanhoff / index.js
Created December 16, 2014 20:12
requirebin sketch
window.shortid = require('shortid');
(function loop(){
fazerAlgoAssincrono(function(err){
if(err)
throw err;
process.nextTick(loop);
});
})()