Skip to content

Instantly share code, notes, and snippets.

Avatar

Robert Cooper robertcoopercode

View GitHub Profile
View utils.php
<?php
/**
* Lorem Ipsum Generator
*
* PHP version 5.3+
*
* Licensed under The MIT License.
* Redistribution of these files must retain the above copyright notice.
*
View loremipsum.php
#!/usr/bin/env php
# Dependency: This script requires PHP
# Install PHP: https://www.php.net/manual/en/install.php
#
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Lorem Ipsum
# @raycast.mode compact
# @raycast.packageName Lorem Ipsum
@robertcoopercode
robertcoopercode / .zshrc
Last active May 5, 2022
Zsh configuration file
View .zshrc
#------------------
# Shell Variables
#------------------
# Specify VS Code as default editor for the React Native Simulator
export REACT_EDITOR=code-insiders
# Set VS Code Insiders as default code editor
export EDITOR=code-insiders
# Android SDK
export ANDROID_HOME=~/Library/Android/sdk
@robertcoopercode
robertcoopercode / dark_colors.yaml
Created Feb 17, 2019
Color LS custom color configuration file
View dark_colors.yaml
# Main Colors
unrecognized_file: palegreen
recognized_file: turquoise
dir: dodgerblue
# Link
dead_link: red
link: cyan
# Access Modes
@robertcoopercode
robertcoopercode / .hyper.js
Last active May 14, 2022
Hyper Configuration
View .hyper.js
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// Choose either "stable" for receiving highly polished,
// or "canary" for less polished but more frequent updates
updateChannel: 'stable',
View genertic-annotation-2.ts
const fillArray = <ArrayElementType>(len: number, elem: ArrayElementType) => {
return new Array<ArrayElementType>(len).fill(elem);
};
const newArray = fillArray<string>(3, 'hi'); // => ['hi', 'hi', 'hi']
newArray.push('bye'); // ✅
newArray.push(true); // ❌ - only strings can be added to the array
View string-enum.ts
enum ThemeColors {
Primary = 'primary',
Secondary = 'secondary',
Dark = 'dark',
DarkSecondary = 'darkSecondary',
};
View optional-annotation.ts
// Optional function parameter
function callMom(message?: string) {
if (!message) {
console.log('Hi mom. Love you. Bye.');
} else {
console.log(message);
}
}
// Interface describing an object containing an optional property
View tuple-annotation.ts
let list: [string, string, number];
list = ['apple', 'banana', 8.75]; // ✅
list = ['apple', true, 8.75]; // ❌ - the second argument should be of type string
list = ['apple', 'banana', 10.33, 3]; // ❌ - the tuple specifies a length of 3, not 4
View intersection-annotation.ts
type Student = {
id: string;
age: number;
};
type Employee = {
companyId: string;
};
let person: Student & Employee;