Skip to content

Instantly share code, notes, and snippets.

View brunowego's full-sized avatar
🎯
Focusing

Bruno Wego brunowego

🎯
Focusing
View GitHub Profile

Vagrant

Plugins

  • vagrant plugin install vagrant-bindfs
  • vagrant plugin install vagrant-vbguest

Config BINDFS

Before installing bindfs, we need to install FUSE with development package using yum:

  • yum install fuse fuse-devel -y
@tecfu
tecfu / gist:f84a65ffa850a0bc2e88
Last active August 29, 2015 14:06
Solving the file name with multiple dots problem in Grunt:

Solving the file name with multiple dots problem in Grunt:

Use the extDot property instead of the ext property.

In Grunt, this is how your can match filenames with multiple dots and write to filenames that contain the original dot sequence, except for file extension.

/path/to/module.somename.scss -> /path/to/module.somename.css
@patrickse
patrickse / gist:ef02c1689bcc64fbe0da
Last active August 29, 2015 14:14
Setup a php project with grunt
@rubenrangel
rubenrangel / ImageInput.js
Created July 8, 2016 01:54
Image upload React component.
import React, { Component, PropTypes } from 'react';
export default class ImageInput extends Component {
constructor(props) {
super(props);
this.state = {
src: props.src ? props.src : null,
}
this.handleOnChange = this.handleOnChange.bind(this);
@mattattui
mattattui / 0README.md
Last active October 16, 2016 12:07
Using obfuscated ids with DoctrineParamConverter

Using Tiny (ID obfuscator) with Symfony2's ParamConverters

  • Symfony's convenience methods for automatically fetching database entities from URL parameters are super-handy.
  • Obfuscated/hash IDs are a great idea, especially in APIs (where you aren't concerned with SEO, but might be concerned about sequential numeric ids or exposing database information).
  • Here's how to make them work together.

The stuff in this gist sets up a Twig filter (obfuscate) to create the obfuscated ids (for URLs), makes the obfuscator available as a service (id_obfuscator) so you can also generate obfuscated URLs in your controllers or whatever, and extends the DoctrineParamConverter to allow it to retrieve entities by their deobfuscated id.

Following Phil Sturgeon's excellent advice in Build APIs You Won't Hate, I've also added an option to allow multiple ids to be loaded at once, like /resources/id1,id2,id3,id4. It's really quite handy sometimes. Bewarned though; it won't

@chrismo
chrismo / README.md
Last active October 19, 2016 20:32
Bundler 1.3 --binstubs vs. Rails 4

On a clean Rails 4 install with Bundler 1.3.0, using --binstubs causes competition between Rails and Bundler for the contents of bin/rails (and bin/rake).

Just running bundle will rewrite the Rails version of bin/rails to a version that doesn't work.

The fix is to use the new bundle binstubs <gemname> command.

(see rails/rails#8974)

@pywebdesign
pywebdesign / config.js
Last active October 22, 2016 21:28
Simple JsonAPi adapter for Restangular
// it require either lodash or underscorejs
.config(function(RestangularProvider) {
// add a response interceptor
RestangularProvider.addResponseInterceptor(function(data, operation, what, url, response, deferred) {
extractedData = data.data;
extractedData.meta = data.meta;
extractedData.included = data.included;
function _apply(elem, fct){
@egermano
egermano / parsley-cpf.js
Created September 4, 2014 22:22
Parsley CPF validator
window.ParsleyConfig = {
validators: {
cpf: {
fn : function ( val, req) {
val = $.trim(val);
val = val.replace('.','');
val = val.replace('.','');
cpf = val.replace('-','');
while(cpf.length < 11) cpf = "0"+ cpf;
@jordpo
jordpo / ajax.js
Last active February 22, 2017 00:01
IcarusWorks - Single Sign On with Ember.js
// addon/services/ajax.js
// ensure custom ajax requests have the appropriate authorization headers when signed in
import Ember from 'ember';
import AjaxService from 'ember-ajax/services/ajax';
const {
computed,
inject,
get
} = Ember;
class Organisation < ApplicationRecord
NUMBER_OF_PERMITTED_USERS = 10
has_many :users, before_add: :validate_user_limit
private
def validate_user_limit(user)
raise Exception.new if users.size >= NUMBER_OF_PERMITTED_USERS
end
end