Skip to content

Instantly share code, notes, and snippets.

View armanso's full-sized avatar

Arman Soudi armanso

View GitHub Profile
@armanso
armanso / AES.java
Last active August 7, 2023 02:34
AES encryption/decryption in crypto-js way, use KDF for generating IV and Key, use CBC with PKCS7Padding for Cipher
import com.sun.jersey.core.util.Base64;
import java.io.UnsupportedEncodingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Random;
import javax.crypto.BadPaddingException;
@armanso
armanso / PPKeys.java
Last active July 11, 2024 07:20
RSA Helper for java, Works with PEM format
/**
* Simple object that keep private and public key
*/
public class PPKeys {
private String privateKey;
private String publicKey;
public String getPublicKey() {
return publicKey;
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- solids that simulate shadow !-->
<item>
<shape>
<corners android:radius="@dimen/radius_corner"></corners>
<solid android:color="#10CCCCCC" />
<padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" />
</shape>
</item>
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import arman.so.shadowexample.R;
import arman.so.shadowexample.utils.ViewUtils;
/**
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
import android.support.annotation.ColorRes;
import android.support.annotation.DimenRes;
import android.support.v4.content.ContextCompat;
import android.view.Gravity;
@armanso
armanso / Extention.kt
Last active April 17, 2021 14:14
Part 2 of blog post - Control view's shadow
fun View.setShadow(
@ColorRes shadowColor: Int,
@DimenRes cornerRadius: Int,
@DimenRes elevation: Int,
shadowGravity: Int = Gravity.BOTTOM,
@ColorRes backgroundColorResource: Int = 0
) {
val resource = context.resources
val firstLayer = 0
val ratioTopBottom = 3
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
testView.setShadow(R.color.shadow, R.dimen.radius, R.dimen.evl)
}
}
class TestFrameLayout @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : FrameLayout(context, attrs, defStyleAttr) {
private val paint: Paint = Paint()
init {
clipChildren = false
clipToPadding = false
paint.color = Color.WHITE
@armanso
armanso / index.ts
Last active April 19, 2020 17:02
Firebase init index
exports.appReviews = functions.runWith({ timeoutSeconds: 5 * 60 })
.pubsub
.schedule('every 15 minutes').onRun(async context => {
// magic gonna happen here!
})
@armanso
armanso / index.ts
Last active April 19, 2020 17:18
config files
const storePublishedReviewsList = async (reviews: PublishedReviews) => {
// callback to store data file
}
const retrivePublishedReviewsList = async (): Promise<PublishedReviews> => {
// callback to retrive data from data source
}
const onNewMessageAvailable = async (messages: string[]) => {
// callback of having new messages