This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Console\Command; | |
use Illuminate\Support\Facades\Log; | |
use Illuminate\Support\Facades\Storage; | |
abstract class BaseCommand extends Command | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Attempt to attach template over the network. | |
* It attempts to derive an HTML tag from the filename, | |
* but we could do anything here. | |
* | |
* @param string filename | |
*/ | |
static async attachRemote(filename) { | |
const filenameMatches = filename.match(/\/([^\.\/]+)\.html/i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<main> | |
<my-paragraph> | |
Lorem ispum sit amet dolor | |
</my-paragraph> | |
<hr /> | |
<labeled-input> | |
This is the form label | |
</labeled-input> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text.RegularExpressions; | |
public class Program | |
{ | |
public static void Main() { | |
string input = "MyParagraphElement"; | |
string output = Regex.Replace(input, @"([a-z0–9])([A-Z])", "$1-$2").ToLower(); | |
Console.WriteLine(output); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Option B: Checks if is NOT null | |
if (dog?.breed is { }) return dog.breed; | |
// Option C: Checks if is NOT null, then assigns to local variable "breedA" | |
if (dog?.breed is { } breedA) return breedA; | |
// Option D: Uses property pattern to check on object and return props as variables | |
if (dog?.breed is { Length: var lengthA } breedB) return $"{breedB} ({lengthA} characters long)"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ \[([^\]]+)\]\(([^\)]+)\) / | |
\[([^\]]+)\] | |
\[ Look for a literal left bracket, by escaping it | |
( Start a capture group to retrieve the contents | |
[^\]]+ Repeatedly find a character that isn't a closing bracket | |
) Close the capture group | |
\] Look for a literal right bracket, by escaping it | |
\(([^\)]+)\) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?PHP | |
// Setup code | |
// ... | |
$emails = Models\User::pluck('email'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generate a range of characters based on strings | |
* | |
* @param string startCharacter | |
* @param string endCharacter | |
* @return string[] | |
*/ | |
function generateCharacterRange(startCharacter, endCharacter) { | |
let letters = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.fromCharCode(...Array(123).keys()).slice(97).split(''); | |
// ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Check URL against Regular Expression | |
* | |
* @param string url | |
* @return string|boolean | |
*/ | |
function parseYoutubeId(url: string): string|boolean { | |
const regexp: RegExp = new RegExp('(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/\s]{11})', 'i'); | |
const matches: string[] = url.match(regexp); |