Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
the learning never stops

Aamnah Akram aamnah

💭
the learning never stops
View GitHub Profile
@aamnah
aamnah / check_os_ostype.sh
Last active Mar 31, 2022
Check operating system inside a bash script and change commands
View check_os_ostype.sh
# 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 Feb 8, 2021
Bash function to save all images from a URL in the current directory, takes a URL as param
View README.md

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 Feb 3, 2021
React Native - Running on physical device
View README.md

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 Feb 8, 2021
Urdu Nastaleeq font in WordPress WPML and other websites
View README.md

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 Aug 9, 2020 — forked from todgru/starttmux.sh
Start up tmux with custom windows, panes and applications running
View starttmux.sh
#!/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 Aug 5, 2020
get a random color every time
View random-color.ts
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 Aug 1, 2020
ESLint for React Native (sans Typescript support)
View .eslintrc.yaml
# .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 Aug 3, 2020
Standard bootstrap for React Native projects
View .eslintrc.yaml
# .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 Nov 24, 2021
Cheats and helpers for creating a custom oh-my-zsh theme and git prompt
View README.md

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 Apr 30, 2020
Change WordPress Multisite Domain
View README.md

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' );