Skip to content

Instantly share code, notes, and snippets.

View brhoades's full-sized avatar
🐙

Billy Rhoades brhoades

🐙
View GitHub Profile
@brhoades
brhoades / gist:b705433f6708326012cb
Created June 13, 2014 23:13
Source chain smashing w/ linkage
# Now get our other source ids (text ids). Assume these text id's are in order.
tids.uniq.each do |tid|
sent = exec "SELECT wordid,nextwordid FROM chains WHERE textid=$1", tid[1]
sent.flatten!.uniq!.map! { |c| c = c.to_i }
sent.delete sent[-1]
frags << sent
end
Retrieve sour
@brhoades
brhoades / gist:0ff8530c09c38ee6c71b
Created June 16, 2014 19:39
jQuery Embedded Anonymous FUNctions
// ajax get the upvote click
jQuery( document.getElementsByClassName( "up_count" ) ).bind( 'click', function( event ){
jQuery( '#vmp_message' ).empty();
jQuery.ajax( {
url:ajax_object.ajax_url,
method:'get',
dataType:'json',
data:{
action:'count_vote_090813',
@brhoades
brhoades / gist:d9f909c29b1461da7bb8
Created December 4, 2014 02:04
Returns a probability distribution of words
CREATE OR REPLACE FUNCTION somefuncname() RETURNS int LANGUAGE plpgsql AS $$
DECLARE
tmp int;
BEGIN
CREATE TEMP TABLE res AS SELECT id, SUM(count) OVER (ORDER BY id DESC) AS cum_sum FROM chains WHERE wid=## GROUP BY id ORDER BY cum_sum DESC;
tmp := FLOOR(random()*( SELECT max(cum_sum) FROM res LIMIT 1 ));
RETURN (SELECT cum_sum FROM res WHERE cum_sum > tmp ORDER BY cum_sum ASC LIMIT 1 );
END
@brhoades
brhoades / findpalindrome.rb
Last active August 29, 2015 14:25
Find longest palindrome substring, Microsoft Coding Competition 2014 https://github.com/Tomdarling/Microsoft-Competition/tree/master/bin/palindromePhrases
require 'awesome_print'
matchstr = /[[:punct:]]|[[:space:]]|[^[:ascii:]]/
class String
def palindrome?
self == self.reverse
end
end
class Array
@brhoades
brhoades / backuptodropbox.bat
Last active August 29, 2015 14:26
File Backup to Dropbox
@echo off
REM Billy Rhoades
REM 8/3/15
REM Backup script meant for rotations. Please change the variable gamename and run this with the windows scheduling program.
REM This file manually looks for the SavedGames folder in its current directory--- this will fail for anything except lego harry potter.
REM Enables md (mkdir -p equivalent)
setlocal enableextensions
@brhoades
brhoades / soda_dispenser.cpp
Created September 14, 2016 17:47
Soda Dispenser - No functions and I didn't make an array ;D!
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <cstdlib>
#define NUMBER_OF_OPTIONS 3
#define NUMBER_OF_ARGS NUMBER_OF_OPTIONS*2
using namespace std;
class MyHash
def initialize
@keys = []
@values = []
end
def [] index
@keys.each_with_index do |v, i|
if index =~ v
return @values[i]
rm -rf repacked unpacked
mkdir repacked &> /dev/null
mkdir -p unpacked &> /dev/null
for f in $(ls *.gz)
do
newfn=$(echo $f | perl -ne "print /(.+).tar.gz/")
#newdir=$(pwd)/unpacked/$newfn
#mkdir -p $newdir &> /dev/null
tar xvf $f -C unpacked
✘ br046823@M1600801  ~/.nonwork/grader   upstream/fb-inspect-hotfix ± cat assignments/hw1/gradesheet/Dockerfile
FROM ubuntu
MAINTAINER Kimbro Staken
RUN apt-get install -y software-properties-common python
RUN add-apt-repository ppa:chris-lea/node.js
RUN echo "deb http://us.archive.ubuntu.com/ubuntu/ precise universe" >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y nodejs
#RUN apt-get install -y nodejs=0.6.12~dfsg1-1ubuntu1
@brhoades
brhoades / build-test-assignments.sh
Created March 2, 2017 15:30
Build example assignments for grader import (use the default gradesheet).
#!/bin/bash
# Builds example submissions / assignment.yml for use with:
# grader import --kind multiple
if [ -z "$1" ]; then
echo "./build-test-assignments.sh [number of assignments]"
echo " Builds mock assignments for local testing."
exit 0
fi