Skip to content

Instantly share code, notes, and snippets.

@melloc01
melloc01 / BaseResource.js
Created January 22, 2016 19:45
BaseResource
'use strict';
function BaseResource(uri, $resource, AppSettings, defaultParams, methods) {
var methods = methods || {};
var url = AppSettings.apiUrl + uri + '/:id';
mergeObjects(methods, {
'update': { method:'PUT' },
'where' : { method:'GET', isArray: true }
function Notification() {
// constructor
function Notification() {
}
this.notify = function (title, text, type, confirmButtonText, cancelButtonText, timer, showConfirmButton) {
@melloc01
melloc01 / gist:2e87cd2b70fe422298f7
Created October 14, 2015 16:03 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@melloc01
melloc01 / minicurso.md
Last active May 19, 2016 19:40
Criando uma SPA com AngularJS + Laravel

Criando uma SPA com AngularJS + Laravel

Objetivo: Em tempo de curso criaremos uma simples Single Page Application de um aplicativo de notas em AngularJS onde consumiremos uma API que será construída em curso, utilizando uma instalação branca do Laravel 5.

O que é uma SPA?

Uma SPA é uma aplicação web que é uma "única página web" com o objetivo de prover uma experiência mais fluida ao usuário, como se fosse uma aplicação Desktop nativa. Numa SPA todo o código (HTML, JS e CSS) é usualmente carregado apenas no primeiro carregamento da página, outros recursos são carregados dinamicamente em resposta às ações do usuário, nesse processo a página nunca é recarregada ou transfere o controle para outra página.

A Aplicação: Notify

  • Estrutura
@melloc01
melloc01 / Fix Linux permissions
Last active May 4, 2016 18:04
Fix unix file & dir permissions
sudo find . -type d -exec chmod 775 {} \; && find . -type f -exec chmod 664 {} \;
echo ==== deploying application =====
echo ========= checking out =========
git --work-tree=/var/www/projeto/api/src --git-dir=/var/www/projeto/api/repository.git checkout -f
echo ========= installing dependencies =========
( cd /var/www/projeto/api/src && composer install && php artisan migrate )
echo =========== complete ===========
var xmlhttp = new XMLHttpRequest(); // esse carinha faz requisições
// aqui você prepara a função de callback (caso queira usar) | função que vai ser chamada depois da resposta do servidor
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) { // quando a requisição tiver sucesso
var dados = JSON.parse(xmlhttp.responseText); // caso a resposta do servidor seja em JSON
// faça o que quiser
}
@melloc01
melloc01 / gist:2117789c2a400b8d21f6
Created June 24, 2015 18:07
Ubuntu provisioning
sudo apt-get update && apt-get update
apt-get install apache2 php5 php5-mcrypt git
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install nodejs
sudo npm install -g grunt-cli bower gulp
sudo apt-get install php5-dev php-pear
@melloc01
melloc01 / gist:b3136736164ac45433e7
Created June 24, 2015 18:03
Max watched files by Unix
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
@melloc01
melloc01 / gist:1f2b42aff2e73d7f2f17
Last active August 29, 2015 14:23
Como fazer uma requisição à uma API com Javascript puro
function XhrRequestExample {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200){
//handle success