Skip to content

Instantly share code, notes, and snippets.

View falexandre's full-sized avatar
😎

Fábio Luis Alexandre falexandre

😎
View GitHub Profile
(function() {
var script,
scripts = document.getElementsByTagName('script')[0];
function load(url) {
script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);
@falexandre
falexandre / publica-fanpage-v4.php
Last active September 3, 2015 19:55 — forked from dpasqua/publica-fanpage-v4.php
Exemplo de script de publicação na fanpage, facebook, usando PHP SDK v4.0.x ! Instale o SDK v4 através do composer. Mais detalhes de como instalar o SDK via composer pode ser obtido em: http://www.douglaspasqua.com/2015/05/24/criando-aplicativos-facebook-sdk-v4-em-php/
<?php
session_start(); // Sessao do php deve estar ativa
// datetimezone
date_default_timezone_set('America/Sao_Paulo');
// autoloader gerado pelo composer
require_once "vendor/autoload.php";
// configurar APP_ID e SECRET
@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
@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 / 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 / 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 / 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 / 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 / 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