Skip to content

Instantly share code, notes, and snippets.

View clnt's full-sized avatar
🤘

Matt Clinton clnt

🤘
View GitHub Profile
@clnt
clnt / serialization-fixer.php
Created May 2, 2019 16:05
Wordpress Serialization fixer script for PHP 7+
<?php
// This code is a serialised string fixer for WordPress (and probably other systems).
// Simply select the table you need to fix in $table, and the code will change the string lengths for you. Saves having to manually go through.
// Written 20090302 by David Coveney http://www.davecoveney.com and released under the WTFPL - ie, do what ever you want with the code, and I take no responsibility for it OK?
// To view the WTFPL go to http://sam.zoy.org/wtfpl/ (WARNING: it's a little rude, if you're sensitive)
//
// Thanks go to getmequick at gmail dot com who years ago posted up his preg_replace at http://uk2.php.net/unserialize and saved me trying to work it out.
//
// Before you start, do make a backup. A backup that you know works, because this code has the scope to really break your data if you're careless.
@clnt
clnt / recordsToCollection.php
Created July 17, 2018 13:48
Convert array of SimpleXMLElement objects into a Laravel collection
/**
* Convert an array of SimpleXMLElement's into a
* collection.
*
* @param array $records
*
* @return \Illuminate\Support\Collection
* @access public
*/
public function recordsToCollection($records) : \Illuminate\Support\Collection
<template>
<div id="monitors">
</div>
</template>
<script>
export default {
props: {
pings: [Object, Number],
<template>
<div class="flex">
<div class="w-full block md:inline-block md:w-1/2 md:pl-6 md:pr-8">
<v-select v-model="monitorInput" :options="monitors" placeholder="Select Line" @input="monitorUpdated"></v-select>
</div>
<div class="w-full block md:inline-block md:w-1/2 md:pr-6 md:pl-8">
<v-select v-model="rangeInput" :options="ranges" placeholder="Select Range" @input="rangeUpdated"></v-select>
</div>
</div>
</template>
<template>
<div id="monitor-wrapper">
<monitor-select v-on:monitor-updated="updateMonitor" v-on:range-updated="updateRange" :monitor-value="allOption"></monitor-select>
<div id="monitor-inner" class="p-6 text-center">
<monitor :pings="pings" :range="range"></monitor>
</div>
</div>
</template>
<script>
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
require('./bootstrap');
window.Vue = require('vue');
@clnt
clnt / gist:b62e20ec6014c95cc607381ae1913153
Created March 27, 2018 10:49
Nginx + Socket.io SSL Config
upstream websocket {
server 127.0.0.1:8443;
}
server {
root /var/www/html/subdomain.example.com/public;
index index.php index.html index.htm;
server_name subdomain.example.com;
@clnt
clnt / gist:22744be0ea9dae967024ae9d0cc0286b
Created January 17, 2018 13:01
StackOverflow Question 92867 Delete Item
if($itemCount > 1)
{
foreach($items as $item)
{
if($item->getProduct()->getId() == $productId)
{
$itemId = $item->getItemId();
$cart->removeItem($itemId)->save();
}
}
@clnt
clnt / gist:44cd87a32d964440a931fd350ea38f77
Created January 17, 2018 12:59
StackOverflow Question 92867 Delete Last Item
if($itemCount > 1)
{
$i = 0;
foreach($items as $item)
{
$i++;
if($i == $itemCount)
{
if($item->getProduct()->getId() == $productId)
{