Skip to content

Instantly share code, notes, and snippets.

@loren138
loren138 / example.py
Last active July 17, 2017 15:13
Example Python
from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt #conda install matplotlib
# -40 65.33333333
# -30 99.66666667
# -20 130
# -10 175.3333333
# 0 383.6666667
# 10 446.3333333
@loren138
loren138 / hangman.py
Last active July 13, 2017 19:39
Hangman Psuedocode
from __future__ import print_function
import numpy
# Save this file using file save in your browser
# Do not copy paste into PyCharm as it will mess up the indentation
# and thus your code will not run properly.
# Print Hangman's current state
def printHangman(numberWrong):
# Print the hangman
@loren138
loren138 / guzzle-retry.php
Last active August 16, 2016 13:26 — forked from gunnarlium/guzzle-retry.php
Example of how to create a retry subscriber for Guzzle 6
<?php
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Handler\CurlHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Request as Psr7Request;
use GuzzleHttp\Psr7\Response as Psr7Response;
use Psr\Log\LoggerInterface;
const MAX_RETRIES = 2;
@loren138
loren138 / .bash_prompt_colors
Last active March 6, 2017 18:16
Server Setup - Change Password and Copy Keys/Bashrc Files
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
bldblk='\e[1;30m' # Black - Bold
@loren138
loren138 / Readme.md
Last active July 6, 2016 16:53
Angular Grep (find value using array of objects with id or other property)

Angular Grep

Find value using array of objects with id or other property.

Usage

In the controller:

@loren138
loren138 / RequestValidator.php
Created May 3, 2016 17:03
Validate Twilio TwilML SMS Request with Laravel (also a Twilio Controller for Laravel)
<?php
/**
* Twilio Request Validator Class
* This file goes in app/Models/Twilio (or you can move it around and change the namespace)
* It requires that you have a file config/api.php
* Source: https://raw.githubusercontent.com/twilio/twilio-php/3d02ee1f1bde8e860e7dbfd9d2d0d2b7ca7d625c/Services/Twilio/RequestValidator.php
*/
namespace App\Models\Twilio;
@loren138
loren138 / updateBranch.sh
Created April 15, 2016 20:41
Update and merge current branch with develop via stash for GitFlow or HubFlow
#!/bin/bash
set -e
branch=$(git rev-parse --abbrev-ref HEAD)
stash=false;
if ! git diff-index --quiet HEAD --; then
stash=true
git stash
fi
@loren138
loren138 / SessionTimeout.php
Created December 18, 2015 20:13
Laravel Session Timeout Middleware
<?php
namespace App\Http\Middleware;
use Closure;
use Session;
class SessionTimeout
{
@loren138
loren138 / readme.md
Created October 22, 2015 16:31
MS SQL with Laravel Homestead

MySBTS (Info Version 2)

To make composer install run after a pull to make sure your versions of things are update date, add this git hook https://gist.github.com/loren138/7038d20d32c206c82393

Upon downloading the API, you will need to run composer install to install the vendor files. This also means that if you update or add a composer dependency eg (composer require or composer update) that you will need to let others know to rerun composer install on their personal machines.

Note: The deploy scripts take care of running composer during the deploy process. (See the rocketeer files here: https://gist.github.com/loren138/27d9f53a4dfb3df206dd)

@loren138
loren138 / RankedQuery.json
Created October 22, 2015 16:26
Sample Elastic Search Code
{"query":{"function_score":{"query":{"multi_match":{"query":"yoga","type":"most_fields","fields":["title^10","title.std","title.shingles","authors^10","language^10","description^10","description.std","description.shingles","transcript^10","transcript.std","transcript.shingles","scripture^10","tags^10","origin_id^10"]}},"functions":[{"gauss":{"date_created":{"origin":"now\/d","scale":"50w","offset":"4w","decay":"0.5"}}}]}},"_source":{"exclude":["transcript","segments.*"]},"size":"10"}