Skip to content

Instantly share code, notes, and snippets.

View eefret's full-sized avatar

Christopher Herrera eefret

View GitHub Profile
@eefret
eefret / test_feature_flag.py
Created June 20, 2023 22:12
LaunchDarkly Testing script
from ldclient.config import Config
from ldclient import LDClient
import time
# Set the SDK key you get from your LaunchDarkly environment
sdk_key = "API_KEY"
# Create a configuration object
config = Config(sdk_key=sdk_key)
@eefret
eefret / turn_app_setting_json_to_dotenv.py
Created April 7, 2022 20:03
Converts app settings from azure app service to dotenv backwards and forwards
from ast import arg
import sys
import json
# should pass the path of the appsettings.json file as the first argument
# should pass the path of the .env file as the second argument
# python3 turn_app_setting_json_to_dotenv.py appsettings.json config.env
with open(sys.argv[1]) as file_obj:
@eefret
eefret / wizard_of_legend_info_scrapper.js
Last active May 16, 2020 16:39
Wizard of Legend arcana and relic info from gamepedia
// This extracts the arcana and relic information from the gamepedia wiki
// just go to the console and paste this script and you will have the full information in a json format
// inside arcanaJson and relicJson variables
let tables = [];
let arcanaTables = [];
let arcanaJson = [];
let arcanaCsv;
let relicTables = [];
let relicJson = [];
@eefret
eefret / version-code-as-commit-count.gradle
Created June 13, 2017 06:37
This automatically sets your version number based on your git commit count.
defaultConfig {
# Add 10000 to move past old SVN revisions.
versionCode gitCommitCount() + 10000 ?: 0
}
def gitCommitCount() {
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', '--count', 'HEAD'
@eefret
eefret / open-after-build.gradle
Last active June 14, 2017 04:46
Opens & Highlights the apk in explorer/finder after a release build.
applicationVariants.all { variant ->
variant.assemble.doLast {
//If this is a 'release' build, reveal the compiled apk in finder/explorer
if (variant.buildType.name.contains('release')) {
def path = null
variant.outputs.each { output ->
path = "${rootDir}/${project.name}/build/outputs/apk/release/${output.outputFileName}"
}
@eefret
eefret / BaseActivity.java
Last active July 7, 2016 21:23
KeyboardLayoutListener Example for when you need to hide views or do something when the keyboard is up without relying in the onFocus, also to deal for when you have an item outside your scroll view and the keyboard pulls all the things up
//Import Utils from somewhere
public class BaseActivity extends Activity {
private ViewTreeObserver.OnGlobalLayoutListener keyboardLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int navigationBarHeight = Utils.getNavigationBarHeight(BaseActivity.this);
int statusBarHeight = Utils.getStatusBarHeight(BaseActivity.this);
// display window size for the app layout
@eefret
eefret / AndroidMarshmallowPermissions.java
Last active March 17, 2016 20:39
This are some methods I usually use to handle android 6 permissions
/**
* Check whether the passed permissions are granted and if not it requests them.
* @param activity The activity that requires the permissions
* @param requestCode The request code
* @param permissions The permissions you want to grant
*/
public static void requestPermissionsNotAllowed(@NonNull Activity activity,
@NonNull int requestCode,
@NonNull String... permissions){
ArrayList<String> missing = new ArrayList<>(permissions.length);
@eefret
eefret / Normalize android assets
Last active March 7, 2016 21:41
Sometimes in Android development you find designers that make your assets names with "-" this makes the android compiler to fail as assets cannot have "-", I create this script to solve this problem recursively renaming the files and replacing "-" with "_" plus making them lowercase.
#!/bin/bash
# Normalize assets
# Sometimes in Android development you find designers that make your assets names with "-" this makes
# the android compiler to fail as assets cannot have "-", I create this script to solve this problem
# recursively renaming the files and replacing "-" with "_" plus making them lowercase.
#
# Instructions:
# 1- Move this script to your Android {PROJECT_BASE_FOLDER}/app/src/main/res
# 2- run it with sudo ex: "sudo ./rename_script.sh"
@eefret
eefret / NetworkStateReceiver.java
Created April 16, 2015 19:27
A Simple but powerfull Network State Receiver for android implementing listeners
public class NetworkStateReceiver extends BroadcastReceiver {
protected List<NetworkStateReceiverListener> listeners;
protected Boolean connected;
public NetworkStateReceiver() {
listeners = new ArrayList<NetworkStateReceiverListener>();
connected = null;
}
@eefret
eefret / Logger
Created September 29, 2014 22:30
Logger class
import android.util.Log;
/**
* @author eefret
* Created by Christopher T. Herrera (eefret) on 4/22/2014 [12:41 AM]
* Wrapper class for android Logging utility will select a tag automatically from class, method and line number executed.
*/
public class Logger {
//TODO Create a detail Enum to define the log detail level.
//TODO Create a method that halt every log possible based on the development mode Ex: (PRODUCTION, DEVELOPMENT, DEBUG) that can manage what can be and can't be logged