This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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)}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
file=$1 | |
basename="${file%%.*}" | |
javac $file | |
java $basename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function objkeys(obj){ | |
keys = Object.keys(obj); | |
var ret = ""; | |
for (var o in keys){ | |
ret = ret +keys[o] + "=>" + obj[keys[o]] + "\n"; | |
} | |
return ret; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 | |
*/ |