Skip to content

Instantly share code, notes, and snippets.

@hum-n
hum-n / Civic.terminal
Last active September 3, 2024 20:57
macOS Terminal theme based on Civic Xcode 8 theme (WWDC 2016 colors)
<?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>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NPECcw
LjE0NTA5ODAzOTIgMC4xNDkwMTk2MDc4IDAuMTg4MjM1Mjk0MQAQAYAC0hAREhNaJGNs
YXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFyY2hp
{
"name": "create-yourproject",
"version": "1.0.0",
"main": "index.js",
"bin": {
"yourproject": "index.js"
}
}
#!/usr/bin/env node
console.log('Nice try!');
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('What’s the name of your project? ', (answer) => {
console.log(`Let’s start ${answer}.`);
rl.close();
let name = process.argv[2];
if (name) {
console.log(`Let’s start ${name}.`);
}
const { spawnSync } = require('child_process');
function run(cmd, args) {
return spawnSync(cmd, args, { stdio: 'inherit' });
}
function clone(dest) {
const cmd = run('git', ['clone', '--depth=1', url, dest]);
if (cmd.status == 0) {
function install(dest) {
run('npm', ['install', '--prefix', dest]);
}
const styles = {
black: '\x1b[30m',
red: '\x1b[31m',
green: '\x1b[32m',
yellow: '\x1b[33m',
blue: '\x1b[34m',
magenta: '\x1b[35m',
cyan: '\x1b[36m',
white: '\x1b[37m',
@hum-n
hum-n / keys-values_loop.js
Last active October 17, 2020 16:25
Keys and values JavaScript object loop.
Object.entries(obj).forEach(([key, val]) => {
console.log(key);
console.log(val);
});
@hum-n
hum-n / keys_loop.js
Created October 17, 2020 16:28
Keys JavaScript object loop.
Object.keys(obj).forEach(key => {
console.log(key);
console.log(obj[key]); // value
});