Skip to content

Instantly share code, notes, and snippets.

View newfurniturey's full-sized avatar
🥞
oh hai =]

Joey Fowler newfurniturey

🥞
oh hai =]
View GitHub Profile
function Get-PublicKey
{
[OutputType([byte[]])]
PARAM (
[Uri]$Uri
)
if (-Not ($uri.Scheme -eq "https"))
{
Write-Error "You can only get keys for https addresses"
alert('hi mom =]');
@newfurniturey
newfurniturey / .bashrc
Created July 23, 2017 12:49
Simple local/remote git branch deletion alias
git-delete-func() {
# do basic pattern matching to prevent command injection (or mistakes)...
# note: this pattern is just a character-set based on my standard branches - it could be better =P
pattern="a-zA-Z0-9/._-"
if [[ $1 =~ [^$pattern] ]]; then
echo -e "invalid branch pattern\n";
return 1;
fi;
# verify the branch exists
@newfurniturey
newfurniturey / Dispatcher.java
Last active August 29, 2015 14:18
Sample ScheduledExecutorService
// create a new thread pool service with 6 threads
ScheduledExecutorService service = Executors.newScheduledThreadPool(6);
// iterate over your list of trains
for (Train train : trainList) {
// determine how long of a delay between the current station and the next
int delay = ...;
// schedule the future service
ScheduledFuture future = service.schedule(new DispatchTask(train), delay, TimeUnit.SECONDS);
@newfurniturey
newfurniturey / gist:a281d0366ccb594aec33
Created June 15, 2014 12:49
C - Alphabet permutations without arrays or recursion
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
int main() {
int string_len = 4;
char alphabet[] = "abc";
int alphabet_len = ((sizeof(alphabet) / sizeof(alphabet[0])) - 1);
@newfurniturey
newfurniturey / gist:0063c9580553226ab36a
Created June 14, 2014 21:01
Alphabet permutations without arrays or recursion
<?php
$string_len = 5;
$alphabet = 'abc';
$alphabet_len = strlen($alphabet);
for ($s = 1; $s <= $string_len; $s++) {
$current_key = str_repeat($alphabet[0], $s);
@newfurniturey
newfurniturey / gist:19d263757a392c1c98c5
Created June 4, 2014 01:44
microcorruption - print executing instructions
// event used to submit the form
var keydownEvent = $.Event('keydown', { which: 13 });
// input field that takes user-instructions
var $entry = $('#textentry');
// text blocks that we're interested in
var executingBytes = document.getElementById('insnbytes');
var decodedBytes = document.getElementById('insndecoded');
@newfurniturey
newfurniturey / gist:9914369
Created April 1, 2014 13:51
StackOverflow Unicoin auto-mine
function getMoarCoins() {
var randDelay = Math.floor((Math.random() * 10) + 1) * 1000;
$.get('/unicoin/rock').done(function (e) {
setTimeout(function() {
var rockId = e.rock;
$.post('/unicoin/mine?rock=' + rockId, {fkey: StackExchange.options.user.fkey}).done(function (t) {
if (t.result !== 'Success') {
console.log('Failed to mine rock ' + rockId);
} else {
console.log('Mined rock ' + rockId + ' for ' + t.value + ' coins with a ' + (randDelay / 1000) + ' second delay!');