Skip to content

Instantly share code, notes, and snippets.

Alan Hoffmeister alanhoff

Block or report user

Report or block alanhoff

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View bug.js
'use strict'
let express = require('express')
let app = express()
function test () {
return typeof null === 'undefined'
}
let reqs = 0
View mix.exs
defmodule PlugTest.Mixfile do
use Mix.Project
def project do
[app: :plug_test,
version: "0.0.1",
elixir: "~> 1.1",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps,
View gist:c14c94fc672994e18981
scopes: {
public: function() {
return {
attributes: Object.keys(attributes).filter(function(attr) {
return ['deleted', 'location'].indexOf(attr) === -1;
})
};
}
}
View query.js
{
where: {},
include: [{
model: models.Profile.scope('public'),
as: 'profile'
}]
}
@alanhoff
alanhoff / client.js
Last active Aug 8, 2019
Exemplo de SSE com Node.js
View client.js
var source = new EventSource('http://localhost:8080');
source.addEventListener('message', function(data){
console.log(data);
});
source.addEventListener('open', function(){
console.log('Conexão aberta!');
});
@alanhoff
alanhoff / express
Created Jul 24, 2015
Benchmark Hapi vs Express
View express
Server Hostname: 127.0.0.1
Server Port: 8080
Document Path: /
Document Length: 11 bytes
Concurrency Level: 100
Time taken for tests: 11.099 seconds
Complete requests: 50000
Failed requests: 0
View gist:ba78fff113d63c5c0efc
* Aplicações modernas
- Carros
- http://imguol.com/blogs/8/files/2014/06/googleselfdrive.gif
- Robótica
- http://gifsec.com/wp-content/uploads/GIF/2014/06/GIF-Robot-feeding-FAIL.gif
- Impressoras 3D
- https://a248.e.akamai.net/f/248/1/1/www.geek.com/wp-content/uploads/2014/03/5.gif
- Drones
- http://ak-hdl.buzzfed.com/static/2014-04/enhanced/webdr04/19/6/anigif_enhanced-1915-1397902864-1.gif
- IoT
View gist:a97717c0b734aa10e3c8
var insert = function(object, index, key, value) {
var rebuilded = {};
var keys = Object.keys(object);
keys.splice(index, 0, key);
keys.forEach(function(k) {
if (k === key)
rebuilded[key] = value;
else
rebuilded[k] = object[k];
@alanhoff
alanhoff / readme.md
Last active Feb 24, 2017
Cross compile Rust
View readme.md

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
Proxy que valida os dados
View http-shield-proxy.js
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
You can’t perform that action at this time.