Skip to content

Instantly share code, notes, and snippets.

@raphaelluchini
raphaelluchini / cors-nginx.conf
Created January 22, 2019 18:33 — forked from alexjs/cors-nginx.conf
Slightly tighter CORS config for nginx
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#
@raphaelluchini
raphaelluchini / controller.js
Created December 23, 2014 19:40
[Angularjs Async] How to load controllers in templates and directives asynchronous with webpack/commonJs
function NavBar($http) {
this.date = new Date();
this.getHttp = function(){
console.log($http);
}
};
module.exports = NavBar;
@raphaelluchini
raphaelluchini / gist:066806cafd080dcefd50
Created August 15, 2014 19:54
Set JQqueryUI DatePicker to browser languarge, requires jquery-ui-i18n.js
var getJqueryUserLanguage = function() {
if (navigator.language.toLowerCase() == 'en-us') {
return '';
}
else {
var l = navigator.language.toLowerCase().split('-');
if (l.length == 1) {
if ($.datepicker.regional[l[0]] != undefined) return l[0];
else return '';
}
@raphaelluchini
raphaelluchini / jquery.places-search.js
Last active October 7, 2016 14:20
Helper to typeahead.js with google places
/**
* jquery.places-search.js - V0.0.1
* Created by Richard Willis; 2013 Licensed MIT
*/ (function() {
function PlacesSearch(element, options) {
this.element = $(element);
this.options = $.extend({}, options);
this.onSelectAddress = this.options.onSelectAddress || $.noop;
@raphaelluchini
raphaelluchini / gist:7607663
Last active December 29, 2015 03:29
Render text/template as html markup on sublime text
//From: http://stackoverflow.com/questions/9655039/sublime-text-2-recognize-underscore-templates-as-html
//1- Go to "Browse Packages" in the menu (where the menu item is depends on your platform).
//2- Open up HTML/HTML.tmLanguage
//3- Change this line (line 286 in my HTML.tmLanguage):
//Before
<string>(?:^\s+)?(&lt;)((?i:script))\b(?![^&gt;]*/&gt;)</string>
@raphaelluchini
raphaelluchini / gist:7536497
Created November 18, 2013 22:26
Snippet to configure apache VirtualHost environment for Backbone Boilerplate
<VirtualHost *:80>
ServerName NAME
DocumentRoot DIRECTORY
<Directory DIRECTORY>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
RewriteEngine On
require.config({
baseUrl: '/backbone-tests/',
paths: {
'jquery' : '/app/libs/jquery',
'underscore' : '/app/libs/underscore',
'backbone' : '/app/libs/backbone',
'mocha' : 'libs/mocha',
'chai' : 'libs/chai',
'chai-jquery' : 'libs/chai-jquery',
'models' : '/app/models'
@raphaelluchini
raphaelluchini / gist:4094100
Created November 17, 2012 07:47 — forked from fael/gist:1212422
Get and format tweets
getTweets = function(alvo, usuario, qtdMensagens){
var o = {}
o.qtdMensagens = qtdMensagens;
o.caixaTwitter = $("#" + alvo);
o.caixaTwitter.append("<li><a href='#'>carregando tweets...</a></li>");
$.jTwitter(usuario, o.qtdMensagens, function(data){