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 / vs_shortcuts.txt
Created December 18, 2019 11:27
VS Code Shortcuts
1.Code formatting
On Windows: Shift + Alt + F
On Mac: Shift + Option + F
On Ubuntu: Ctrl + Shift + I
2.Copy line up/down
On Windows: Shift + Alt + Up/Down
On Mac: Shift + Option + Up/Down
On Ubuntu: Ctrl + Shift + Alt + Up/Down
@faruktoptas
faruktoptas / bash.sh
Last active September 10, 2019 13:29
Git commands
#Switch to dev branch, pull it then come back to my current branch
current="$(git branch | grep \* | cut -d ' ' -f2)";git checkout dev;git pull origin dev;git checkout $current
@faruktoptas
faruktoptas / data_binding.kt
Last active August 2, 2019 15:01
DataBinding samples
// Conditional string
android:text="@{viewModel.startButtonText ? @string/title_start_travel : @string/title_start}"
// Conditional visibility
<import type="android.view.View" />
android:visibility="@{viewModel.visibility == 1 ? View.VISIBLE : View.GONE}"
// Non-string text
android:text="@{String.valueOf(data.minutes)}"
@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 / renew.sh
Created January 30, 2019 15:13
Script to renew letsencrypt certificate
echo "1/7 Stopping nginx"
sudo service nginx stop
echo "2/7 Removing mongod.lock"
rm /var/lib/mongodb/mongod.lock
echo "3/7 Stopping mongod"
sudo service mongod stop
echo "4/7 Renewing letsencrypt"
@faruktoptas
faruktoptas / jcompile.sh
Created August 22, 2013 19:25
Sublime Text 2 Java compile build settings. Place jcompile.sh in /usr/bin directory then make it executable.
#!/bin/bash
file=$1
basename="${file%%.*}"
javac $file
java $basename
@faruktoptas
faruktoptas / objkeys.js
Last active January 4, 2019 10:19
JS Object Keys
function objkeys(obj){
keys = Object.keys(obj);
var ret = "";
for (var o in keys){
ret = ret +keys[o] + "=>" + obj[keys[o]] + "\n";
}
return ret;
}
@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 / 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) {
/**
* 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
*/