Skip to content

Instantly share code, notes, and snippets.

View brynner's full-sized avatar
😎
Hello World!

Brynner Ferreira brynner

😎
Hello World!
View GitHub Profile
<?php
require_once('base_facebook.php');
require_once('facebook.php');
// Credentials
$fb_app_id = '***************';
$fb_app_secret = '********************************';
$facebook = new Facebook(array('appId'=>$fb_app_id, 'secret'=>$fb_app_secret, 'cookie'=>true));
@brynner
brynner / LocalStorageExpires.js
Last active October 20, 2020 18:51
My solution to set a local cache with expiration, using HTML5 LocalStorage. This dramatically increases the performance of a mobile application.
/* Author: Brynner Ferreira (brynner.net) */
// Functions
function removeHtmlStorage(name) {
localStorage.removeItem(name);
localStorage.removeItem(name+'_time');
}
function setHtmlStorage(name, value, expires) {
if (expires==undefined || expires=='null') { var expires = 3600; } // default: 1h
var date = new Date();
var schedule = Math.round((date.setSeconds(date.getSeconds()+expires))/1000);
<?php
/**
* Create a web friendly URL slug from a string.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <sean@iamseanmurphy.com>
* @copyright Copyright 2012 Sean Murphy. All rights reserved.
@brynner
brynner / gulpfile.js
Created June 26, 2017 17:38 — forked from franksmule/gulpfile.js
gulp.js that does SASS, JS Concatenation Watching - Tutorial -> http://omcfarlane.co.uk/install-gulp-js-windows/
//*********** IMPORTS *****************
var gulp = require('gulp');
var sass = require('gulp-ruby-sass');
var gutil = require('gulp-util');
var rename = require("gulp-rename");
var map = require("map-stream");
var livereload = require("gulp-livereload");
var concat = require("gulp-concat");
var uglify = require('gulp-uglify');
var watch = require('gulp-watch');
@brynner
brynner / package.json
Last active June 26, 2017 17:50 — forked from franksmule/package.json
Package.json for the gulp.js file - Tutorial -> http://omcfarlane.co.uk/install-gulp-js-windows/
{
"name": "MeuProjeto",
"version": "1.0.0",
"dependencies": {
"gulp": "*",
"gulp-ruby-sass": "*",
"gulp-util": "*",
"gulp-rename": "*",
"map-stream": "*",
"gulp-livereload": "*",
@brynner
brynner / bootstrap-mq.scss
Last active June 29, 2017 18:44 — forked from olegpolyakov/bootstrap-mq.scss
Bootstrap Sass Media Query Variables
//== Media queries breakpoints
// Extra small screen / phone
$screen-xs: 480px;
$screen-xs-min: $screen-xs;
// Small screen / tablet
$screen-sm: 768px;
$screen-sm-min: $screen-sm;
@brynner
brynner / Dockerfile
Created September 19, 2017 02:56 — forked from MichaelCaraccio/Dockerfile
PHP7 + Apache + Laravel + Amazon web services (AWS) Elastic Beanstalk
FROM php:7.0.12-apache
ENV DEBIAN_FRONTEND=noninteractive
# Install the PHP extensions I need for my personnal project (gd, mbstring, opcache)
RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libpq-dev git mysql-client-5.5 wget \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
&& docker-php-ext-install gd mbstring opcache pdo zip
@brynner
brynner / dom.js
Last active August 16, 2018 15:43
Add data to HTML according to object's property name
// Add data to HTML according to object´s property name
function addContentFromDataToHtml(object, dataSet) {
recursiveObject({object: object, callback: addContentFromDataToHtmlCallback, dataSet: dataSet});
}
function recursiveObject(recursiveParams) {
if (recursiveParams.parentsItem) {
recursiveParams.parentsItem = recursiveParams.parentsItem+'.';
} else {
recursiveParams.parentsItem = '';
}
@brynner
brynner / Admin.cshtml
Created August 23, 2018 22:42
C# - Rendering different Partials and Scripts according to a statement using Razor.
I'm an admin.