Skip to content

Instantly share code, notes, and snippets.

View Tarek-Bohdima's full-sized avatar

Tarek Bohdima Tarek-Bohdima

View GitHub Profile
@dodyg
dodyg / gist:5823184
Last active March 29, 2024 03:59
Kotlin Programming Language Cheat Sheet Part 1

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.

@jpelgrim
jpelgrim / new_gist_file
Created September 9, 2013 05:01
Singleton with an init method taking an Android Application object
public class MySingleton {
static final Object mLock = new Object();
static MySingleton mInstance;
private Context mContext;
// Private constructor prevents instantiation from other classes
private MySingleton() { }
@macodev
macodev / .zshrc-mac
Last active October 19, 2021 20:42
.zshrc settings
# PATHS
export MAMP_PATH=/Applications/MAMP/bin/php/php5.6.2/bin
export GIT_PATH=/usr/local/git/bin
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
export RVM_PATH=$HOME/.rvm/bin
export PATH="$MAMP_PATH:$GIT_PATH:$RVM_PATH:$PATH"
# export MANPATH="/usr/local/man:$MANPATH"
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
@davfre
davfre / git_cheat-sheet.md
Last active May 12, 2024 04:37
git commandline cheat-sheet
@mareksuscak
mareksuscak / bump-version.sh
Created March 15, 2015 12:56
Bump version shell script.
#!/bin/bash
# Thanks goes to @pete-otaqui for the initial gist:
# https://gist.github.com/pete-otaqui/4188238
#
# Original version modified by Marek Suscak
#
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3" or even "1.2.3-beta+001.ab"

1. Store api keys in a xml file

Put xml file "api_keys.xml" in the directory "res/value/".

api_keys.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="THE_MOVIE_DB_API_TOKEN">XXXXX</string>
</resources>
public interface AvailabilityChecker {
Observable<ValidationResult<String>> isEmailAvailable(@NonNull String email);
Observable<ValidationResult<String>> isUsernameAvailable(@NonNull String email);
ValidationResult<String> isEmailAvailableSync(@NonNull String email);
ValidationResult<String> isUsernameAvailableSync(@NonNull String email);
}
@wojteklu
wojteklu / clean_code.md
Last active July 7, 2024 18:05
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@jemshit
jemshit / proguard-rules.pro
Last active June 13, 2024 07:25
Proguard Rules for Android libraries
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
-keepclassmembers class fqcn.of.javascript.interface.for.webview {
public *;
}
### RxJava, RxAndroid (https://gist.github.com/kosiara/487868792fbd3214f9c9)
-keep class rx.schedulers.Schedulers {
public static <methods>;
@sturdustgeorgiana
sturdustgeorgiana / gist:65b79b7ddcb253b6c6dc8405bd40b39b
Last active January 29, 2018 01:07
Primavara.javacode Android for Beginners
package com.sistahwork.costin; /**
* Add your package below. Package name can be found in the project's AndroidManifest.xml file.
* This is the package name our example uses:
*
* package com.example.android.justjava;
*/
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;