Skip to content

Instantly share code, notes, and snippets.

View arafathusayn's full-sized avatar
👨‍💻
Focusing

Arafat Husayn arafathusayn

👨‍💻
Focusing
View GitHub Profile
@arafathusayn
arafathusayn / Android USB Debugging.md
Last active November 25, 2017 16:25
[React Native Android] yarn run usb or, npm run usb (Linux or MacOS)

Add the code below to your npm scripts in package.json

"usb": "react-native run-android --deviceId $(adb devices | grep -oP '[0-9a-zA-Z]{7,30}\t')",

Example:

"scripts": {
  "start": "node node_modules/react-native/local-cli/cli.js start",
 "usb": "react-native run-android --deviceId $(adb devices | grep -oP '[0-9a-zA-Z]{7,30}\t')",
@arafathusayn
arafathusayn / vs-js-snippets.json
Created November 9, 2017 13:07
VS Code custom snippets for Javascript
{
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
},
@arafathusayn
arafathusayn / bookmarklet.js
Created October 19, 2017 08:17
Wanna run your Javascript snippets on your mobile offline? Save this bookmarklet in your mobile browser bookmarks. You may navigate to about:blank first to get a blank page to run the bookmarklet on it. Start typing your bookmark name which contains the 'javascript:' code below as URL in your address bar and tap on it. Then start playing!
javascript:document.body.innerHTML=`<div style='border-radius:10px;height:290px;width:600px;margin:auto;padding:10px;background-color:green;'> <textarea style='border:1px solid green;border-radius:5px;margin:auto;padding:5px;width:600px;height:290px;' onkeyup='(new Function(this.value.trim()))()' onfocus='(new Function(this.value.trim()))()'>\n\n\n\n\n\n\n\ndocument.getElementById('r').innerText = "Hello!"</textarea> <div id='r' style='font-size:24px;font-weight:bold;padding:30px;margin-top:30px;text-align:center;border:2px solid green;' ></div> </div>`
@arafathusayn
arafathusayn / gulpfile.js
Created October 18, 2017 08:11
Laravel View Files Minification (HTML, CSS & JS) with Gulp
// > gulp minify
const htmlmin = require('gulp-htmlmin')
const gulp = require('gulp')
gulp.task('minify', () => {
const opts = {
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true,
@arafathusayn
arafathusayn / gist:53595a737f929860338c08361b0d028d
Created October 15, 2017 11:39 — forked from mrbobbybryant/gist:f1714ab93b8171947ed7
WordPress Custom Post Type (Using $singular and $plural)
<?php
//Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function dwwp_register_post_type() {
$singular = 'Job';
$plural = 'Jobs';
@arafathusayn
arafathusayn / Open with SublimeText3.bat
Created October 5, 2017 07:42
Add "Open with SublimeText3!" to every context menu (right-click files, folders, current folder) on Windows OS
@echo off
SET st3_path=C:\Program Files\Sublime Text 3\sublime_text.exe
SET st3_label=Open with SublimeText3!
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "%st3_label%" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3_path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3_path% \"%%1\"" /f
rem add it for folders
@arafathusayn
arafathusayn / chrome-bg-with-sw-communication.md
Created September 3, 2017 13:23 — forked from zdila/chrome-bg-with-sw-communication.md
How to send messages from service worker to the chrome extension without having the webapp open

In the background script we have:

chrome.webRequest.onBeforeRequest.addListener(function (details) {
  if (details.method === 'HEAD') {
    if (details.url.endsWith('?start')) {
      ringSound.play();
    } else if (details.url.endsWith('?stop')) {
      ringSound.pause();
 ringSound.currentTime = 0;
@arafathusayn
arafathusayn / acceptAllFriendRequestsOnFB.js
Created July 30, 2017 12:15
When you got so many friend requests on Facebook but you don't like to click on "Confirm" button of each request!
setInterval(() => { document.querySelector('div#FriendRequestMorePager > div > a').click() }, 5000)
setInterval(() => {
document.querySelector('button[class="_42ft _4jy0 _4jy3 _4jy1 selected _51sy"][value="1"][type="submit"]').scrollIntoView()
window.scrollBy(0, -100)
document.querySelector('button[class="_42ft _4jy0 _4jy3 _4jy1 selected _51sy"][value="1"][type="submit"]').click()
}, 1000)
@arafathusayn
arafathusayn / index.js
Last active May 4, 2017 06:21 — forked from schnerd/index.js
index.js
const CDP = require('chrome-remote-interface');
const argv = require('minimist')(process.argv.slice(2));
const file = require('fs');
// CLI Args
const url = argv.url || 'https://www.google.com';
const format = (argv.format === 'jpeg') ? 'jpeg' : (argv.format === 'jpg') ? 'jpg' : 'png';
const viewportWidth = argv.viewportWidth || 1920;
const viewportHeight = argv.viewportHeight || 1080;
const aspectRatio = viewportWidth / viewportHeight;
@arafathusayn
arafathusayn / tmux_local_install.sh
Last active April 21, 2017 11:57 — forked from crobicha/tmux_local_install.sh
bash script for installing tmux without root access
#!/bin/bash
# Don't forget: chmod +x tmux_local_install.sh
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e