Skip to content

Instantly share code, notes, and snippets.

View frankyonnetti's full-sized avatar

Frank Yonnetti frankyonnetti

View GitHub Profile
@frankyonnetti
frankyonnetti / postgresql.sh
Last active February 17, 2021 00:32
Postgresql #postgres
# http://postgresapp.com
# http://big-elephants.com/2012-12/tuning-postgres-on-macos
# import sql file
## In the command promt, not the postgres promt.
## Same why you would import mysql db.
# create
$ createdb database_name
@frankyonnetti
frankyonnetti / php-ternary-operation.php
Last active February 17, 2021 00:32
PHP - ternary operation #php #ternary #shorthand
var = x ? y : z
// means
if $x is set, use $y, if not use $z
@frankyonnetti
frankyonnetti / php-strip-whitespace-punctuation-and-lowercase.php
Last active February 17, 2021 00:33
PHP - strip whitespace, punctuation and lowercase #php #strip-whitespace #lowercase
# to keep letters & numbers
$s = preg_replace('/[^a-z0-9]+/i', '_', $s); # or...
$s = preg_replace('/[^a-z\d]+/i', '_', $s);
# to keep letters only
$s = preg_replace('/[^a-z]+/i', '_', $s);
# to keep letters, numbers & underscore
$s = preg_replace('/[^\w]+/', '_', $s);
@frankyonnetti
frankyonnetti / oh-my-zsh.sh
Last active February 17, 2021 00:33
Oh-my-zsh #oh-my-zsh #terminal
# Cheatsheet
# https://github.com/robbyrussell/oh-my-zsh/wiki/Cheatsheet
# brew install zsh-completions
# To activate these completions, add the following to your .zshrc:
$ fpath=(/usr/local/share/zsh-completions $fpath)
# You may also need to force rebuild `zcompdump`:
@frankyonnetti
frankyonnetti / mysql-commands.sh
Last active February 17, 2021 14:46
MySQL - commands #mysql
### MySQL ###
#########################
# MySQL commands:
http://www.pantz.org/software/mysql/mysqlcommands.html
# Add database:
mysql> create database DATABASENAME;
# Delete database:
@frankyonnetti
frankyonnetti / mysql-supres- cli-warnings.sh
Last active February 17, 2021 00:34
MySQL - supress cli warnings #mysql #cli #warnings
# https://stackoverflow.com/a/20854048
# Avoid the WARNING message using the mysql_config_editor tools:
$ mysql_config_editor set --login-path=local --host=localhost --user=username --password
# Now type this:
$ mysql --login-path=local
@frankyonnetti
frankyonnetti / jquery-colorLuminance.js
Last active February 17, 2021 00:35
jQuery - colorLuminance #jquery #color
// Adjust value of a HEX color
// jsfiddle.net/y2mgW
function colorLuminance(hex, lum) {
// validate hex string
hex = String(hex).replace(/[^0-9a-f]/gi, '');
if (hex.length < 6) {
hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2];
}
lum = lum || 0;
// convert to decimal and change luminosity
@frankyonnetti
frankyonnetti / javascript-menu-dropdown-onclick.js
Last active May 22, 2021 19:51
Javascript - menu dropdown onClick #javascript #menu
const menus = document.querySelectorAll('.dropdown')
menus.forEach((menu) => {
menu.addEventListener('click', () => {
// close open menus first
menus.forEach((menu) => {
menu.classList.remove('open')
})
// open clicked menu
menu.classList.add('open')
@frankyonnetti
frankyonnetti / python-fabric-install.sh
Last active February 17, 2021 00:36
Python - fabric install #python #fabric
# install python
$ brew install python@2
# upgrade pip tools
$ pip install --upgrade pip setuptools
# insatll fabric version 1
# version 2 will not work with python 2
$ pip install 'fabric<2.0'
@frankyonnetti
frankyonnetti / html5-template.html
Last active August 13, 2021 02:02
HTML5 - template #html #template
<!DOCTYPE html>
<html lang="en">
<head>
<title>Untitled</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<!-- favicon -->
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">