Skip to content

Instantly share code, notes, and snippets.

View bruno78's full-sized avatar

Bruno G. Tavares bruno78

View GitHub Profile
@bruno78
bruno78 / README
Created November 24, 2018 00:56 — forked from MarsVard/README
android drawable to imitate google cards.
put card.xml in your drawables directory, put colors.xml in your values directory or add the colors to your colors.xml file.
set the background of a view to card,
as you can see in card.xml the drawable handles the card margin, so you don't have to add a margin to your view
``` xml
<View
android:layout_width="fill_parent"
@bruno78
bruno78 / changeFabButton.java
Last active October 28, 2018 14:10
Solution for fab icon that disappears after click when using Coordinator layout
/***
* This method solves this problem:
* https://stackoverflow.com/questions/52133846/fab-icon-disappers-after-click
* https://stackoverflow.com/questions/49587945/setimageresourceint-doesnt-work-after-setbackgroundtintcolorlistcolorstateli/52158081#52158081
* @param resource
* Implement this method inside of the fab click function
*/
private void changeFab(int resource) {
mFabButton.hide();
mFabButton.setImageResource(resource);
@bruno78
bruno78 / scrim.xml
Created October 22, 2018 02:01
A scrim view to be added to the drawable folder, giving visibility to texts on white screen images
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="-90"
android:startColor="#00000000"
android:centerColor="#00000000"
android:endColor="#4d000000"
android:type="linear" />
</shape>
@bruno78
bruno78 / BitmapUtils.java
Created October 19, 2018 22:39
BitmapUtils reduces the size of image files to fit your screen saving memory.
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@bruno78
bruno78 / countingSyllables.java
Created October 1, 2017 18:46
How to separate and count syllables in a word.
// Regex function that return a list of items split by the pattern.
public List<String> getTokens(String pattern)
{
ArrayList<String> tokens = new ArrayList<String>();
Pattern tokSplitter = Pattern.compile(pattern);
Matcher m = tokSplitter.matcher(text);
while (m.find()) {
tokens.add(m.group());
}
@bruno78
bruno78 / ssbg-slideshow.js
Created December 27, 2016 03:17 — forked from Ema4rl/ ssbg-slideshow.js
Super Simple jQuery Background-image Slideshow (using CSS3 for the transition, gets the image paths via HTML5 `data` attribute, and with image preload trick).
/*!
* By Eharry.me (https://gist.github.com/Ema4rl/b8ef90be99205ddada5ef2cd6e632ebe)
*/
! function ($) {
"use strict";
var slide = $("[data-slides]"),
count = 0,
slides = slide.data("slides"),
len = slides.length,
n = function () {
@bruno78
bruno78 / autocomplete.js
Created November 23, 2016 03:44
An example of implementation of autocomplete using jQuery
$(document).ready(function() {
//array
var books = ["Pride and Prejudice", "Running with Scissors", "The DaVinci Code", "The Aeneid"];
// element tag from html and using array as source
$("#tags").autocomplete({source: books});
});
@bruno78
bruno78 / twitter-api.py
Created November 10, 2016 00:02
A basic twitter api to print user statuses
import sys
import operator
import requests
import json
import twitter
from config import *
# Interact with Twitter API
twitter_api = twitter.Api(consumer_key = twitter_consumer_key, consumer_secret = twitter_consumer_secret,
@bruno78
bruno78 / server.js
Created October 24, 2016 21:50
Creating a simple server using Node.js and Express
var express = require('express');
var morgan = require('morgan');
var hostname = 'localhost';
var port = 3000;
var app = express();
app.use(morgan('dev'));
@bruno78
bruno78 / read_time.html
Created October 10, 2016 20:51
READ TIME - counts the words of your post and calculates the reading time. Add this file to your _includes folder on your Jekyll website.
<span class="reading-time" title="Estimated read time">
{% assign words = content | number_of_words %}
{% if words == 180 %}
1 minute read
{% elsif words < 180 %}
less than 1 minute read
{% else %}
{{ words | plus:90 | divided_by:180 }} minutes read
{% endif %}
</span>