Skip to content

Instantly share code, notes, and snippets.

@TiagoWinehouse
TiagoWinehouse / app.js
Created May 25, 2015 13:50
$cordovaCamera
/* $cordovaCamera
* http://ngcordova.com/docs/plugins/camera/
*/
$scope.takepicture = function() {
var options = {
destinationType: Camera.DestinationType.FILE_URL,
quality: 90
};
$cordovaCamera.getPicture(options).then(function(imageData) {
@TiagoWinehouse
TiagoWinehouse / app.js
Created July 21, 2015 00:23
JavaScript Funcional
//Lista Apenas um array de objetos;
var users = [
{name: "John Doe", age: 42}
, {name: "Mary Doe", age: 37}
, {name: "Eddie Doe", age: 24}
];
//Ordenação Utilize a função Array#sort;
var ordered = users.sort(function(a, b){
return (a.name < b.name ? -1 : 1);
@TiagoWinehouse
TiagoWinehouse / nginx.conf
Last active August 29, 2015 14:25 — forked from calebwoods/nginx.conf
Sample Nginx config for deployment of Angular.js app
server { listen 80;
server_name example.com;
access_log /var/log/example.com/nginx.access.log;
error_log /var/log/example.com/nginx.error.log;
root /var/www/apps/example.com/public;
charset utf-8;
location / {
rewrite ^ https://$host$request_uri? permanent;
}
@TiagoWinehouse
TiagoWinehouse / Sinaleira.ino
Last active August 29, 2015 14:26
Sinaleira ARDUINO
#define LED_VERMELHO 13
#define LED_AMARELO 12
#define LED_VERDE 11
#define LED_VERMELHO_ 8
#define LED_AMARELO_ 9
#define LED_VERDE_ 10
void setup(){
pinMode(LED_VERMELHO, OUTPUT);
@TiagoWinehouse
TiagoWinehouse / exemplo.js
Created September 12, 2015 13:05
Performance Closures
//exemplo pouco prático porém demonstrativo
function MyObject(name, message){
this.name = name.toString();
this.message = message.toString();
this.getName = function(){
return this.name;
};
this.getMessage = function(){
return this.message;
};
@TiagoWinehouse
TiagoWinehouse / call.js
Created September 12, 2015 14:46
Exemplo: Usando call para encadear construtores para um objeto
function Produto(nome, preco){
this.nome = nome;
this.preco = preco;
if(preco < 0){
throw RangeError('Cannot create product ' + this.nome + ' with a negative price');
}
return this;
}
function Prato(nome, preco){
@TiagoWinehouse
TiagoWinehouse / call_.js
Created September 12, 2015 14:53
Usando o call para chamar funções anônimas
var animais = [
{ especie: 'Lion', nome: 'King' },
{ especie: 'Whale', nome: 'Fail' }
];
for (var i = 0; i < animais.length; i++) {
(function(i) {
this.print = function() {
console.log('#' + i + ' ' + this.especie
+ ': ' + this.nome);
@TiagoWinehouse
TiagoWinehouse / jsconfig.json
Created November 3, 2015 13:50
jsconfig.json
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs"
}
}
#!/bin/bash
npm install express
npm install mongodb --mongodb:native
npm install mongoose
npm install jade
@TiagoWinehouse
TiagoWinehouse / js
Created April 15, 2016 15:02
Online x Offline
app.run(function($rootScope) {
// console.log("online:" + navigator.onLine);
$rootScope.online = navigator.onLine ? 'online' : 'offline';
$rootScope.$apply();
if (window.addEventListener) {
window.addEventListener("online", function() {
$rootScope.online = "online";
$rootScope.$apply();