Skip to content

Instantly share code, notes, and snippets.

@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 / 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

function Notification() {
// constructor
function Notification() {
}
this.notify = function (title, text, type, confirmButtonText, cancelButtonText, timer, showConfirmButton) {
@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 }
@melloc01
melloc01 / BindSocket.js
Created March 16, 2016 23:06
AngularJS Service
function BindSocketService($rootScope, io) {
function BindSocket(resource, items) {
var connection = io.socket.on(resource,function handle(evt) {
switch (evt.verb) {
case 'created':
items.push(evt.data);
$rootScope.$apply();
break;
case 'destroyed':
var index;
@melloc01
melloc01 / Install-php7.md
Created August 19, 2016 18:21 — forked from hollodotme/Install-php7.md
Installing php7-fpm with phpredis and xdebug extension on Ubuntu 14.04

Install php7.0-fpm

# remove php5 modules
apt-get autoremove --purge php5-*
# add php-7.0 source list by [Ondřej Surý](https://github.com/oerdnj)
add-apt-repository ppa:ondrej/php
# Update index
apt-get update
# Install php7.0-fpm with needed extensions
@melloc01
melloc01 / jest-async.js
Last active November 17, 2017 18:41
Testando método async numa flux store com jest
// no test
const subscriber = require('./subscriber') // automock
it('should test something', () => {
dispatch(dispatcher, BLIR_CONSTANT, null, { requestIndex: 2 })
console.log('esse aparece antes')
// no teste, esse subscriber é o mesmo (===) lá dentro do escopo do src
expect(subscriber.request.mock.calls).toHaveLength(1)
})
'use strict'
Object.defineProperty(exports, '__esModule', {
value: true
})
var _createClass = (function () {
function defineProperties (target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i]
@melloc01
melloc01 / cloudSettings
Created July 11, 2018 20:41
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-07-11T20:41:12.256Z","extensionVersion":"v2.9.2"}
@melloc01
melloc01 / cloudSettings
Created August 15, 2018 15:14
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-08-15T15:14:11.978Z","extensionVersion":"v3.0.0"}