Skip to content

Instantly share code, notes, and snippets.

View mohsin's full-sized avatar

Saifur Rahman Mohsin mohsin

View GitHub Profile
@mohsin
mohsin / KEYSTORE.md
Last active January 4, 2021 22:05
Using Keystore properties in Android Projects
  1. Add to project-level build.gradle:
allprojects {
    ...
    afterEvaluate { project ->
        def propsFile = rootProject.file('keystore.properties')
        def configName = 'release'

        if (propsFile.exists() && project.hasProperty("android") && project.android.signingConfigs.hasProperty(configName)) {
@mohsin
mohsin / totaltime.sh
Created August 2, 2017 18:01
Bash script to find the total duration of videos in a folder
ext=".mp4"
ffmpeg_location="/usr/local/Cellar/ffmpeg/3.1.2/bin/ffmpeg"
for file in *$ext
do
duration=$("$ffmpeg_location" -i "${file}" 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//)
hours=10#$(echo "$duration" | cut -d":" -f1)
minutes=10#$(echo "$duration" | cut -d":" -f2)
seconds=10#$(echo "$duration" | cut -d":" -f3 | cut -d"." -f1)
millis=10#$(echo "$duration" | cut -d":" -f3 | cut -d"." -f2)
((totalMillis=millis+seconds*1000+minutes*60000+hours*3600000))
@mohsin
mohsin / OctoberCMS-Setup.md
Last active September 20, 2017 21:11
OctoberCMS Web Project Setup

Checklist available as Trello board as well. Copy board at https://trello.com/b/3jxpgyRE to use.

Setup OctoberCMS

  • Pull OctoberCMS
wget https://octobercms.com/download
unzip master
mv install-master/ Web
rm master
cd Web/
@mohsin
mohsin / business-offers.md
Created March 9, 2018 15:03
My business offers

I'm a freelance app developer and make really good money building apps for others. One of my long term goals is to hire more people and work together but not yet. Instead, I've put 2 other offers to my friends and only 1 out of the 20 people I offered, took up one and he makes money regularly. So, I'll put forward the same offers to you and if you think you can do this then we're on!

First offer (low income with less effort)

Get me projects (clients) for web and mobile development. Whatever money I make from the client you refer, I give 5% finder fee perpetually (that means that even if they come back after a project for more work, since you referred you get paid the finder fee every time money comes my way thro' that client). One of my good friends took this offer up and he makes a decent level of money every month from the clients that he referred to me. Lucky for him, the clients have kept coming back for more work so it's been stable income for him. It's like a

@mohsin
mohsin / DropboxController.php
Created August 7, 2019 19:57
Laravel function to download files from Dropbox
public function download(Request $request, $clintId, $dtId, $inId)
{
$path = $request->input('dropbox_file_path');
$downloadFileName = basename($path);
$cheaders = [
'Authorization: Bearer ' . env('DROPBOX_BEARER_TOKEN'),
'Content-Type: text/plain',
'Dropbox-API-Arg: {"path":"$path"}'
];
@mohsin
mohsin / mail-in-a-box.md
Created August 23, 2019 09:28
Installation Log Mail-In-A-Box on GCP instance

Setup DNS A record mail.mywebsite.com to external IP of instance

First let's install SSL certificates coz Mail-In-A-Box certificates are not linked to an email

sudo add-apt-repository ppa:certbot/certbot
sudo apt install python-certbot-nginx

If dkpg lock issue appears:

lsof /var/lib/dpkg/lock
ps cax | grep PID
@mohsin
mohsin / list.txt
Created September 3, 2019 08:23
List of git files in a new Android Studio generated project
new file: .gitignore
new file: app/.gitignore
new file: app/build.gradle
new file: app/proguard-rules.pro
new file: app/src/main/AndroidManifest.xml
new file: app/src/main/java/com/acme/MainActivity.kt
new file: app/src/main/res/drawable-v24/ic_launcher_foreground.xml
new file: app/src/main/res/drawable/ic_launcher_background.xml
new file: app/src/main/res/layout/activity_main.xml
new file: app/src/main/res/layout/content_main.xml
@mohsin
mohsin / gist:6b68b2d826c2dac4e803aceee9bd44c7
Created November 1, 2019 13:06
PHP-CS Sublime Text 3 Configuration
// SublimeLinter Settings - User
// Make sure to drop phpcs.xml at HOME directory.
{
"linters": {
"phpcs": {
"args": "--standard='~/phpcs.xml'",
"styles": [
{
"icon": "circle"
}
@mohsin
mohsin / index.js
Created May 3, 2020 19:40
Code to calculate country-wise death percent for COVID-19 cases at https://www.worldometers.info/coronavirus/
// Run thro' browser JS console
$('#main_table_countries_today > tbody:nth-child(2) > tr').each(function(item) {
var total = parseInt($(this).children('td:nth-child(2)').text().replace(/,/g, ''), 10);
var active = parseInt($(this).children('td:nth-child(7)').text().replace(/,/g, ''), 10);
var deadCases = parseInt($(this).children('td:nth-child(4)').text().replace(/,/g, ''), 10);
var recOrDead = total - active;
$(this).append('<td>' + ((deadCases / recOrDead) * 100).toFixed(3) + '</td>');
});
@mohsin
mohsin / waterfall.js
Created May 14, 2020 19:27
jQueryless Waterfall with custom Deferred
/* Usage
* waterfall(this, [Promise1, Promise2, ...])
* .fail(function(reason){
* console.log('failed')
* })
*/
export function waterfall(...params) {
var steps = [],
dfrd = new Deferred(),