Skip to content

Instantly share code, notes, and snippets.

Working from home

Felipe Lima felipecsl

Working from home
Block or report user

Report or block felipecsl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
felipecsl / extensions.kt
Last active Jan 30, 2018
Helpful Kotlin extension functions
View extensions.kt
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper
import org.gradle.api.Task
import org.gradle.api.Project
import org.gradle.api.UnknownTaskException
import org.gradle.api.GradleException
import org.gradle.api.plugins.ExtraPropertiesExtension
fun <T> Project.ext(key: String): T {
View longest-substring.rb
def length_of_longest_substring(str)
if str.empty?
return 0
map = {}
curr_start = 0
max_length = 0
found_start = 0
found_end = 0
i = 0
felipecsl / unless.kt
Last active Dec 24, 2017
Kotlin unless like Ruby just for fun
View unless.kt
inline fun <T> unless(stmt: () -> Boolean, block: () -> T, noinline elseBlock: (() -> T)? = null) =
if (!stmt.invoke()) {
} else {
// Use like:
unless({ foo == bar }, {
felipecsl / incrementVersionCode
Created Dec 10, 2013
Increments the android versionCode automatically on each debug or release build
View incrementVersionCode
task('increaseVersionCode') << {
def manifestFile = file("src/main/AndroidManifest.xml")
def pattern = Pattern.compile("versionCode=\"(\\d+)\"")
def matcher = pattern.matcher((CharSequence)manifestFile.getText())
def versionCode = Integer.parseInt(
manifestFile.write(matcher.replaceAll("versionCode=\"" + ++versionCode + "\""))
assembleDebug.dependsOn 'increaseVersionCode'
felipecsl / app.js
Created Sep 9, 2016
Sample use of react-native-maps with a tabbed layout
View app.js
import React, { Component } from 'react';
import {
} from 'react-native';
import MapView from 'react-native-maps';
felipecsl / gist:c6fa823f20f2087d762a
Created Feb 13, 2015
Fire up Android Intent from ADB (command line)
View gist:c6fa823f20f2087d762a
adb shell am start -a android.intent.action.VIEW -d “scheme://host/path?query=value"
felipecsl / rxruby.rb
Created Feb 25, 2016
Super simplified and naive (but fun) version of RxRuby I wrote during an endless flight to Brazil
View rxruby.rb
class Observable
def initialize(&on_subscribe)
@on_subscribe = on_subscribe
def self.from(arr)
new do |o|
arr.each do |i|
felipecsl / after_commit_with_transactional_fixtures.rb
Created Nov 3, 2011 — forked from outoftime/after_commit_with_transactional_fixtures.rb
Patch ActiveRecord to fire after_commit callbacks at the appropriate time during tests with transactional fixtures.
View after_commit_with_transactional_fixtures.rb
module ActiveRecord
module ConnectionAdapters
module DatabaseStatements
# Run the normal transaction method; when it's done, check to see if there
# is exactly one open transaction. If so, that's the transactional
# fixtures transaction; from the model's standpoint, the completed
# transaction is the real deal. Send commit callbacks to models.
# If the transaction block raises a Rollback, we need to know, so we don't
View Mongoid connection snippet for MongoHQ + Heroku
Mongoid.configure do |config|
if ENV['RACK_ENV'] == 'development' # ambiente de desenvolvimento
name = "myapp_development"
host = "localhost"
config.master =
config.slaves = [, 27017, :slave_ok => true).db(name) ]
else # ambiente de produção
uri = URI.parse(ENV['MONGOHQ_URL'])
config.master = Mongo::Connection.from_uri(ENV['MONGOHQ_URL']).db(uri.path.gsub("/", ""))
View cristiano_ronaldo.json
"commonName":"Cristiano Ronaldo",
"firstName":"C. Ronaldo",
You can’t perform that action at this time.