Skip to content

Instantly share code, notes, and snippets.

@marianz-bonfire
marianz-bonfire / UsersController.php
Created September 19, 2024 15:18
Mock Controller
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Validator;
@marianz-bonfire
marianz-bonfire / Util.js
Last active November 29, 2024 21:34
Collection of helper JS function
function generateGuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
const r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
}
function generateCode(length) {
let code = "";
for (let index = 0; index < length; index++) {
@marianz-bonfire
marianz-bonfire / ColumnIndexToColumnLetter.cs
Created January 18, 2024 01:53
C# convert Excel column index into letter
private static string ColumnIndexToColumnLetter(int columnIndex)
{
var index = columnIndex;
var columnLetter = string.Empty;
var mod = 0;
while (index > 0) {
mod = (index - 1) % 26;
columnLetter = (char)(65 + mod) + columnLetter;
index = (index - mod) / 26;
@marianz-bonfire
marianz-bonfire / only_one_usage_of_each_socket_address.reg
Created January 11, 2024 02:45
REGEDIT: Only one usage of each socket address
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
"TcpTimedWaitDelay"=dword:0000001e
"MaxUserPort"=dword:0000fffe
"TcpNumConnections"=dword:00fffffe
"TcpMaxDataRetransmissions"=dword:00000005
@marianz-bonfire
marianz-bonfire / drag_area.dart
Created January 11, 2024 02:14
Flutter -Movable Object
class DragArea extends HookWidget {
final Widget child;
const DragArea({super.key, required this.child});
@override
Widget build(BuildContext context) {
final position = useState(Offset(100, 100));
return Stack(