Skip to content

Instantly share code, notes, and snippets.

View baileylo's full-sized avatar

Logan Bailey baileylo

View GitHub Profile
@baileylo
baileylo / image-upload.vue
Created May 9, 2018 17:15
A vue component for uploading images and previewing them.
<template>
<div>
<div>
<div class="rounded" style="background-color:white; border: 1px solid #999; height: 200px;font-size:128px;text-align:center" @drop.stop.prevent="drop" @dragenter.stop.prevent="dragEnter" @dragleave.stop.prevent="dragLeave" @dragover.stop.prevent="">
<img :src="imageData" v-if="imageData" ref="preview" :width="imageWidth" :height="imageHeight">
<i class="fas fa-image" v-else="imageData"></i>
</div>
</div>
<input type="file" ref="fileInput" class="form-control d-none" v-bind:class="{'is-invalid': error}" @change="onFileChange">
<div class="invalid-feedback" :class="{'d-block': error}" v-text="error" v-if="error"></div>
@baileylo
baileylo / speech-writer.php
Created July 21, 2016 00:29
A speech writer designed to prevent plagiarism
<?php
if ($argc < 2) {
echo "Please enter a number of words for the speech\n";
exit(1);
}
$dictionary = explode(PHP_EOL, `cat /usr/share/dict/words`);
@baileylo
baileylo / gist:8945380
Last active August 29, 2015 13:56
Thinking about unit tests and how you think about your functions and how you write your tests.
<?php
class Foo
{
private $bar;
public function setBar($bar)
{
$this->bar = $bar;
}
@baileylo
baileylo / input.json
Last active December 27, 2015 11:59
A simple URL redirection validator written in php. Usage: php urlTester.php input.json See input.json for example input file.
[
["http://localhost:8000/redirect1/" , 301, "http://localhost:8000"],
["http://localhost:8000/redirect2/" , 302, "http://localhost:8000"],
["http://localhost:8000/something" , 404]
]
@baileylo
baileylo / Default (OSX).sublime-mousemap
Created October 25, 2013 16:14
Adds key binding for option key on mac to go to function definition.
[
{ "button": "button1", "modifiers": ["alt"], "command": "goto_definition", "press_command": "drag_select" }
]
@baileylo
baileylo / gist:6783242
Created October 1, 2013 18:52
Code to create spotify openable links.
// starts with spotify:track
// used defined input
input = 'spotify:track:6MdqqkQ8sSC0WB4i8PyRuQ';
var parts = input.match(/spotify\:track\:(.+)/)
if (parts.length !== 2) {
return input;
}
@baileylo
baileylo / gist:4490036
Created January 9, 2013 02:27
Fix your damn code!
<?php
// If you do this
if ($a) {
if ($b) {
//code here
} else {
//code here
}
} else {
//Brian McBride
//Ping Pong application
//9/15/08
#include <pthread.h>
#include <iostream>
#include <string>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 7/13/2012
####################################
sudo apt-get update
sudo apt-get upgrade
@baileylo
baileylo / gist:2362087
Created April 11, 2012 20:07
Example why you should use type hinting in php where applicable.
<?php
class User {
}
function setUserName(User $user, $new_username) {
$user->Profile->setUserName($new_username);
}