Skip to content

Instantly share code, notes, and snippets.

@hrsa
hrsa / 2018_02_07_101510_migrate_to_utf8mb4.php
Last active February 20, 2024 20:43 — forked from NBZ4live/2018_02_07_101510_migrate_to_utf8mb4.php
Laravel migration to migrate the database from utf8 to utf8mb4 (exclude views and char() columns and keep default values)
<?php
use Illuminate\Database\Migrations\Migration;
return new class extends Migration {
public function up(): void
{
$this->migrateCharsetTo('utf8mb4', 'utf8mb4_unicode_ci');
}
@0187773933
0187773933 / OneDriveRemoverOSX.sh
Last active April 13, 2024 11:12
Completely Uninstalls OneDrive from Mac OSX and all settings just change username
#!/bin/bash
sudo pkill -9 OneDrive
sudo rm -rf /Applications/OneDrive.app/
sudo rm /Library/LaunchAgents/com.microsoft.OneDriveStandaloneUpdater.plist
sudo rm /Library/LaunchDaemons/com.microsoft.OneDriveStandaloneUpdaterDaemon.plist
sudo rm /Library/LaunchDaemons/com.microsoft.OneDriveUpdaterDaemon.plist
sudo rm -rf /Library/Logs/Microsoft/OneDrive
sudo rm /private/var/db/receipts/com.microsoft.OneDrive-mac.bom
@zfarbp
zfarbp / s.md
Last active March 27, 2024 10:34
Trigger Spotify with osascript

Trigger Spotify with osascript

/Applications/Spotify.app/Contents/Resources/Spotify.sdef

# read-only
osascript -e 'tell application "Spotify" to player state'                  # stopped,playing,paused
osascript -e 'tell application "Spotify" to current track'                 # The current playing track.
osascript -e 'tell application "Spotify" to artwork url of current track'  # Image data in TIFF format.
osascript -e 'tell application "Spotify" to artist of current track'       # The artist of the track.
#battery
sudo pmset -b standbydelaylow 300
sudo pmset -b standby 1
sudo pmset -b halfdim 1
sudo pmset -b sms 0
sudo pmset -b disksleep 10
sudo pmset -b standbydelayhigh 600
sudo pmset -b sleep 10
sudo pmset -b autopoweroffdelay 40000
sudo pmset -b hibernatemode 25
@NBZ4live
NBZ4live / 2018_02_07_101510_migrate_to_utf8mb4.php
Created February 7, 2018 11:56
Laravel migration to migrate the database from utf8 to utf8mb4
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class MigrateToUtf8mb4 extends Migration
{
/**
* Run the migrations.
@e7d
e7d / sample.sh
Last active May 11, 2024 13:46
Bash "try catch"
#!/bin/bash
export AnException=100
export AnotherException=101
# start with a try
try
( # open a subshell !!!
echo "do something"
[ someErrorCondition ] && throw $AnException
@JacobBennett
JacobBennett / blog.md
Last active June 4, 2023 05:50
Sharing Laravel Cookies across subdomains

I recently ran into a problem where I had a suite of applications hosted on a set of subdomains that all needed to be able to share a single cookie. Any cookies other than the shared cookie needed to stay specific to their subdomain, but this one shared cookie needed to be accessible to any of them. I also wanted to accomplish this using Laravel's Cookie facade.

The Problem

To accomplish this, there were two issues to solve.

  1. All cookies created by the Laravel framework are encrypted by default. (link)
  2. I needed to figure out how to set a domain on the shared cookie that was different than the domain it was being set from.

Setting Non-Encrypted Cookies

In Laravel 5.1, a feature was added which allows you to add a list of cookie names that should not be encrypted to the EncryptCookies Middleware under the $except array. Check out [the docs](http://laravel.com/docs/5.1/responses#attaching-cookies

@tkuchiki
tkuchiki / bats.log
Last active May 16, 2023 11:07
Example Bats
##### setup start
BATS_TEST_NAME: test_example_status_and_output-2c_lines
BATS_TEST_FILENAME: /home/bats/test.bats
BATS_TEST_DIRNAME: /home/bats
BATS_TEST_NAMES: test_example_status_and_output-2c_lines
BATS_TEST_DESCRIPTION: example status and output, lines
BATS_TEST_NUMBER: 1
BATS_TMPDIR: /tmp
##### setup end
example 1
@silent1mezzo
silent1mezzo / 0fixup.md
Created January 24, 2012 15:12 — forked from SethRobertson/index.md
On undoing, fixing, or removing commits in git

A git choose-your-own-adventure!

This document is an attempt to be a fairly comprehensive guide to recovering from what you did not mean to do when using git. It isn't that git is so complicated that you need a large document to take care or your particular problem, it is more that the set of things that you might have done is so large that different techniques are needed depending on exactly what you have done and what you want to have happen.