Skip to content

Instantly share code, notes, and snippets.

View daviferreira's full-sized avatar

Davi Ferreira daviferreira

View GitHub Profile
location @prerender {
set $prerender 0;
if ($http_user_agent ~* "googlebot|yahoo|bingbot|baiduspider|yandex|yeti|yodaobot|gigabot|ia_archiver|facebookexternalhit|twitterbot|developers\.google\.com") {
set $prerender 1;
}
if ($args ~ "_escaped_fragment_|prerender=1") {
set $prerender 1;
}
if ($http_user_agent ~ "Prerender") {
set $prerender 0;
@daviferreira
daviferreira / compiler.js
Last active April 18, 2017 21:42
Mocha compiler for es6 + react components with css require statements
'use strict';
var babel = require('babel-core');
var fs = require('fs');
// borrowed from https://github.com/babel/babel-jest/blob/master/index.js
require.extensions['.jsx'] = function (module, filename) {
var src = fs.readFileSync(filename, 'utf8');
// Allow the stage to be configured by an environment
// variable, but use Babel's default stage (2) if
@daviferreira
daviferreira / react-phantom-bind.js
Created October 14, 2014 19:40
react with phantomjs
if (!Function.prototype.bind) {
var Empty = function(){};
Function.prototype.bind = function bind(that) { // .length is 1
var target = this;
if (typeof target != "function") {
throw new TypeError("Function.prototype.bind called on incompatible " + target);
}
var args = Array.prototype.slice.call(arguments, 1); // for normal call
var binder = function () {
if (this instanceof bound) {
@daviferreira
daviferreira / SassMeister-input.scss
Created September 18, 2014 21:48
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.1)
// ----
$settings: ("offset": 'margin-left',
"push": 'left',
"pull": 'right',
"center": 'margin-left');
@daviferreira
daviferreira / .jshintrc
Created August 15, 2014 14:33
my jshintrc
{
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 4,
"latedef": true,
export CLICOLOR=1
export LSCOLORS=gxfxcxdxBxxxxxxxxxxxxx
# Colors from http://wiki.archlinux.org/index.php/Color_Bash_Prompt
NO_COLOR='\e[0m' #disable any colors
# regular colors
BLACK='\033[0;30m'
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
@daviferreira
daviferreira / gist:5576447
Created May 14, 2013 14:40
console crossbrowser
/**
* Protect window.console method calls, e.g. console is not defined on IE
* unless dev tools are open, and IE doesn't define console.debug
*/
(function () {
if (!window.console) {
window.console = {};
}
// union of Chrome, FF, IE, and Safari console methods
var functionCall = function () {},
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@daviferreira
daviferreira / smooth-scrolling.coffee
Created March 31, 2012 23:46
Smooth scrolling for anchor '#' links using jQuery and CoffeeScript
# based on http://www.paulund.co.uk/smooth-scroll-to-internal-links-with-jquery
$ ->
$('a[href^="#"]').on 'click.smoothscroll', (e) ->
e.preventDefault()
target = @hash
$target = $(target)
@daviferreira
daviferreira / html5-css3.md
Created February 13, 2012 16:34
HTML5/CSS3 workshop links