Skip to content

Instantly share code, notes, and snippets.

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

Josias Sena JosiasSena

🏠
Working from home
View GitHub Profile
class ApolloSubscriptionClientFactory {
fun createSubscriptionApolloClient(sharedOkHttpClientBuilder: OkHttpClient.Builder): ApolloClient {
val okHttpClient = sharedOkHttpClientBuilder
.pingInterval(KEEP_ALIVE_INTERVAL, TimeUnit.SECONDS)
.build()
val subscriptionTransportFactory = WebSocketSubscriptionTransport.Factory("wss://your_subscription_host/graphql", okHttpClient)
return ApolloClient.builder()
@JosiasSena
JosiasSena / all_to_lowercase.sh
Created March 29, 2019 14:16
Set all files in current directory to lowercase
for file in *; do mv "$file” "`echo $file | tr "[:upper:]" "[:lower:]"`"; done
@JosiasSena
JosiasSena / vmOptions
Created July 15, 2016 23:12
Preffered android studio VM options
-Xms512m
-Xmx3g
-XX:MaxPermSize=2g
-XX:ReservedCodeCacheSize=1g
-XX:+UseCompressedOops
public class PhoneBookManager {
private final ContentResolver contentResolver;
public PhoneBookManager(final Context context) {
contentResolver = context.getContentResolver();
}
private boolean isContactWithNumberExists(@NonNull final String number) {
@JosiasSena
JosiasSena / Utils.java
Created December 20, 2016 01:51
Helpful utility class
package josiassena.humbug;
import android.Manifest;
import android.app.Activity;
import android.app.NotificationManager;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@JosiasSena
JosiasSena / RotateImage.kt
Last active July 12, 2018 12:05
Rotate an image/bitmap
import android.graphics.Bitmap
import android.graphics.Matrix
import android.support.media.ExifInterface
import java.io.File
class ImageUtils {
companion object {
/**
@JosiasSena
JosiasSena / MainActivity.kt
Created May 20, 2018 02:17
Step counter example
package com.josiassena.simplepedometer
import android.content.Context
import android.content.pm.PackageManager
import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
// ==UserScript==
// @name Hide suspended apps
// @namespace josiassena.com
// @version 1.0
// @description Hide suspended applications
// @author Josias Sena
// @match https://play.google.com/apps/publish/?dev_acc=*
// @require http://code.jquery.com/jquery-latest.js
// @grant none
// ==/UserScript==
@JosiasSena
JosiasSena / ResetRepository.md
Last active December 30, 2017 23:12
Reset repository. Clears all commit history.

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A
@JosiasSena
JosiasSena / wakeUpPhone
Created July 15, 2016 23:27
Wakes up device/turns on screen. For example if a notification is received this will make sure that the devices screen lights up
public static void wakeUpPhone(Context context, String tag) {
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wakeLock = powerManager.newWakeLock((
PowerManager.SCREEN_BRIGHT_WAKE_LOCK |
PowerManager.FULL_WAKE_LOCK |
PowerManager.ACQUIRE_CAUSES_WAKEUP), tag);
wakeLock.acquire();
}