Skip to content

Instantly share code, notes, and snippets.

View alanbacelar's full-sized avatar
🏠
Working from home

Alan Bacelar alanbacelar

🏠
Working from home
View GitHub Profile
@beeman
beeman / remove-all-from-docker.sh
Created November 15, 2016 03:04
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
@riggaroo
riggaroo / MainActivity.java
Last active July 15, 2020 12:30
Online Presence with Firebase and Android based off article https://firebase.googleblog.com/2013/06/how-to-build-presence-system.html . Read the article as it explains the whole .onDisconnect().removeValue() nicely.
private void initialiseOnlinePresence() {
final DatabaseReference onlineRef = databaseReference.child(".info/connected");
final DatabaseReference currentUserRef = databaseReference.child("/presence/" + userId);
onlineRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(final DataSnapshot dataSnapshot) {
Log.d(TAG, "DataSnapshot:" + dataSnapshot);
if (dataSnapshot.getValue(Boolean.class)){
currentUserRef.onDisconnect().removeValue();
currentUserRef.setValue(true);
Biohacking = {};
Biohacking.KIND = {
11: "BATH",
9: "DEFECATE",
3: "DRINK",
2: "EAT",
5: "HUNGRY",
10: "SEX",
6: "SLEEP",
@paulirish
paulirish / what-forces-layout.md
Last active June 20, 2025 23:33
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
var logs = [{"id":2,"user_id":1,"kind":2,"description":"300g de Linguiça","logged_at":"2015-01-28T22:00:00.000-03:00","created_at":"2015-01-29T21:39:58.180-03:00","updated_at":"2015-01-29T21:39:58.180-03:00","deleted_at":null},{"id":1,"user_id":1,"kind":1,"description":"84.9","logged_at":"2015-01-29T06:00:41.000-03:00","created_at":"2015-01-29T21:36:41.986-03:00","updated_at":"2015-01-29T21:37:28.428-03:00","deleted_at":null},{"id":5,"user_id":1,"kind":1,"description":"84.8","logged_at":"2015-01-29T19:00:00.000-03:00","created_at":"2015-01-30T08:43:39.528-03:00","updated_at":"2015-01-30T08:43:39.528-03:00","deleted_at":null},{"id":3,"user_id":1,"kind":2,"description":"1kg de Pizza 4 queijos/Peperoni","logged_at":"2015-01-29T22:00:00.000-03:00","created_at":"2015-01-30T08:41:45.404-03:00","updated_at":"2015-01-30T08:41:45.404-03:00","deleted_at":null},{"id":4,"user_id":1,"kind":3,"description":"300ml de água","logged_at":"2015-01-29T22:40:00.000-03:00","created_at":"2015-01-30T08:43:03.179-03:00","updated_at":
@kelvinn
kelvinn / cmd.sh
Created July 24, 2014 02:55
Example of using Apache Bench (ab) to POST JSON to an API
# post_loc.txt contains the json you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/
@burgalon
burgalon / AccountAuthenticator.java
Last active July 15, 2023 08:29
Implementing OAuth2 with AccountManager, Retrofit and Dagger
public class AccountAuthenticator extends AbstractAccountAuthenticator {
private final Context context;
@Inject @ClientId String clientId;
@Inject @ClientSecret String clientSecret;
@Inject ApiService apiService;
public AccountAuthenticator(Context context) {
super(context);
@jonathantneal
jonathantneal / README.md
Last active March 24, 2025 17:47
Local SSL websites on macOS Sierra

Local SSL websites on macOS Sierra

These instructions will guide you through the process of setting up local, trusted websites on your own computer.

These instructions are intended to be used on macOS Sierra, but they have been known to work in El Capitan, Yosemite, Mavericks, and Mountain Lion.

NOTE: You may substitute the edit command for nano, vim, or whatever the editor of your choice is. Personally, I forward the edit command to Sublime Text:

alias edit="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
@zenorocha
zenorocha / .hyper.js
Last active April 11, 2025 07:01 — forked from millermedeiros/osx_setup.md
Setup macOS Sierra (10.12)
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 14,
// font family with optional fallbacks