Skip to content

Instantly share code, notes, and snippets.

View nyl2k8's full-sized avatar

Niall Lonergan nyl2k8

View GitHub Profile
source ~/.profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# The inspiration for this file can be found: https://natelandau.com/my-mac-osx-bash_profile/
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
@nyl2k8
nyl2k8 / index.php
Created October 22, 2019 11:04
Image Upload Preview
<form action="/controller.php" method="post" enctype="multipart/form-data">
<input type="file" id="imgInput" name="file" />
<img src="/assets/default_empty.png" id="upImage" src="#" alt="Upload Image" />
</form>
<script type="text/javascript">
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
@nyl2k8
nyl2k8 / generatepassword.js
Created July 1, 2019 16:16
Javascript Password Generator.
function generatePassword() {
var numCaps = 1;
var numLower = 6;
var numChars = 1;
var stringLength = numCaps + numLower + numChars;
var randomString = '';
var caps = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
var lower = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
@nyl2k8
nyl2k8 / .htaccess
Created June 26, 2019 08:09
.htaccess file for Codeigniter.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
@nyl2k8
nyl2k8 / try_catch.php
Last active October 15, 2018 08:16
PDO Try Catch
try {
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Add PDO query below here.
if($sth->execute()){
$arr = $sth->errorInfo();
print_r($arr);
}
}
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
//#1 - npm init -y
//#2 - npm install -save express
//#3 - npm install -save nodemon
var express = require('express')
var app = express()
var port = 3000;
app.get('/', function(req, res){
res.sendFile(__dirname + 'index.html')
# 1) Replace 'http://localhost/site.loc' with 'http://site.com'
# 2) Check if wp_ prefix needs to changed.
# 3) Avoid trailing slashes in url. eg. http://site.com/
UPDATE wp_options SET option_value = replace(option_value,
'//localhost/website', '//website.loc') WHERE
option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid,
'//localhost/website','//website.loc');