Skip to content

Instantly share code, notes, and snippets.

View aamnah's full-sized avatar
💭
the learning never stops

Aamnah aamnah

💭
the learning never stops
View GitHub Profile
@aamnah
aamnah / check_os_ostype.sh
Last active March 31, 2022 09:23
Check operating system inside a bash script and change commands
# Flush DNS cache
if [[ $OSTYPE == darwin* ]]; then
# works on macOS
alias flushdns='sudo dscacheutil -flushcache'
elif [[ $OSTYPE == linux* ]]; then
# works on Ubuntu 18.04+
alias flushdns='sudo systemd-resolve --flush-caches'
fi
@aamnah
aamnah / README.md
Last active February 8, 2021 04:51
Bash function to save all images from a URL in the current directory, takes a URL as param

wget all images

Bash function to save all images from a URL in the current directory, takes a URL as param.

Saved it as a bash function so that i don't have to worry about remembering the params for wget.

  • -nd no directories (save all files to the current directory; -P directory changes the target directory)
  • -r -l 2: recursive level 2
  • -A accepted extensions
  • -H span hosts (wget doesn't download files from different domains or subdomains by default)
@aamnah
aamnah / README.md
Last active February 3, 2021 10:25
React Native - Running on physical device

NOTE: Seems like you can only test on one physical device at a time

Add manufacturer codes to udev rules

  • 0e8d - MediaTek (Infinix Hot 9)
  • 17ef - Lenovo
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="0e8d", MODE="0666", GROUP="plugdev"' | sudo tee /etc/udev/rules.d/51-android-usb.rules
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="17ef", MODE="0666", GROUP="plugdev"' | sudo tee /etc/udev/rules.d/51-android-usb.rules
@aamnah
aamnah / README.md
Last active February 8, 2021 04:53
Urdu Nastaleeq font in WordPress WPML and other websites

Non-English WordPress sites

The lang attribute should be added with whatever the language code is. For example lang="ur" for Urdu. This needs to be added to any element where you have Urdu text. You can then target all lang attributes on the page that have the ur value and set the font family for it.

*[lang="ur"] { 
	font-family: 'Noto Nastaleeq;
}

The caveat with this approach is that it'll only work if the lang attribute exists and has the value set to ur. If you forget setting this, your custom Urdu font will not show.

@aamnah
aamnah / starttmux.sh
Created August 9, 2020 16:27 — forked from todgru/starttmux.sh
Start up tmux with custom windows, panes and applications running
#!/bin/sh
#
# Setup a work space called `work` with two windows
# first window has 3 panes.
# The first pane set at 65%, split horizontally, set to api root and running vim
# pane 2 is split at 25% and running redis-server
# pane 3 is set to api root and bash prompt.
# note: `api` aliased to `cd ~/path/to/work`
#
session="work"
@aamnah
aamnah / random-color.ts
Created August 5, 2020 05:58
get a random color every time
const getColor = () => (Math.floor(Math.random() * 255))
const style = {
color: `rgb(${getColor()},${getColor()},${getColor()})`
}
return (
<div>
<h4 style={style}>{message}</h4>
</div>
)
@aamnah
aamnah / .eslintrc.yaml
Created August 1, 2020 16:05
ESLint for React Native (sans Typescript support)
# .eslintrc.yaml
# Configuration: https://eslint.org/docs/user-guide/configuring
# Using with Prettier: https://prettier.io/docs/en/integrating-with-linters.html#recommended-configuration
root: true
extends:
- '@react-native-community'
- plugin:import/errors
- plugin:import/warnings
@aamnah
aamnah / .eslintrc.yaml
Last active August 3, 2020 06:40
Standard bootstrap for React Native projects
# .eslintrc.yaml
# Configuration: https://eslint.org/docs/user-guide/configuring
# Using with Prettier: https://prettier.io/docs/en/integrating-with-linters.html#recommended-configuration
root: true
extends:
- '@react-native-community'
- 'plugin:import/errors'
- 'plugin:import/warnings'
@aamnah
aamnah / README.md
Last active November 26, 2023 03:45
Cheats and helpers for creating a custom oh-my-zsh theme and git prompt

Zsh custom git prompt cheatsheet

Everything you need for customizing your git prompt in oh-my-zsh

  • print and echo commands for all functions in the git plugin. Printing and echoing because then i can check what values are outputted. Massively helpful when creating a theme.
  • a list of all the variables that you can use to customize $(git_prompt_info), thanks to vergenzt
grep -o "ZSH_THEME_GIT_[A-Z_]\+" lib/git.zsh| sort | uniq
@aamnah
aamnah / README.md
Last active April 30, 2020 15:45
Change WordPress Multisite Domain

Change WordPress Multisite Domain

You need to update five different tables in the database in order to change the domain, as well as updating the wp-config.php file

The following SQL script takes care of updating all tables in one go. Make sure to replace newdomain.com and olddomain.com (minus the http:// at the begining and / at the end) with the domain you want to change to before running the SQL commands

In wp-config.php, update the following line:

define( 'DOMAIN_CURRENT_SITE', 'newdomain.com' );