Skip to content

Instantly share code, notes, and snippets.

View filipesperandio's full-sized avatar

Filipe Esperandio (Pippo) filipesperandio

  • CodeClimate
  • porto alegre, brazil
  • 20:22 (UTC -03:00)
View GitHub Profile
# Input: 'foo "foo bar" bar foobar'
# Output: ["foo", "foo bar", "bar", "foobar"]
# Input 'foo "foo bar baz" bar "foobar" "foo bar bar"'
# Output: ["foo", "foo bar baz", "bar", "foobar", "foo bar bar"]
def parse(txt)
end
ActiveRecord::Migrator.migrate "db/migrate"
@filipesperandio
filipesperandio / ellipsis.css
Last active September 12, 2019 19:17
CSS hacks
.ellipsis {
text-overflow: ellipsis;
/* Required for text-overflow to do anything */
overflow: hidden;
/* Impacts on the result */
white-space: nowrap;
}
function joinEndWith(arr, separator, last) {
const reg = new RegExp(`(.+)${separator}(.+)`)
return arr.join(separator).replace(reg, `$1${last}$2`)
}
@filipesperandio
filipesperandio / docker-compose.yml
Created June 28, 2019 09:49
Elastic Search Mem Limit
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.1.1
environment:
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms750m -Xmx750m"
mem_limit: 1024m
volumes:
- elasticsearch:/usr/share/elasticsearch/data
> function validate(isValid) { return isValid || !isValid }
undefined
> validate(true)
true
> validate(false)
true
> validate(undefined)
true
> validate(null)
true
@filipesperandio
filipesperandio / flatten.js
Last active September 17, 2016 18:55
Flatten array
function arrayEquals(actual, expected) {
return actual.every(function(element, i) {
if (Array.isArray(element)) {
return arrayEquals(element, expected[i]);
}
return element === expected[i];
})
}
function flatten (arr) {
@filipesperandio
filipesperandio / RxAndroid_Test.java
Last active October 11, 2016 14:50
Android Gists
static {
RxAndroidPlugins rxAndroidPlugins = RxAndroidPlugins.getInstance();
rxAndroidPlugins.reset();
rxAndroidPlugins.registerSchedulersHook(new RxAndroidSchedulersHook() {
@Override
public Scheduler getMainThreadScheduler() {
return Schedulers.immediate();
}
});
}
private void shceduleSomething() {
final Handler handler = new Handler();
Timer timer = new Timer();
TimerTask doAsynchronousTask = new TimerTask() {
@Override
public void run() {
handler.post(new Runnable() {
public void run() {
doSomething();
}
@filipesperandio
filipesperandio / index.html
Last active September 17, 2016 20:37 — forked from anonymous/index.html
Flex Box Spike | http://jsbin.com/beluce
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
ol, li {
margin: 0;
padding: 0;
}