Skip to content

Instantly share code, notes, and snippets.

View aslamanver's full-sized avatar
🎯
Focusing

Aslam Anver aslamanver

🎯
Focusing
View GitHub Profile
@aslamanver
aslamanver / docker_wordpress.md
Created October 26, 2022 09:46 — forked from bradtraversy/docker_wordpress.md
Docker Compose FIle For Wordpress, MySQL & phpmyadmin

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes
@aslamanver
aslamanver / dialogs.dart
Last active August 18, 2022 18:04
Progress & Message Dialog Flutter
showProgressDialog(BuildContext context) {
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return WillPopScope(
onWillPop: () async => false,
child: AlertDialog(
elevation: 0,
@aslamanver
aslamanver / Extensions.kt
Last active June 17, 2022 17:37
Convert Java/Kotlin object to another object - 1
fun <T> Any.convert(classOfT: Class<T>): T = Gson().fromJson(Gson().toJson(this), classOfT)
package org.tillion.aslam.test;
class Operations {
public static void main(String[] args) {
int[] intArr = {5, 4, 3, 8, 9, 11, 3, 3, 2, 9, 8, 7, 1, 22, 15, 67, 4, 17, 54, 67};
for (int j = 0; j < intArr.length - 1; j++) {
@aslamanver
aslamanver / EmailRegex.MD
Last active September 28, 2021 07:17
Email Validation Pattern - Regex, JavaScript, Java, Kotlin and Dart

JavaScript, Dart Pattern

^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$


Java, Kotlin Pattern

@aslamanver
aslamanver / cdn.lk
Last active September 20, 2021 09:34
Nginx - Server, Proxy and Reverse Proxy Configurations
server {
listen 80;
listen [::]:80;
listen 443 ssl;
server_name cdn.lk;
ssl_certificate /home/aslam/server/ssl/cdn.lk.crt;
ssl_certificate_key /home/aslam/server/ssl/cdn.lk.key;
location / {
@aslamanver
aslamanver / DetailsView.kt
Last active September 5, 2021 06:46
Custom View in Android - Kotlin
import android.content.Context
import android.content.res.TypedArray
import android.util.AttributeSet
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
class DetailsView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
@aslamanver
aslamanver / HumanDateUtils.java
Last active February 14, 2021 14:20
Human Readable Date - Java
import java.util.Date;
public class HumanDateUtils {
public static String durationFromNow(Date startDate) {
long different = System.currentTimeMillis() - startDate.getTime();
long secondsInMilli = 1000;
long minutesInMilli = secondsInMilli * 60;
@aslamanver
aslamanver / app.js
Last active December 4, 2020 06:58
Pure JavaScript WebSocket Server with Ping-Pong, Handshake Upgrade, AES Encrypt, Decrypt and Authentication functionalities.
const express = require("express")
const WebSocket = require('ws')
const app = express()
const server = require('http').createServer(app)
const wss = new WebSocket.Server({ noServer: true })
const wschandler = require('./wschandler').from(wss, server)
wss.on('connection', (ws, req) => {
console.log('connection', req.socket.remoteAddress, ws.data.token)
@aslamanver
aslamanver / categorizer.py
Created November 1, 2020 19:46
Files categorize by year and month - This script will categorize all the files in a directory to a folders.
#!/bin/bash
# This script will move all the files in a directory to a folders
# with the name of year and month which it gets from the file's created time.
# Run: python categorizer.py /home/aslam/screenshots
# It will categorize all of your files by folders as the name of year and month
# Ex: 1.jpg will be moved to 2020-10_1 folder as 1.jpg created at 2020-10-15 also
# the last number after underscore is the count of the directory
import os