Skip to content

Instantly share code, notes, and snippets.

View SauloSilva's full-sized avatar

Saulo Santiago SauloSilva

View GitHub Profile
@SauloSilva
SauloSilva / decorators.rb
Created June 20, 2014 03:32
Decorators rails 4
# Decorators
class ItemDecorator
def initialize(item)
@item = item
end
def status
if @item.sold?
@SauloSilva
SauloSilva / logcat-color.md
Last active April 2, 2018 12:39
Logcat-color intall

#Logcat color configuration

Like leaving the log of the friendliest adb

  • Download file and install:

      $ cd /tmp    
      $ wget https://github.com/downloads/marshall/logcat-color/logcat-color-0.5.tar.gz
    

$ tar -vzxf logcat-color-0.5.tar.gz

@SauloSilva
SauloSilva / hints_api_rails.rb
Last active August 29, 2015 14:02
Hints to api at rails
# config/initializer/inflections.rb => module customize API
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'API'
end
# hints for namespace and subdomains
# api.bar.com/foo/
BarRails::Application.routes.draw do
@SauloSilva
SauloSilva / maven.sh
Created May 6, 2014 14:05
Commands maven
# maven install
mvn install:install-file -Dfile=libs/android-support-v4.jar -DgroupId=com.google.android -DartifactId=support-v4 -Dversion=r8 -Dpackaging=jar
mvn install
# maven run
mvn android:deploy
mvn android:run
@SauloSilva
SauloSilva / git_pc
Last active October 18, 2015 14:21
git pc
#!/bin/bash
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
COMMIT_MESSAGE=$1
echo -e "$(tput setaf 2)** Executing Status command$(tput sgr0)"
git status
echo -e "\n$(tput setaf 2)\n** Executing add command$(tput sgr0)"
git add .
@SauloSilva
SauloSilva / mixings.sass
Created April 17, 2014 13:24
Mixings parameters
@mixin progress-value($pairs...) {
@each $pair in $pairs {
$value: nth($pairs, 1);
$color: nth($pairs, 2);
progress[value="#{$value}"] {
color: #{$color}; // For IE 10 progress bar
&::-webkit-progress-value { background-color: #{$color}; }
&::-moz-progress-bar { background-color: #{$color}; }
@SauloSilva
SauloSilva / connect-mongo.js
Created April 10, 2014 17:28
Connect node with mongo
var Db = require('mongodb').Db,
MongoClient = require('mongodb').MongoClient,
Server = require('mongodb').Server,
ReplSetServers = require('mongodb').ReplSetServers,
ObjectID = require('mongodb').ObjectID,
Binary = require('mongodb').Binary,
GridStore = require('mongodb').GridStore,
Code = require('mongodb').Code,
BSON = require('mongodb').pure().BSON,
assert = require('assert');
@SauloSilva
SauloSilva / android_event.java
Created March 30, 2014 05:09
fazendo o envento na mão.
// elements views
Button buttonSend = (Button) rootView.findViewById(R.id.button_send);
buttonSend.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
System.out.println("others buttons send");
}
});
@SauloSilva
SauloSilva / each_slice.js
Last active May 8, 2019 16:09
Each slice javascript
// without callback
Array.prototype.eachSlice = function (size){
this.arr = []
for (var i = 0, l = this.length; i < l; i += size){
this.arr.push(this.slice(i, i + size))
}
return this.arr
};
[1, 2, 3, 4, 5, 6].eachSlice(2)
@SauloSilva
SauloSilva / to_sentence.coffee
Created January 25, 2014 20:36
Clone to setence active support of rails.
Array.prototype.toSentence = ->
wordsConnector = ', '
lastWordConnector = ' e '
sentence = undefined
switch @length
when 0
sentence = ''
when 1
sentence = @[0]