Skip to content

Instantly share code, notes, and snippets.

View jgentes's full-sized avatar
🎯
Crushing it

James Gentes jgentes

🎯
Crushing it
View GitHub Profile
@jgentes
jgentes / $profile
Last active March 29, 2024 00:28
powershell autocomplete
Import-Module posh-git
Set-PSReadlineKeyHandler -Key Tab -Function Complete
Set-PSReadLineKeyHandler -Chord "Tab" -Function AcceptSuggestion
Set-PSReadLineKeyHandler -Chord "RightArrow" -Function ForwardWord
@jgentes
jgentes / multisync
Created June 21, 2023 03:26
archive multisync logic
play: async (trackId?: Track['id']) => {
let tracks
if (!trackId) {
// pull players from audioState to play all
;[tracks] = getAudioState()
tracks = Object.keys(tracks) as Track['id'][]
} else tracks = [trackId]
for (const trackId of tracks) {
if (trackId) setAudioState[trackId as number].playing(true)
// Type User can have an ID which is either a number or a string
type User<CustomType extends number | string> = {
id: CustomType
name?: string
age?: number
}
// In this case, we define CustomType as a string
let myUser: User<string> = {
id: '1234-1234-1234',

// Type User can have an ID which is either a number or a string type User<CustomType extends (number | string)> = { id: CustomType, name?: string, age?: number }

// In this case, we define CustomType as a string let myUser:User = { id: "1234-1234-1234",

@jgentes
jgentes / type definition from array.ts
Created October 31, 2022 13:45
Quickly define the values needed in an array and use that array as a type definition
const arrayOfStringLiterals = ['a', 'b', 'c'] as const
type TypeArrayOfStringLiterals = typeof arrayOfStringLiterals[number]
@jgentes
jgentes / gist:c59f24f2dd54dcb29c13dc1ac12c1f7f
Created July 22, 2020 22:22
Powershell script to fix Windows 10 WSL2 port forwarding problem
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
if( $found ){
$remoteport = $matches[0];
} else{
echo "The Script Exited, the ip address of WSL 2 cannot be found";
exit;
}
@jgentes
jgentes / .bashrc
Created July 10, 2020 17:52
Automatically start MSQL in WSL2
export MYSQLPID=$(pidof mysqld)
if [ -z $MYSQLPID ]; then sudo service mysql start; fi
@jgentes
jgentes / gist:1b1cd850be43d10b8106579aef2ce78b
Created December 12, 2018 15:57
my bash color console
export PS1='\[\033[0;36m\] \w\[\033[0;32m\] - [$(git branch 2>/dev/null | grep "^*" | colrm 1 2)\[\033[0;32m\]]\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\]\[\033[0m\] '
@jgentes
jgentes / docker-compose.yml
Created April 5, 2018 17:00
Failing docker-compose for resin
---
version: '2'
services:
sidekick:
restart: always
privileged: true
build:
args:
GIT_KEY: abcd
image: ./sidekick
@jgentes
jgentes / index.html
Created April 23, 2013 02:56
A CodePen by James Gentes. iOS 6 style switches with pure CSS - Courtesy the awesome Lea Verou @ http://lea.verou.me/2013/03/ios-6-switch-style-checkboxes-with-pure-css/
<h1>iOS 6 style switches with pure CSS</h1>
<label>Something <input type="checkbox" class="ios-switch" /></label>
<label>Pre-checked<input type="checkbox" class="ios-switch" checked /></label>
<label><input type="checkbox" class="ios-switch" />Label after control</label>
<label><input type="checkbox" class="ios-switch" checked />Another label after control</label>
<p>Check out the slide animation, even in WebKit versions that don’t support animation for pseudo-elements.
Verified to work in <strong>Chrome, Firefox, IE10</strong>, but could possibly work in many others.</p>