Skip to content

Instantly share code, notes, and snippets.

View jshbrntt's full-sized avatar
🏠
Working from home

Joshua Barnett jshbrntt

🏠
Working from home
View GitHub Profile
@HiImJulien
HiImJulien / clang_windows_cross.cmake
Created March 21, 2020 18:45
Toolchain file to cross-compile from clang (WSL-Ubuntu) to Windows.
# Cross toolchain configuration for using clang-cl.
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_VERSION 10.0)
set(CMAKE_SYSTEM_PROCESSOR AMD64)
set(CMAKE_C_COMPILER "/usr/bin/clang-cl-9")
set(CMAKE_CXX_COMPILER "/usr/bin/clang-cl-9")
set(CMAKE_LINKER "/usr/bin/lld-link-9")
@ernsheong
ernsheong / access-mac-localhost-from-parallels-desktop-ie-edge.md
Last active January 24, 2024 00:30
Accessing macOS localhost from Parallels Desktop IE or Edge

Access macOS localhost from IE or Edge within Parallels Desktop

This issue is so infuriating that I'm going to take some time to write about it.

  1. MOST IMPORTANT. Your local development server must be bound to IP address 0.0.0.0. Some do this by default, but many don't. You need to make sure that you run your local server with correct IP bindings. You may need to provide additional flags to your serve commands e.g. polymer serve --hostname domain.local, hugo serve --bind 0.0.0.0. If you use a named domain like domain.local, it has to be defined in /etc/hosts and pointing at 0.0.0.0.

  2. My Parallels setting is using Shared Network, nothing special there.

  3. Open macOS Terminal and type ifconfig. Look for the value under vnic0 > inet. It is typically 10.211.55.2.

Sierpinski Triangle Explorer

The exercise is to create a Sierpinski Triangle Explorer. A single page app written in JavaScript and HTML that draws a Sierpinski Triangle.

The wikipedia page (http://en.wikipedia.org/wiki/Sierpinski_triangle) should provide enough detail on how it’s drawn.

The app should support:

  • zooming in and out
  • panning
@DarrenN
DarrenN / get-npm-package-version
Last active April 17, 2024 16:57 — forked from yvele/get-npm-package-version.sh
Extract version from package.json (NPM) using bash / shell
# Version key/value should be on his own line
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
echo $PACKAGE_VERSION
@jshbrntt
jshbrntt / videos2web.sh
Last active December 28, 2021 21:41
Script to convert videos to web compatible formats.
#!/bin/bash
printf "\e[1;36m\n\
_ _ ____ _ \n\
__ _(_) __| | ___ ___ ___|___ \__ _____| |__ \n\
\ \ / / |/ _\` |/ _ \/ _ \/ __| __) \ \ /\ / / _ \ '_ \ \n\
\ V /| | (_| | __/ (_) \__ \/ __/ \ V V / __/ |_) | \n\
\_/ |_|\__,_|\___|\___/|___/_____| \_/\_/ \___|_.__/ \n\
https://gist.github.com/joshua-barnett/0764f654ba992b663ee9\n\
Usage: \n\
$ ./videos2web.sh input_directory/ output_directory \e[m\\n"
@joshblack
joshblack / watchify-reactify-gulp.js
Created November 20, 2014 03:00
Gulpfile for doing watchify builds with the react transformer all hooked up to browser sync.
var gulp = require('gulp');
var util = require('gulp-util');
var watchify = require('watchify');
var reactify = require('reactify');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
@jshbrntt
jshbrntt / flac-to-mp3.bat
Last active November 6, 2019 09:33
Batch file to convert folder of .flac files to .mp3 using ffmpeg.
@ECHO OFF
FOR %%f IN (*.flac) DO (
echo Converting: %%f
ffmpeg -i "%%f" -ab 320k -map_metadata 0 "%%~nf.mp3"
)
echo Finished
PAUSE
@jshbrntt
jshbrntt / post-commit
Created February 24, 2014 17:20
Hook for writing latest repository short-hash to text file.
#!/bin/sh
rm www/version.txt -i
cat /dev/null > www/version.txt
git rev-parse --short HEAD >> www/version.txt
git add www/version.txt
@lizhiwei
lizhiwei / send_file_partial.py
Created December 10, 2013 04:20
HTTP 206 (Partial Content) For Flask
import mimetypes
import os
import re
from flask import request, send_file, Response
@app.after_request
def after_request(response):
response.headers.add('Accept-Ranges', 'bytes')
return response
@jimothyGator
jimothyGator / README.md
Last active April 25, 2024 18:00
Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
mkdir -p /usr/local/etc/nginx/sites-{enabled,available}
cd /usr/local/etc/nginx/sites-enabled
ln -s ../sites-available/default.conf
ln -s ../sites-available/default-ssl.conf

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default.conf and default-ssl.conf to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/