Skip to content

Instantly share code, notes, and snippets.

View faruktoptas's full-sized avatar
🐝
I may be slow to respond.

Faruk Toptaş faruktoptas

🐝
I may be slow to respond.
View GitHub Profile
@faruktoptas
faruktoptas / tfs-find-user-tasks.js
Last active April 5, 2019 15:18
Merge same tasks for different team members into one task. Generate a clean/printable board
var USER = "USER"
var json = document.getElementById("taskboard").innerHTML.split("</script>");
var data = JSON.parse(json[0].substring(55, json[0].length))
function contains(list, item){
var has = false
list.forEach(function(l){
if (l == item){
has = true
}
@faruktoptas
faruktoptas / gen.py
Created September 22, 2018 20:06
Generate Android/iOS localization files from a JSON file
import sys,json,os, collections
infile = 'res.json'
def __main__():
if (len(sys.argv) < 3):
print "Usage: \npython gen.py [android | ios] outfile"
sys.exit()
type = sys.argv[1]
if (type != "android" and type != "ios" ):
/**
* Each presenter must implement this interface
*
* @param <V> View for the presenter
</V> */
interface BaseMvpPresenter<V : BaseView> {
/**
* @return true if view is attached to presenter
*/
@faruktoptas
faruktoptas / KeyboardSensitiveRelativeLayout.java
Last active November 3, 2023 17:50
A layout that detects Soft Keyboard is visible or not.
public class KeyboardSensitiveRelativeLayout extends RelativeLayout {
private OnKeyboardShowHideListener listener;
public KeyboardSensitiveRelativeLayout(Context context) {
super(context);
}
public KeyboardSensitiveRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);
@faruktoptas
faruktoptas / MyRecyclerViewAdapter.kt
Last active September 26, 2018 06:58
Simple RecyclerView Adapter
class MyRecyclerViewAdapter(private val list: List<MyModel>) : RecyclerView.Adapter<MyRecyclerViewAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.row_recycler, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val myModel = list[position]
holder.title.text = myModel.title
@faruktoptas
faruktoptas / FaRequestManager.java
Created March 14, 2016 10:00
A simple class to make GET and POST requests.
import android.net.SSLCertificateSocketFactory;
import android.os.AsyncTask;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
@faruktoptas
faruktoptas / .gitignore
Created February 3, 2016 08:33
Android .gitignore
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
@faruktoptas
faruktoptas / MainActivity.java
Last active September 25, 2018 10:29
Public Key Pinning Run
private void sendRequest() {
requestQueue = Volley.newRequestQueue(this, new HurlStack(null, pinnedSSLSocketFactory()));
StringRequest request = new StringRequest(Request.Method.GET, SECURE_URL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Toast.makeText(MainActivity.this, "Response: " + response, Toast.LENGTH_SHORT).show();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
@faruktoptas
faruktoptas / PubKeyManager.java
Last active April 27, 2021 07:14
Public Key Pinning
public final class PubKeyManager implements X509TrustManager {
private String publicKey;
public PubKeyManager(String publicKey) {
this.publicKey = publicKey;
}
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
if (chain == null) {
@faruktoptas
faruktoptas / build.gradle
Created October 22, 2015 08:25
Rename output apk file (append versionName)
android {
// ....
applicationVariants.all { variant ->
renameApk(variant, defaultConfig)
}
}
// ---------------------------
def renameApk(variant, defaultConfig) {