- Install the ESLint extension in VSCode.
- This actually parses the Javascript you write and applies syntax and semantic rules.
- Install the Prettier code formatter extension in VSCode.
- All this does is format the code you've written to look nice. No syntax checking or parsing of your Javascript. If you don't install this, you'll still get all the benefits of linting and VSCode's built-in formatter.
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
#!/bin/bash | |
ps -u $(whoami) -x -o comm | egrep -o '/Applications/([A-z0-9 ]+/)?[A-z0-9 ]+\.app' | sort -u | egrep -o '[A-z0-9 ]+\.app' | awk '{if (NR!=0) {print substr($0, 1, length($0) - 4)}}' |
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
public class CenteredJFrame { | |
public static void main(String[] args) { | |
JFrame frame = new JFrame(); | |
center(frame, 800, 600); | |
frame.add(new JButton("Bananas")); | |
frame.add(new JButton("Oranges")); | |
frame.add(new JButton("Apples")); | |
frame.setVisible(true); | |
} |
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
function getURLFileExtension(url) { | |
if (url && url.length > 0) { | |
let results = url.match(/(?:[\d\w]+\.[\d\w]+)(?:\/.+)\.([^/]*)$/); | |
if (results && results.length == 2) { | |
return results[1]; | |
} | |
} | |
return undefined | |
} |
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
/** | |
* | |
* @param {string} letter the string representation of the grade. Examples: ["a-", "A", "F", "b+"] | |
* @param {number} points the number of points that an perfect A represents on the scale | |
* @param {number} inc the number of points in between each full letter grade | |
*/ | |
function grade(letter = "", points = 4, inc = 1) { | |
if (letter.length < 1 || letter.length > 2) { | |
throw 'the length of the letter grade string must be equal to 1 or 2' | |
} |
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
#!/usr/local/bin/bash | |
osascript -e 'tell app "System Events" to tell appearance preferences to set dark mode to not dark mode' |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>URL</key> | |
<string>http://example.com</string> | |
</dict> | |
</plist> |
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
#!/usr/bin/env node | |
const fs = require('fs'); | |
const path = require('path'); | |
const tweetCSVFile = path.resolve(__dirname, '../all_tweets_classified.csv'); | |
const outFile = path.resolve(__dirname, '../all_tweets_classified.json'); | |
const [header, rows] = parseCSV(tweetCSVFile); | |
const jsonData = csvToJson([header, rows], { | |
msg_id: String, |
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
function gcz() { | |
if [[ -z $1 ]]; then | |
git checkout $(gb | fzf | tr -d ' *') | |
else | |
git checkout $(gb | fzf -1 -q $1 | tr -d ' *') | |
fi | |
} |
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
function render(template: string, data: any, brackets = ['{{', '}}']) { | |
const output: string[] = []; | |
const [left, right] = | |
brackets.length > 1 ? brackets : [...brackets, ...brackets]; | |
let pos = 0; | |
while (pos < template.length) { | |
const start = template.indexOf(left, pos); | |
if (start < 0) break; |
OlderNewer