Skip to content

Instantly share code, notes, and snippets.

@carolynvs
carolynvs / .gitconfig
Last active October 19, 2022 14:44
git wip - Show what branches you have been working on lately
[alias]
wip = for-each-ref --sort='authordate:iso8601' --format=' %(color:green)%(authordate:relative)%09%(color:white)%(refname:short)' refs/heads
@beigirad
beigirad / SampleValidator.kt
Created October 29, 2019 17:58
validation method
class SampleValidator(
val balance: Long?,
val amount: Long?,
val acceptedTerms: Boolean?
) : Validator<SampleValidator> {
override fun validate(): Validation<SampleValidator> {
return when {
balance ?: 0 <= 0 -> Validation.Invalid("بالانس شما کافی نیست")
amount ?: 0 <= 0 -> Validation.Invalid("مبلغ وارد شده صحیح نیست")
amount ?: 0 > balance ?: 0 -> Validation.Invalid("مبلغ وارد شده بیشتر از بالانس شماست")
@runo280
runo280 / 00readme.md
Last active September 29, 2020 11:36
Download script for C@ster.i0 free courses

How to use

1- Install requirements

This command is for Ubuntu based distros

sudo apt install aria2 youtube-dl

2- Make [course_name].sh file excutable:

chmod +x [course_name].sh

@alex-shpak
alex-shpak / Interceptor.java
Last active March 29, 2023 21:06
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
private class HttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//Build new request
Request.Builder builder = request.newBuilder();
builder.header("Accept", "application/json"); //if necessary, say to consume JSON
@ZkHaider
ZkHaider / expand-collapse.java
Last active January 30, 2022 02:31
Simple Expand / Collapse RecyclerView Item
public static class ExampleViewHolder extends RecyclerView.ViewHolder
implements View.OnClickListener {
private int originalHeight = 0;
private boolean isViewExpanded = false;
private YourCustomView yourCustomView
public ExampleViewHolder(View v) {
super(v);
v.setOnClickListener(this);
@pranayairan
pranayairan / androidShipwithDb.java
Created August 27, 2012 15:26
Code to use existing database in your android app
public class DataBaseHelper extends SQLiteOpenHelper{
//The Android's default system path of your application database.
//replace com.binarybricks.shippingwithsqllite with you Application package nae
//This should be same as which you used package section in your manifest
private static String DB_PATH = "/data/data/com.binarybricks.shippingwithsqllite/databases/";
//replace this with name of your db file which you copied into asset folder
private static String DB_NAME = "dexterology";
@jafetsanchez
jafetsanchez / RijndaelCrypt.cs
Created July 13, 2011 11:31
Rijndael on C# and Java
#region Using
using System;
using System.Security.Cryptography;
using System.Text;
#endregion
namespace YourApp.Security.Cryptography
{