Skip to content

Instantly share code, notes, and snippets.

View dkebler's full-sized avatar

David Kebler dkebler

  • We Also Walk Dogs
  • Oregon, US
View GitHub Profile
@dkebler
dkebler / gulp-node-sass-bower
Last active August 29, 2015 14:20
Getting Gulp to find sass @imports within bower packages - node-sass
// Assumes you are using node-sass. Sadly this is not an automated solution.
// You have to know where the scss of each bower package is located
// if you add a package you'll have to add another config.bowerDir + '/path/to/package/scss/' to the sass task.
// some package scss have more @import lines to other scss so be sure to add those paths as well (like with foundation)
var gulp = require('gulp');
// Include Our Plugins
var sass = require('gulp-sass');
@dkebler
dkebler / Git push deployment in 7 easy steps.md
Last active October 6, 2015 04:16 — forked from thomasfr/Git push deployment in 7 easy steps.md
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
@dkebler
dkebler / registers_MCP23017.cson
Created December 8, 2016 03:12
MCP23017 Register Code Database as cson file
# ww1.microchip.com/downloads/en/DeviceDoc/21952b.pdf
# see table 1.6 and details in sections 1.6.x following
# follow with two bytes to set both banks/ports A and B
# adding 1 to value will address bank/port B with a single byte, as long as bit 7 of IOCON = 0
registers: [
{
name:'IODIR'
alias:'DIRECTION'
value: 0x00
desc: 'When a bit is set, the corresponding pin becomes an input. When a bit is clear, the corresponding pin becomes an output.'
@dkebler
dkebler / get_latest_release.sh
Created December 4, 2017 18:37 — forked from lukechilds/get_latest_release.sh
Shell - Get latest release from GitHub
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Usage
# $ get_latest_release "creationix/nvm"
# v0.31.4
@dkebler
dkebler / store-starter.js
Last active September 23, 2021 16:04
Vue dynamic/reactive nested/deep property setting and getting with vuex store
import Vue from 'vue'
import Vuex from 'vuex'
import { setProp, getProp } from 'vue-properties'
import traverse from 'traverse'
import isPlainObj from 'is-plain-object'
Vue.use(Vuex)
const store = new Vuex.Store({
state: {
@dkebler
dkebler / homeassistant.js
Created July 29, 2019 03:09
Access home assistant websocket api via nodej client and long lasting token
import to from 'await-to-js'
import ha from 'home-assistant-js-websocket'
import WebSocket from 'ws'
import { EventEmitter } from 'events'
import ndb from 'debug'
const debug = ndb('home-assistant:ws')
const MSG_TYPE_AUTH_REQUIRED = 'auth_required'
const MSG_TYPE_AUTH_INVALID = 'auth_invalid'
const MSG_TYPE_AUTH_OK = 'auth_ok'
@dkebler
dkebler / rock64shrink.sh
Last active March 4, 2023 22:45
Bash Script for Shrinking/Truncating a disk image
#!/bin/bash
# WARNING this script could easily trash a image or worse a device. DO NOT USE IT WITH A DEVICE
# It will make a copy of the image to work on by default unless you use the -o option
# which you should NOT unless your image is much bigger than >16GB
# In other words test it on a disk image file that could be damaged.
# Use the -h option to see list of options
# You MUST use -t to do the last step truncation
const net = require("net"), fs = require("fs"), remote_server = process.argv[2];
let socket;
socket = remote_server ? net.connect(8000, remote_server) : net.connect(8000);
let ostream = fs.createWriteStream("./receiver/SC-02.pdf");
let date = new Date(), size = 0, elapsed;
socket.on('data', chunk => {
size += chunk.length;
elapsed = new Date() - date;
const net = require("net"), fs = require("fs");
let server, istream = fs.createReadStream("./sender/SC-02.pdf");
server = net.createServer(socket => {
socket.pipe(process.stdout);
istream.on("readable", function () {
let data;
while (data = this.read()) {
@dkebler
dkebler / hugo-update.sh
Created September 26, 2020 16:20
Hugo Release Update Script - supports extended version
#!/bin/bash
# Version 0.21.0 8:26 PST, Nov 9, 2018
# inspried from this forum post https://discourse.gohugo.io/t/script-to-install-latest-hugo-release-on-macos-and-ubuntu/14774/10
# if you have run into github api anonymous access limits which happens during debugging/dev then add user and token here or sourced from a separate file
# . ~/githubapitoken
#GITHUB_USER=""
#GITHUB_TOKEN=""
if [ "$GITHUB_TOKEN" != "" ]; then
echo using access token with script