Skip to content

Instantly share code, notes, and snippets.

💭
(っ◕‿◕)っ

Tony Crowe tcrowe

💭
(っ◕‿◕)っ
Block or report user

Report or block tcrowe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tcrowe
tcrowe / example.ejs
Created Jun 20, 2019
hexo ejs hierarchical categories display
View example.ejs
<%
function displayCategories(parent = undefined) { // start with no parent
site.categories
.find({ parent }) // warehouse allows for complex queries
.sort("name") // sorting .sort("fieldName", 1) ascending or .sort("fieldName", -1) descending
.each(function(category) {
// count the child categories
const childCount = site.categories.find({ parent: category._id }).count();
%>
<li>
@tcrowe
tcrowe / binary-command-exists.zsh
Created Jun 2, 2019
Bash or ZSH: Check if a binary or command exists
View binary-command-exists.zsh
# which goes into dev null
# $? is the magic that tells us if it worked 0 = exists
if [[ `which nvm &>/dev/null && $?` != 0 ]]; then
source ~/.nvm/nvm.sh
fi
@tcrowe
tcrowe / build-electron-exe.zsh
Created Mar 19, 2019
Build electron app for windows using osx
View build-electron-exe.zsh
#!/bin/zsh
# tell electron packager's rcedit.exe to use wine64
export WINE=`which wine64`
export WINEARCH=win64
export WINE_ARCH=win64
# possibly interesting information
# https://wiki.winehq.org/Debug_Channels
# unset WINEDEBUG
@tcrowe
tcrowe / osx-snippet-delete.js
Created Mar 14, 2019
Delete all the snippets in Sublimetext's packages and also the user's installed packages
View osx-snippet-delete.js
/*
⚠️ It does not prompt or ask permission. It just deletes all the snippets!
usage: node osx-snippet-delete.js
*/
const path = require("path");
const {exec} =require("child_process")
@tcrowe
tcrowe / ssh-host-keys.sh
Created Feb 6, 2019
new ssh host keys with "yes" confirmation
View ssh-host-keys.sh
# v--automatic yes
yes | ssh-keygen -q -t ed25519 -N '' -f /etc/ssh/ssh_host_ed25519_key
yes | ssh-keygen -q -t rsa -b 2048 -N '' -f /etc/ssh/ssh_host_rsa_key
# what bits do you want? ---^
@tcrowe
tcrowe / nice-browser-sync.zsh
Last active Feb 8, 2019
a specific and quiet browser-sync
View nice-browser-sync.zsh
#!/bin/zsh
browser-sync start -w --ss dist --port 9924 --host 127.0.0.1 --logLevel error --no-notify --no-open --no-ui --no-online --no-ghost-mode
@tcrowe
tcrowe / telegram-bot.js
Last active Nov 17, 2018
start up a new telegram bot using nodejs
View telegram-bot.js
/*
# the basic echo bot
Instructions:
+ Pops up the docs in the browser
+ npm docs node-telegram-bot-api
+ Install the bot module
+ npm install node-telegram-bot-api
+ Dump in this code into a JS file like ./index.js
@tcrowe
tcrowe / convert-mov-to-gif.sh
Last active Nov 10, 2018
Convert QuickTime MOV to GIF
View convert-mov-to-gif.sh
ffmpeg -i incoming.mov -s 300x200 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --dither > outgoing.gif
# https://github.com/chrisjmendez/convert-mov-to-gif
@tcrowe
tcrowe / webpack.config.js
Created Oct 25, 2018
a decent webpack config with babel and react
View webpack.config.js
/*
# webpack config
npm install webpack webpack-cli uglifyjs-webpack-plugin @babel/core @babel/cli @babel/register @babel/preset-env @babel/preset-react babel-loader react react-dom
https://webpack.js.org
https://webpack.js.org/configuration
*/
@tcrowe
tcrowe / .eslintrc
Last active Nov 20, 2018
.eslintrc with prettier
View .eslintrc
{
"env": {
"es6": true,
"node": true
},
"plugins": ["prettier"],
"extends": [
"eslint:recommended",
"plugin:prettier/recommended"
],
You can’t perform that action at this time.