Skip to content

Instantly share code, notes, and snippets.

View falexandre's full-sized avatar
😎

Fábio Luis Alexandre falexandre

😎
View GitHub Profile
@falexandre
falexandre / gist:0484f3544ca1259b675e8c46b40f8b3b
Created September 4, 2017 12:34 — forked from bkrauska/gist:9742260
DiffMerge git mergetool & difftool setup
Install http://download-us.sourcegear.com/DiffMerge/4.2.0/DiffMerge_4.2.0.697.stable_x64.msi
// this is an adaptation of http://adventuresincoding.com/2010/04/how-to-setup-git-to-use-diffmerge
Then run the following commands from the git bash
git config --global merge.tool diffmerge
git config --global mergetool.diffmerge.cmd "sgdm --merge --result=\$MERGED \$LOCAL \$BASE \$REMOTE"
@falexandre
falexandre / app.js
Created August 14, 2017 11:43 — forked from bingeboy/app.js
Upload and display image with NodeJS and Express.
/*
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, common = require('./routes/common')
, fs = require('fs')
, http = require('http')
, util = require('util')
@falexandre
falexandre / after_res_hooks.js
Created August 8, 2017 15:28 — forked from pasupulaphani/after_res_hooks.js
Mongoose connection best practices
var db = mongoose.connect('mongodb://localhost:27017/DB');
// In middleware
app.use(function (req, res, next) {
// action after response
var afterResponse = function() {
logger.info({req: req}, "End request");
// any other clean ups
@falexandre
falexandre / index.html
Created June 4, 2017 20:55 — forked from shalotelli/index.html
Creating Web Components in JavaScript (ES6) to use in your Angular, React and Ember projects
<!DOCTYPE html>
<html>
<head>
<title>Web Components</title>
<style>
body {
font-family: 'Helvetica Neue';
}
</style>
@falexandre
falexandre / package.json
Created January 24, 2017 09:13
web-pac exemple
{
"name": "gestaoponto-frontend",
"version": "1.0.0",
"description": "GPO - Gestão do Ponto",
"scripts": {
"build": "rimraf dist && webpack --bail --progress --profile",
"server": "webpack-dev-server --history-api-fallback --inline --progress --host 0.0.0.0 --port 3000",
"test": "karma start",
"test-watch": "karma start --auto-watch --no-single-run",
"start": "npm run server"
@falexandre
falexandre / nginx.conf
Created January 18, 2017 10:29 — forked from denys281/nginx.conf
phpmyadmin nginx virtual host (php-fpm)
server {
# Listen on port 81
listen 81;
# Server name being used (exact name, wildcards or regular expression)
# server_name phpmyadmin.my;
root /usr/share/phpmyadmin;
@falexandre
falexandre / basic-auth.swift
Created July 9, 2016 14:42 — forked from morengab/basic-auth.swift
HTTP POST Request with Basic Authentication using NSURLSession in Swift
// Other sources: http://swiftdeveloperblog.com/send-http-post-request-example-using-swift-and-php/
// Create request
let baseUrl = "http://www.ocrwebservice.com/restservices/processDocument",
params = "?language=english&gettext=true&outputformat=txt",
requestUrl = NSURL(string: "\(baseUrl)\(params)"),
request = NSMutableURLRequest(URL:requestUrl!)
request.HTTPMethod = "POST";
request.HTTPBodyStream = NSInputStream(fileAtPath: "[/YOUR/FILE/PATH/IMAGE.jpg]")
@falexandre
falexandre / basic-auth.swift
Created July 9, 2016 14:38 — forked from armstrongnate/basic-auth.swift
HTTP Basic Authentication using NSURLSession in swift
import Foundation
let config = NSURLSessionConfiguration.defaultSessionConfiguration()
let userPasswordString = "[email protected]:password"
let userPasswordData = userPasswordString.dataUsingEncoding(NSUTF8StringEncoding)
let base64EncodedCredential = userPasswordData!.base64EncodedStringWithOptions(nil)
let authString = "Basic \(base64EncodedCredential)"
config.HTTPAdditionalHeaders = ["Authorization" : authString]
let session = NSURLSession(configuration: config)
@falexandre
falexandre / gist:281d0333c8aa0df1bbd4
Created February 15, 2016 12:13 — forked from stuart11n/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote