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_install.sh
Last active October 29, 2017 09:10
check if a program/command is installed on macOS
# Check if a program is installed on macOS (or any Unix-like system)
# Run the function and pass the program/command you want to check as an argument
# Example: checkInstall brew
checkInstall() {
program=$1
if [[ $(command -v ${program}) == "" ]]; then
# program is not installed since the output is empty
echo -e "${program} is not installed"
@aamnah
aamnah / check_brew_install.sh
Last active May 23, 2022 13:54
check if Homebrew is installed on macOS
# Check if Homebrew is installed, install if we don't have it, update if we do
homebrew() {
# $() is for command substitution, commands don't _return_ values, they _capture_ them
# more here: https://stackoverflow.com/a/12137501/890814
# [[ ]] is the newer _test command_ for evaluations, is more literal
# more here: http://mywiki.wooledge.org/BashFAQ/031
# the double [[ ]], and $() is important
# `command -v brew` will output nothing if Homebrew is not installed
if [[ $(command -v brew) == "" ]]; then
@aamnah
aamnah / copyDefaultTheme.sh
Last active October 12, 2017 16:36
Copy the default OpenCart theme, re-structure it, update links and make it ready to be published as an .ocmod.zip file
# Copy Default Theme
# run this script from inside `catalog/view/theme/`
# (the themes directory for OpenCart, i.e. where your 'default' theme folder resides)
# run: bash catalog/view/theme/copyTheme.sh foo
# TODO
# [ ] add status/progress messages
# [ ] add error handling, if the folder already exists etc.
@aamnah
aamnah / form.html
Last active October 11, 2017 05:18
Form Elements and Input Types
<form action="#" method="post" id="demoForm">
<h3>Form Elements and (most of the) Input Types</h3>
<label for="progress-bar">Progress</label>
<progress value="75" max="100" name="progress-bar"></progress>
<fieldset>
<legend>Account Info</legend>
<label for="name">Name </label>
<input type="name" id="name">
<label for="email">Email </label>
@aamnah
aamnah / _media-queries.scss
Last active March 25, 2017 07:30
Sass - Media Query Mixins
// MEDIA QUERIES
// USE: @include media(desktop) { .. }
// Breakpoints in ./_variables.scss
// $S: 576px; // Small devices (landscape phones, 576px and up)
// $M: 768px; // Medium devices (tablets, 768px and up)
// $L: 992px; // Large devices (desktops, 992px and up)
// $XL: 1200px; // Extra large devices (large desktops, 1200px and up)
// If device size EXACTLY MATCHES
@aamnah
aamnah / _colors.scss
Last active March 15, 2017 16:33
Flat UI Colors - Sass named variables
/*
In Sublime Text, install the Color Highlighter plugin to get highlighted colors,
immedidately know what color is the variable $body-bg pointing to
Colors from: http://designmodo.github.io/Flat-UI/
*/
$color-turquoise: #1ABC9C; // TURQUOISE
$color-greenSea: #16A085; // GREEN SEA
$color-emerald: #2ECC71; // EMERALD
$color-nephritis: #27AE60; // NEPHRITIS
@aamnah
aamnah / list-articles-by-collection.liquid
Last active February 8, 2025 22:34 — forked from nternetinspired/output-articles-by-collection.liquid
Loop through Jekyll collections and list their posts
{% comment %}
Loops though every collection you defined in _config.yml and grabs the pages they contain; outputting titles.
{% endcomment %}
{% for collection in site.collections %}
{% assign name = collection.label %}
<h1>{{ name }}</h1>
@aamnah
aamnah / mysql.sql
Last active March 9, 2017 19:54
MySQL: Create a database, user, and grant privileges
SET @DATABASE='database';
SET @USERNAME='username';
SET @PASSWORD='password';
SET @HOST='localhost';
CREATE DATABASE @DATABASE;
CREATE USER '@USERNAME'@'@HOST' IDENTIFIED BY '@PASSWORD';
-- GRANT USAGE ON @DATABASE.* TO '@USERNAME'@'@HOST';
GRANT ALL PRIVILEGES ON @DATABASE.* TO '@USERNAME'@'@HOST';
FLUSH PRIVILEGES;
@aamnah
aamnah / .htaccess
Last active May 30, 2018 16:19
.htaccess for WordPress
# Secure File Permissions
# https://codex.wordpress.org/Changing_File_Permissions#.htaccess_permissions
# 600 -rw------- /home/user/wp-config.php
# 604 -rw----r-- /home/user/cgi-bin/.htaccess
# 600 -rw------- /home/user/cgi-bin/php.ini
# 711 -rwx--x--x /home/user/cgi-bin/php.cgi
# 100 ---x------ /home/user/cgi-bin/php5.cgi
# BEGIN Increases Max Upload Size
php_value upload_max_filesize 64M
@aamnah
aamnah / server.js
Created March 5, 2017 15:01
Basic API using Nodejs + Express + MongoDB (less than 100 lines of code, adds + finds vehicles)
/*
path: server.js
*/
// Require shit
const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
// Let's import our Vehicle model