Skip to content

Instantly share code, notes, and snippets.

View cabloo's full-sized avatar

Zane H cabloo

View GitHub Profile
@cabloo
cabloo / Git Branch.md
Last active August 29, 2015 14:20
Sync with remotes and create new git branch

Setup

  • Put gitbr in /usr/local/bin.
  • If necessary, replace master and origin with the main branch and remote of the repository.
  • Make it executable (chmod +x /usr/local/bin/gitbr).

Usage

  • Run gitbr with no arguments to have the branch name generated for you (e.g. 04-13-001274741-2015).
  • Run gitbr to use a specific branch name.
@cabloo
cabloo / training.scala
Last active December 11, 2015 00:59
Training neural network
//XOR logic
var xor = new NeuralNetwork( Array( 2, 3, 1 ) )
xor.train( 10000, Map( Array(0.0,1.0)->Array(1.0),Array(1.0,0.0)->Array(1.0),Array(1.0,1.0)->Array(0.0),Array(0.0,0.0)->Array(0.0)))
xor.truth_table()
//Rudimentary OCR
val zero = Array[Double](0,1,1,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,1,1,0)
val two = Array[Double](0,1,1,1,0,0,0,0,1,0,0,1,1,1,0,0,1,0,0,0,0,1,1,1,0)
@cabloo
cabloo / disable_ipv6.sh
Last active January 4, 2016 03:28
Debian Necessities
echo "# Disable IPV6" >> /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.eth0.disable_ipv6 = 1" >> /etc/sysctl.conf
@cabloo
cabloo / git_cleanup.sh
Last active February 27, 2016 01:17
Git cleanup merged branches
git pull origin HEAD
# http://stevenharman.net/git-clean-delete-already-merged-branches
git branch --merged develop | grep -v "master" | grep -v "develop" | xargs -n 1 git branch -d
git branch
@cabloo
cabloo / image.php
Last active March 21, 2016 18:10
Custom PHP graphing library built for GameVue
<?php
class image
{
public $registry;
public function resize( $new_img, $tempFile, $saveTo, $MaxWidth, $MaxHeight )
{
$path = pathinfo( $saveTo );
$(function(){
$('.autocomplete .input').live("propertychange keydown keypress keyup input paste focus click", function(e){
e.stopImmediatePropagation();
e.stopPropagation();
var $parent = $(this).parents('.autocomplete');
var $dropdown = $parent.find('.dropdown');
if( $dropdown.length === 0 )
{
@cabloo
cabloo / 2016_05_14_172105_CreateSomeRelation.php
Last active May 14, 2016 18:24
Laravel Drop Foreign Column
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;
use Illuminate\Database\Migrations\Migration;
class CreateSomeRelation extends Migration
{
/**
* @var Builder
@cabloo
cabloo / AddProjectNamespace.md
Last active December 8, 2016 20:56
Add a root namespace (e.g. App) to a Laravel project that doesn't have one. Afterwards, set the namespace in phpspec.yml

Add a root namespace (e.g. App) to a Laravel project that doesn't have one.

([\s])([\\']{0,1})(Console|Events|Exceptions|Handlers|Helpers|Http|Models|Providers|Services)([\\;])

->

$1$2App\\$3$4
@cabloo
cabloo / Git Pull Request.md
Last active March 3, 2017 04:17
Create Pull Request on GitHub with same title as last commit message

Setup:

  • Generate a GitHub Access Token with repo:status access.
  • Put gitpr.py in a scripts directory (I use ~/scripts/python/) and update it with your github access token.
  • Save gitpr as /usr/bin/gitpr and make it executable (chmod +x /usr/bin/gitpr). Then update the value of scripts_dir to the directory you saved gitpr.py in.
  • Optional: Install pyperclip with sudo pip install pyperclip. If pyperclip is detected, the link to the Pull Request on GitHub will be copied to your clipboard.
  • Optional: if you are using a repository that takes Pull Requests at a branch other than master, you will have to add the repository to the target_branches dict with the repo as the key and the target branch as the value. See the code for an example.

Usage:

@cabloo
cabloo / Readme.md
Last active November 12, 2017 21:11
Deploy a server with root account access via private key + sudo user only.

Run this on your local machine, it will run the scripts below for you:

wget "https://gist.githubusercontent.com/cabloo/223528dc0c4d01caac95f7d872e38864/raw/deploy-client.sh"
bash deploy-client.sh

You will need to follow the prompts and then enter the root password of the remote server twice.