Skip to content

Instantly share code, notes, and snippets.

@ConnerAiken
ConnerAiken / index.html
Last active June 29, 2017 19:12
ES6: Promise Chain and Fetch API
<!DOCTYPE html>
<html lang="en">
<head>
<title>ES6: Promises and Fetch API Example</title>
<meta charset="utf-8">
<meta author="Conner Aiken">
<meta content="width=device-width, initial-scale=1" name="viewport">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
@ConnerAiken
ConnerAiken / ex.js
Created July 7, 2017 19:49
Disable right-click in webpages
document.addEventListener('contextmenu', event => event.preventDefault());
// This will annoy users and some browsers prevent this behavior so test accordingly.
@ConnerAiken
ConnerAiken / clean.php
Created July 22, 2017 18:26
Clean email form input in PHP
function cleanInput($input) {
// Pass the $_GET, $_POST or $_REQUEST array
$output = array();
foreach ($input as $key=>$value) {
$o = $value;
// Make sure it's within the max length
$o = substr($o,0,256);
@ConnerAiken
ConnerAiken / .robomongorc.js
Created August 11, 2017 16:59
Robomongo - add CSV Export option
// Export to CSV function
DBQuery.prototype.toCSV = function(deliminator, textQualifier)
{
var count = -1;
var headers = [];
var data = {};
var cursor = this;
deliminator = deliminator == null ? ',' : deliminator;
@ConnerAiken
ConnerAiken / index.html
Created November 22, 2017 17:11
Async/Await example
<!DOCTYPE html>
<html>
<head>
<script>
const validUrl = 'https://jsonplaceholder.typicode.com/posts';
const invalidUrl = 'https://jsonplaceholder.invalid.domain.com/posts';
function downloadData(url) {
console.log(`[downloadData()] attempting AJAX request to ${url}`);
@ConnerAiken
ConnerAiken / commands.txt
Created February 23, 2018 17:43
Jenkins - Clear build history
// change this variable to match the name of the job whose builds you want to delete
def jobName = "Your Job Name"
def job = Jenkins.instance.getItem(jobName)
job.getBuilds().each { it.delete() }
// uncomment these lines to reset the build number to 1:
//job.nextBuildNumber = 1
//job.save()
@ConnerAiken
ConnerAiken / script.sh
Created March 16, 2018 18:52
Sync two git repositories
#!/bin/bash
# REPO_NAME=<repo>.git
# ORIGIN_URL=git@<host>:<project>/$REPO_NAME
# REPO1_URL=git@<host>:<project>/$REPO_NAME
rm -rf $REPO_NAME
git clone --bare $ORIGIN_URL
cd $REPO_NAME
git remote add --mirror=fetch repo1 $REPO1_URL
@ConnerAiken
ConnerAiken / robbyrussell.zsh-theme
Created March 20, 2018 16:34
ZShell - Robby Russell Theme /w User@Host in prompt
GNU nano 2.5.3 File: /home/connera/.oh-my-zsh/themes/robbyrussell.zsh-theme Modified
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
# Customize and add user/host perfix
PROMPT="%{$fg[white]%}%n@%{$fg[green]%}%m%{$reset_color%} ${PROMPT}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
@ConnerAiken
ConnerAiken / README.md
Created March 31, 2018 05:16
js/jsx loader for webpack4 - babel-loader
@ConnerAiken
ConnerAiken / README.md
Created April 14, 2018 20:03 — forked from hofmannsven/README.md
My simply Git Cheatsheet