Skip to content

Instantly share code, notes, and snippets.

// These tests show the various ways to spawn child threads
// and in what scenarios the value in the AsyncLocal or
// logical CallContext will flow to the child threads.
// All of the below test results are identical if you
// use the old CallContext.LogicalSetData CallContext.LogicalGetData
void Main()
{
// Set the AsyncLocal value and we'll see where this flows
<?php
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasOneOrMany;
trait CanUpdateRelations
{
public function newInstanceWithRelations($attributes = [])
<?php
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Query\Builder as QueryBuilder;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
trait HasAutoIncByField
{
@m-nic
m-nic / ExtractTranslationsCommand.php
Last active January 8, 2021 19:41
Laravel + Vue translation strings command.
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Lang;
use Symfony\Component\Finder\SplFileInfo;
@m-nic
m-nic / setupPrez.sh
Created January 5, 2020 12:46
setupPrez.sh
#!/usr/bin/env bash
mkdir projectAOSTW
cd projectAOSTW || exit
git clone https://github.com/m-nic/aostw.git
cd aostw || exit
wget https://gist.githubusercontent.com/m-nic/a0f1bebf4726bf2691a88f821adb05c6/raw/16872d118dc9a52ccb7155690c64a7ace1bad459/add_site.sh
bash add_site.sh service.aostw.localhost
#!/usr/bin/env bash
sudo apt update
# Install apache
sudo apt install -y apache2
# sudo systemctl enable apache2.service
sudo systemctl start apache2.service
# Install PHP
sudo apt-get install software-properties-common
@m-nic
m-nic / simpleCrud.js
Last active April 21, 2019 13:37
simpleCRUD node
var host = "127.0.0.1";
var port = 8080;
var express = require("express");
var fs = require('fs');
var app = express();
#!/usr/bin/python
from flask import Flask, request, redirect, url_for, send_from_directory
# Setup Flask app.
app = Flask(__name__)
app.debug = True
# Routes
#!/usr/bin/env bash
if [ -z "$1" ] && [ -z "$2" ]; then
echo "Enter domain name and document root"
else
sandboxHost="$1"
documentRoot="`pwd`/$2"
apacheConf="/etc/apache2/sites-available/$sandboxHost.conf"
#!/usr/bin/env bash
sudo mysql -e "CREATE USER '$1'@'localhost' IDENTIFIED WITH mysql_native_password BY '$2'; GRANT ALL PRIVILEGES ON * . * TO '$1'@'localhost'; FLUSH PRIVILEGES;" -p