Skip to content

Instantly share code, notes, and snippets.

@byteranger
byteranger / gist:9cf0ceb2a74a65999ad4
Last active August 29, 2015 14:14
In Laravel 4.1, where you have a table named "a", this migration will create a table named "b," but fail on creating the foreign key because column b.a_id doesn't exist. This leaves the DB in an inconsistent state where the table exists, but the migrations table doesn't know it.
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTableB extends Migration {
/**
* Run the migrations.
*
<?php
/*
TESTED:
CentOS/WHM/CPanel
Apache 2.4
PHP 5.5.29
suPHP
CGI/FastCGI
$name = preg_replace_callback('/[A-Z]/', function ($matches) {
return '_' . strtolower($matches[0]);
}, $name);
@byteranger
byteranger / functions.bash
Last active March 5, 2024 08:53
Useful commands, one-liners and tricks I come across or think of while working with bash. Usually on Linux, but sometimes other Unix including MacOS. Should have started collecting these in one place sooner, lots to catch up on. Will probably eventually move to a git repo.
# Bash 4.3+ required
# Split a string into an array
function str_split {
local -n result=$1
if [[ -n "$3" ]]
then
local IFS="$3"
fi
read -ra result <<< "$2"
<?php
//ini_set('display_errors', '1'); //DEBUG
ob_start();
$active = null;
?><!DOCTYPE html>
<html>
<head><title>Health Check</title></head>
<body>
<dl>
<?php
@byteranger
byteranger / vmware.vmx
Created August 7, 2020 22:08
VMware condensed serial number
SMBIOS.useShortSerialNumber = "TRUE"