Skip to content

Instantly share code, notes, and snippets.

@mattsplat
mattsplat / helpers.kt
Last active August 11, 2023 15:32
Copy Class
/**
* Create new class with values from original unless passed in changes map
*/
inline fun <reified T: Any> T.replicateWithChanges(
changes: Map<String, Any?> = mapOf()
): T {
val constructor = this.javaClass.kotlin.primaryConstructor
if(constructor?.parameters == null) throw Exception("Invalid Constructor for Replication")
val propertyMap = this.mapProperties()
@mattsplat
mattsplat / app.js
Created August 27, 2021 04:01
Lazy Load Vue3 Laravel
require('./bootstrap');
import {createApp} from "vue";
import {registerComponents} from './components';
const app = createApp({});
registerComponents(app)
app.mount('#app')
@mattsplat
mattsplat / WithAttachedMixin.php
Last active March 25, 2021 16:01
withAttached
/**
*
* Usage
*
* Register in provider
* Builder::mixin(new WithAttachedMixin);
*
* withAttached(
* relation name,
* name of property (default = {relation_name}_{column}s),
@mattsplat
mattsplat / AggregateCountMacro.php
Last active September 13, 2020 00:24
Aggregate Counts
Illuminate\Database\Eloquent\Builder::macro('toSqlWithBindings', function () {
return $this->toBase()->toSqlWithBindings();
});
\Illuminate\Database\Query\Builder::macro('toSqlWithBindings', function () {
return vsprintf(
str_replace('?', '%s', $this->grammar->compileSelect($this)),
collect($this->getBindings())
/*
Provides an easy interface for add select statements to Eloquent relationships.
This allows you to sort by the fields in the query.
Usage
add to AppServiceProvider@boot
Relationship name and column must be seperated by pipe.
Laravel strips out . so it was easier to just use something else
Model::withRelationalAttribute(['relation|column as relation_column'])->get()
@mattsplat
mattsplat / AutoComplete.vue
Created September 16, 2019 22:10
Vue auto complete or new
/*
Example usage;
<autocomplete
url="/statutes/all"
create
v-model="charge.citation"
valueField="number"
displayField="name"
@selected="statuteSelected"
></autocomplete>
@mattsplat
mattsplat / react-native-ble-plx+1.0.3.patch
Last active September 9, 2019 20:20
Add getBondedDevices function to react-native-ble-plx for Android
diff --git a/node_modules/react-native-ble-plx/android/build/generated/source/buildConfig/debug/com/polidea/reactnativeble/BuildConfig.java b/node_modules/react-native-ble-plx/android/build/generated/source/buildConfig/debug/com/polidea/reactnativeble/BuildConfig.java
new file mode 100644
index 0000000..a5ba89a
--- /dev/null
+++ b/node_modules/react-native-ble-plx/android/build/generated/source/buildConfig/debug/com/polidea/reactnativeble/BuildConfig.java
@@ -0,0 +1,13 @@
+/**
+ * Automatically generated file. DO NOT MODIFY
+ */
+package com.polidea.reactnativeble;