Skip to content

Instantly share code, notes, and snippets.

View rana01645's full-sized avatar

Afjalur Rahman Rana rana01645

View GitHub Profile
@rana01645
rana01645 / delete 7 days older file from speicific folder linux
Created March 2, 2021 06:11
delete 7 days older file from speicific folder linux
sudo find /home/forge/default/user/ -mindepth 1 -type f -mtime +7 | xargs rm
@rana01645
rana01645 / remove_comment_regex.txt
Created December 13, 2020 07:31 — forked from natebass/remove_comment_regex.txt
Remove comments from file. Credit to Lambda's answer on Stack Overflow https://stackoverflow.com/a/2613945/5178499
Remove all block comments and line comments:
(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/|[ \t]*//.*)
Remove block comments:
(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/)
Remove line comments:
([ \t]*//.*)
# checkout to old_named branch
git checkout <old_name>
# create new named branch
git branch -m <new_name>
# push new named branch to remote
git push origin -u <new_name>
# delete old named branch
@rana01645
rana01645 / gist:ea5350cfb6f966036f308f56c6e986d7
Created September 30, 2020 18:17
import db to remote mysql
DB_HOST=1.2.3.4
DB_PORT=3306
DB_DATABASE=db_name
DB_PASSWORD='password'
DB_USERNAME=username
pv -f db.sql | mysql -f -h ${DB_HOST} --port=${DB_PORT} -u${DB_USERNAME} -p${DB_PASSWORD} ${DB_DATABASE}
@rana01645
rana01645 / wgcf.py
Created July 22, 2020 20:55 — forked from oskar456/wgcf.py
Cloudflare WARP linux client (using wg-quick for actual tunnel setup)
#!/usr/bin/env python3
import subprocess
import json
import os
from pathlib import Path
import requests
from requests.compat import urljoin
@rana01645
rana01645 / laravel_csv_modifier.php
Created July 22, 2020 19:52
vel CSV spceific column modifier based on another file
use Illuminate\Support\Collection;
function csvToArray($filename = '', $delimiter = ',')
{
if (!file_exists($filename) || !is_readable($filename))
return false;
$header = null;
$data = array();
if (($handle = fopen($filename, 'r')) !== false)
{
sudo mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;
service mysql restart
$action = AutomationAction::where('type','upload')->whereNull('started_at')->whereHasMorph( 'performer',['App\Video'], function ( $query) { $query->whereNotNull('uploaded_at'); })->update(['status'=>'success','started_at'=>now(),'finished_at'=>now()]);
/** get queue size **/
Queue::size('queue-name');
/** Count by name **/
use Illuminate\Support\Facades\Redis;
// List all keys with status (awaiting, reserved, delayed)
Redis::keys('*');
// Count by name
@rana01645
rana01645 / background.js
Created November 16, 2019 21:27 — forked from muralikg/background.js
puppeteer screen capture demo. Currently records 10 second video. Change the timeout in background.js with your own logic to stop the recording when necessary. Try with `node export.js`
/* global chrome, MediaRecorder, FileReader */
chrome.runtime.onConnect.addListener(port => {
let recorder = null
port.onMessage.addListener(msg => {
console.log(msg);
switch (msg.type) {
case 'REC_STOP':
console.log('Stopping recording')
if (!port.recorderPlaying || !recorder) {