Skip to content

Instantly share code, notes, and snippets.

View ryantxr's full-sized avatar

Ryan Teixeira ryantxr

View GitHub Profile
@ryantxr
ryantxr / extractMageMetaData.php
Created May 20, 2024 10:55
Extract mage.space meta data from jpg file
<?php
/*
May 20 2024 @ryantxr
This is intended to be used on images generated by mage.space.
Some images generated on mage.space have some meta data in the
actual image. If the meta data exists in the file this program will
output it as json.
NOTE: Mage does not put the model in the meta data.
@ryantxr
ryantxr / migration-required-primary-key.php
Created March 25, 2024 01:04
Laravel migration mod to turn off primary key requirement
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
@ryantxr
ryantxr / LaravelSqlLogging.php
Created November 26, 2018 18:36
Capture ALL SQL to a separate sql.log
// Capture ALL SQL to a separate sql.log
// In config/logging.php add the following to the channel list
'sql' => [
'driver' => 'single',
'path' => storage_path('logs/sql.log'),
'level' => 'debug',
],
// In app/Providers/AppServiceProvider.php add the following to the boot() method.
@ryantxr
ryantxr / Laravel5.6-Bootstrap-Vue.md
Last active April 2, 2018 13:48
How I made Laravel 5.6, Bootstrap 4 and Vue 2 work together

This is a brief description on making Laravel 5.6, Bootstrap-Vue work. Make sure to install Node and Npm. I have the following:

  1. Node 8.10.0
  2. NPM 4.6.1

Make a new laravel project

laravel new name-of-project

/*
This is a wait dialog to show "please wait" while the app is doing some
long running task.
To call it from a view controller:
WaitDialog.show(self)
// start long running task
// Long running task is done.
WaitDialog.hide()
@ryantxr
ryantxr / BeanstalkQueue.php
Created February 12, 2018 14:31
Use Beanstalk and PHP to make an asynchronous system
class BeanstalkClient extends AbstractBaseQueue{
public $queue;
public $host;
public $port;
public $timeout;
function __construct($timeout=null) {
$this->loadClasses();
$this->host = '127.0.0.1;
@ryantxr
ryantxr / HttpArgString.swift
Created November 3, 2017 02:37
Extension for [String : String] to convert to http arg string
//
// Extensions.swift
// ProcessCompletion
//
// Created by ryan teixeira on 11/2/17.
// Copyright © 2017 Blazecore. All rights reserved.
//
import Foundation
@ryantxr
ryantxr / OutputJson.swift
Created October 11, 2017 17:36
JSON output from API Call
/*
JSON from API calls are provided as Data objects, not strings.
While debugging, it is often necessary to output the JSON
string somewhere. This snippet does that.
*/
if let data = data {
print("JSON = " + String(data: data, encoding: .utf8)! )
}
// Notice the use of ! since the String constructor might fail.
@ryantxr
ryantxr / InitStructFromData.swift
Last active August 19, 2017 22:13
Initialize a struct from data, dictionary etc
// Credit: https://stackoverflow.com/users/887210/colgraff
struct Header {
let version : UInt
let options : UInt
let records : UInt
}
// adds marshaling
extension Header {
enum Keys: String { case version, options, records }
<?php
class Adventurer {
public $class;
public $name;
public $inventory = [];
public $handler;
function __construct($name, $class, $handler=null) {