Skip to content

jaechow/info

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

74 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Β Β Β Β Β Β  Live Demo Contributions welcome GitHub Issues License Awesome GitHub tweet

Windows Development β€’ macOS Development β€’ Android Development β€’ Android Studio β€’ Webserver Development β€’ Linux Stuff β€’ Sublime Text β€’ GitHub Emotes

Info

Introduction

The living, breathing cheat-sheet!

Windows Development

  • Open the Power Shell prompt

    • shortcut: Windows+X and type A
  • Install Chocolatey the Package Manager

Run Get-ExecutionPolicy. If it returns Restricted, then run Set-ExecutionPolicy AllSigned or Set-ExecutionPolicy Bypass -Scope Process.

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
  • Enable GPG signing with native Windows Git
foo@bar:~$ where gpg
C:\Program Files (x86)\GnuPG\bin\gpg.exe

foo@bar:~$ git config --global gpg.program "C:\Program Files (x86)\GnuPG\bin\gpg.exe"

macOS Development

  • Open the Terminal Emulator

      • shortcut: command+space and type terminal
    • command is also ⌘
    • option is also βŒ₯
    • control is also βŒƒ
    • shift is also ⇧
  • View all (hidden) files in Finder

    • shift+command+.
  • Go To Folder (open system directory in Finder)

    • shift+command+G
  • Output log of all macOS downloaded content

sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'select LSQuarantineDataURLString from LSQuarantineEvent'
  • Remove log of all macOS downloaded content
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'
  • Install Homebrew, the macOS package manager
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • Elevate to root
foo@bar:~$ sudo su
Password:πŸ—
  • Copy contents of id_rsa.pub file to your clipboard
pbcopy < ~/.ssh/id_rsa.pub
  • Display Time Machine Snapshots
tmutil listlocalsnapshots /

The terminal will display Snapshots like: com.apple.TimeMachine.2018-03-01-00201

  • Delete Time Machine Snapshots
tmutil deletelocalsnapshots 2018-03-01-002010

Android Development

  • Reboot Android device to bootloader
adb reboot bootloader
  • Reboot Android device to fastboot (non-Samsung)
adb reboot fastboot
  • Wipe Android device's User data (Cracked screen, need to wipe?)
adb fastboot -w
  • OEM Unlock Android device bootloader
fastboot oem unlock
  • Flash the bootloader partition with the file dragged into the console window
fastboot flash bootloder 
  • Erase Dalvik cache
fastboot erase cache
  • Reboot Android device (from Fastboot)
fastboot reboot

Android Studio

  • Enable keyboard input without editing theΒ config.ini:

Tools β†’ Android β†’ AVD Manager β†’βœοΈβ†’ Show Advanced Settings (scroll to bottom) β†’ Enable Keyboard Input

Webserver Development

  • Install packages necessary to host webpages
sudo apt update && sudo apt install php apache2 libapache2-mod-php php-curl libapache2-mod-auth-mysql mysql-server php-mysql phpmyadmin
  • Setup MySQL
mysql_secure_installation
mysql -u root -p
  • Enable Apache2 rewrite module
a2enmod rewrite
  • Enable headers rewrite module
a2enmod headers
  • Enable mcrypt
sudo php5enmod mcrypt
  • Restart Apache
sudo service apache2 restart
  • Install Remote Sublime Text Binary
sudo wget -O /usr/local/bin/rmate https://raw.github.com/aurora/rmate/master/rmate && sudo chmod a+x /usr/local/bin/rmate
  • Edit mysql config
rmate /etc/mysql/my.cnf
  • Enable mysqli
rmate /etc/php/7.0/apache2/php.ini
  • Make phpMyAdmin viewable
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
  • Edit Apache Configuration
rmate /etc/apache2/apache2.conf
  • View Apache Error Log
rmate /var/log/apache2/error.log
  • Update cURL
! /usr/bin/env bash
  • Install any build-dependencies necessary for cURL
sudo apt-get build-dep curl
  • Get latest libcurl (as of: Feb 25, 2016)
mkdir ~/curl
cd ~/curl
wget http://curl.haxx.se/download/curl-7.50.2.tar.bz2
tar -xvjf curl-7.50.2.tar.bz2
cd curl-7.50.2

In Review: Symbolic Link ln -s [current-target] [new-location]

  • Update SSL (Avoid Heart Bleed)
    • First, ensure make is installed
sudo apt-get install make
  • Download openSSL
wget https://www.openssl.org/source/openssl-1.1.0h.tar.gz
  • Decompress and enter new directory
tar -xzvf openssl-1.1.0h.tar.gz
cd openssl-1.0.2g
  • Configure openSSL
sudo ./config -Wl,--enable-new-dtags,-rpath,'$(LIBRPATH)'
  • Compile openSSL
sudo make
  • Install openSSL
sudo make install
  • Restart
sudo reboot
  • Verify openSSL version
openssl version -v
  • Allow Access-Control to share Font cross-site
  • Edit Apache2 Configuration:
<FilesMatch "\.(ttf|otf|eot|woff)$">
  <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
  </IfModule>
</FilesMatch>
  • SSL Certificates with Let's Encrypt

    • First, add the repository:
    sudo add-apt-repository ppa:certbot/certbot
    • press enter to accept. Next, update the package and install
    sudo apt update && sudo apt install python-certbot-apache
    • Ensure apache2.conf contains port 80 entry for domain(s) being added
    • Generate SSL Certificate
      • certonly assumes you will manually configure SSL Certificate config
    certbot --apache certonly -d domain.com -d www.domain.com -d sub1.domain.com -d sub2.domain.com -d sub3.domain.com
    • Add to existing SSL Certificate
      • Ensure the original 'domain.com' is first in the list:
    certbot --apache certonly --expand -d domain.com -d www.domain.com -d sub1.domain.com -d sub2.domain.com -d sub3.domain.com -d sub4.domain.com
  • Remove a Let's Encrypt SSL Certificate

rm -rf /etc/letsencrypt/archive/domain.com/
rm -rf /etc/letsencrypt/live/domain.com/
rm -rf /etc/letsencrypt/renewal/domain.com.conf
  • Edit SSL Certificate configuration
rmate /etc/apache2/sites-available/000-default-le-ssl.conf
  • Set up Auto-Renewal To run the renewal check daily, we will use cron, a standard system service for running periodic jobs. We tell cron what to do by opening and editing a file called a crontab
sudo crontab -e

Your text editor will open the default crontab which is a text file with some help text in it. Paste in the following line at the end of the file, then save and close it:

. . .
15 3 * * * /usr/bin/certbot renew --quiet

The 15 3 * * * part of this line means "run the following command at 3:15 am, every day". You may choose any time.

The renew command for Certbot will check all certificates installed on the system and update any that are set to expire in less than thirty days. --quiet tells Certbot not to output information nor wait for user input.

cron will now run this command daily. Because we installed our certificates using the --apache plugin, Apache will also be reloaded to ensure the new certificates are used.

Linux Stuff

  • Print Working Directory
pwd
  • Shortcuts

    • id username
      • List primary and secondary groups for username
    • ls ~
      • List contents of home directory
  • User Administration

  • Add a username and assign secondary group: tomcat7
sudo useradd -G tomcat7 -m username
  • Recursively delete user and /home directory
sudo userdel -r username
  • Assign primary group named primarygroup for user named username
sudo usermod -g primarygroup username
  • Modify the secondary group(s) (comma,delimited,list) of username
sudo usermod -G admin,adm,merchant,issuer,username username
  • Add a new group named groupname
sudo groupadd groupname
  • To remove a user from a group, use the gpasswd command with the -d (short for delete) option as follows
gpasswd -d userName groupExiting
  • Recursively change the owner of file directoryname to groupname
sudo chgrp -R groupname directoryname
  • Change shell to bash (bash history) for username
sudo chsh -s /bin/bash username
  • BASH Aliases

    • Create/Edit ~/.bash_aliases
    • Add:
      • alias rsub='rmate $1'
      • no whitespace around '='
  • Modify file permissions with chmod a+x

chmod a+x ~/.bash_aliases
  • To read and execute the contents of a file/script use the Source command (the following example loads the bash aliases file)
source ~/.bash_aliases
  • Find all files owned by jacob, change owner to jason and group owner to groupname
sudo find .-user jacob -exec chown jason:groupname {} \;

Sublime Text

  • Open .ssh/config in Sublime Text locally
subl ~/.ssh/config
  • Enable remote Sublime Text editting, add
Host domain.com
RemoteForward 52698 127.0.0.1:52698
  • Find all cron jobs listed by user
  • exclude comments
  • Suppress 'no crontab for user...' messages:

Must be run as root

for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l 2>/dev/null | grep -v '^#'; done

GitHub Custom Emotes

Use these emotes anywhere on GitHub (only)

emote shortcode
:bowtie: :bowtie:
:neckbeard: :neckbeard:
:octocat: :octocat:
:shipit: :shipit:
:trollface: :trollface:
:suspect: :suspect:
:hurtrealbad: :hurtrealbad:
:feelsgood: :feelsgood:
:goberserk: :goberserk:
:finnadie: :finnadie:
:rage1: :rage1:
:rage1: :rage1:
:rage3: :rage3:
:rage4: :rage4:
:godmode: :godmode:

Contributors

GitHub Contributors Image

Your Repository's Stats

About

Shortcuts and cheat sheets for developers.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Languages