Skip to content

Instantly share code, notes, and snippets.

View xunker's full-sized avatar

Matthew Nielsen xunker

View GitHub Profile
@xunker
xunker / slaskstatus.sh
Last active June 26, 2017 17:55
Automatically set your Slack status emoji based on what WiFi network you are connected to
#!/bin/bash
# Originally based on https://gist.github.com/samervin/621fcde93d28346ec5dbab4466b51d45
slacktoken="YOUR_SLACK_TOKEN"
apiurl="https://slack.com/api/users.profile.set?token="$slacktoken"&profile="
# https://stackoverflow.com/questions/4481005/get-wireless-ssid-through-shell-script-on-mac-os-x
# This will probably only work on Mac OS 10.10+.
ssid=$(/usr/sbin/networksetup -getairportnetwork en0 | cut -c 24-)
echo $ssid
if [ "$ssid" = "WORK_NETWORK_NAME" ]; then
@xunker
xunker / n-gon_around_circle.scad
Last active November 8, 2016 23:14
Drawing an N-gon around a circle using OpenSCAD
/*
Drawing an N-gon around a circle using OpenSCAD
https://gist.github.com/xunker/daabf70dbb8e990077d3a1a11d1e06dd
Matthew Nielsen - github.com/xunker
Math credit: http://mathcentral.uregina.ca/QQ/database/QQ.09.06/s/cliff1.html
*/
/* Diameter of the circle around which the n-gon will be built. */
@xunker
xunker / delete_all_from_sender.scpt
Last active January 5, 2025 00:15
Delete all from sender - an Applescript for the Mail.app in Mac OS X that will search for all messages set by the sender of the email message currently open and allow you to delete them all at once.
-- Delete all from sender - https://gist.github.com/xunker/44fa4404c882c27e0ad25857e9470552
-- For the Mail.app in Mac OS X. It will search for all messages set by the sender of the email message currently open,
-- highlight them all and ask if you want to delete them. If you choose "yes" it will delete them for you and then clear
-- the search.
--
-- Important notes:
-- You can load this in Script Editor and then save it as an application so you can run it without Script Editor being open.
-- This does not work when Mail.app is in fullscreen mode; it must be in windowed mode.
-- You will need to enable "Assistive Devices" support for Script Editor (if run there) or for the .app you saved if you converted it to a standalone app.
source ~/.git-prompt.sh
PS1="[\$(date +%H:%M:%S)]\[\033[0;37m\]\[\033[0;32m\]\w\[\033[0;37m\]\$(__git_ps1) \$ "
@xunker
xunker / zipruby_test.rb
Created October 2, 2014 21:46
Compare zipruby memory consumption with others
#!/user/bin/env ruby
#
# Demonstrates memory behaviour with zipruby vs rubyzip vs exec('unzip').
# Tested with mri 1.8.7/1.9.3/2.1.2, zipruby 0.3.6 and rubyzip 1.1.6.
#
# Usage: ruby zipruby_test.rb <test method>
#
# Test methods are:
# read_zipruby read file from zip using zipruby gem
# read_rubyzip read file from zip using rubyzip gem
@xunker
xunker / gist:194aa382ebfd75ce14a3
Last active August 29, 2015 14:02
Ruby/Raspi ping-pong PoC code
require 'pi_piper'
include PiPiper
trigger_pin = PiPiper::Pin.new(pin: 25, direction: :out)
trigger_pin.off
sense_pin = PiPiper::Pin.new(pin: 18, direction: :in)
while true
sense = sense_pin.read
puts sense
@xunker
xunker / life.rb
Last active January 4, 2016 18:39
Bad life
require './drawer'
class Life
def initialize(window_x: 640, window_y: 480)
@window_x = window_x
@window_y = window_y
@cellsize = 8
calcuate_bounds
@xunker
xunker / JSON Parser module code
Last active December 31, 2015 18:22
knktr: Github webhook functions
JSON = (function()
-- -*- coding: utf-8 -*-
--
-- Simple JSON encoding and decoding in pure Lua.
--
-- Copyright 2010-2013 Jeffrey Friedl
-- http://regex.info/blog/
--
-- Latest version: http://regex.info/blog/lua/json
--
@xunker
xunker / first.rb
Created July 5, 2013 17:03
Opal router attempts
require 'opal'
require 'jquery'
require 'opal-jquery'
require 'erb'
require 'vienna'
require 'views/app_view'
require 'views/todo_view'
require 'templates/footer'
@xunker
xunker / borg.rb
Last active December 17, 2015 23:09
borg.rb - an office productivity enhancer for Mac OS only.
voices = %w[Agnes Alex Bruce Bubbles Fred Junior Kathy Princess Ralph Vicki Victoria]
phrases = [
"We are the Borg.",
"Lower your shields and surrender your ships.",
"We will add your biological and technological distinctiveness to our own.",
"Your culture will adapt to service us.",
"Resistance is futile."
]