Skip to content

Instantly share code, notes, and snippets.

View TechplexEngineer's full-sized avatar

Blake Bourque TechplexEngineer

View GitHub Profile
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { check } from 'meteor/check';
import { _ } from 'meteor/underscore';
export const GroupsCollection = new Mongo.Collection('groups');
export const roleperms = {
isUserInGroup(userId, group) {
check(userId, String);
@TechplexEngineer
TechplexEngineer / prefs.json
Created September 11, 2016 12:40
Sublime Dark Theme
{
"color_scheme": "Packages/User/SublimeLinter/Monokai (SL).tmTheme",
"theme": "predawn-DEV.sublime-theme"
}
@TechplexEngineer
TechplexEngineer / CameraThread.java
Created July 16, 2016 12:20
WPI Library USB Camera using a separate thread.
try {
new Thread(new CamThread()).start();
} catch(Exception ex) {
ex.printStackTrace();
}
//Put this in the file as a nested class
class CamThread implements Runnable {
@Override
@TechplexEngineer
TechplexEngineer / pathFor_FlowRouter.js
Created June 11, 2016 20:13
PathFor template helper designed to imitate the functionality of the Iron:Router pathFor helper but using Flow Router in Meteor.
Template.registerHelper('pathFor', function (options) {
var routeName;
if (arguments.length > 1) {
routeName = arguments[0];
options = arguments[1] || {};
}
var opts = options && options.hash;
#! /usr/bin/env python
for x in xrange(1,101):
if x % 3 == 0 and x % 5 == 0:
print('Fizz-Buzz')
elif x % 3 == 0:
print('Fizz')
elif x % 5 == 0:
print('Buzz')
else:
@TechplexEngineer
TechplexEngineer / !Json_Tabifier.md
Last active May 10, 2016 15:37
Given "JSONlike" data this code adds the proper tabs and newlines

Given ugly json like data these programs add the proper tabs and line returns for nice formatting. Based on code https://tools.arantius.com/tabifier

Given input like this(A nested dictionary priettyprinted with pprint in python):

{   'name': '?',
	'path': '?',
	'hostname': 'B1-C1',
	'interfaces': [   {   'hw-id': '00:50:56:b9:76:04',
						  'ip': '10.1.2.1/24',
@TechplexEngineer
TechplexEngineer / Lights.java
Created March 27, 2016 15:30
A class to provide a clean interface to the Adafruit 16 channel PWM driver(PCA9685) for the RoboRIO.
import edu.wpi.first.wpilibj.I2C;
/**
* Lights class to provide clean interface to the Adafruit 16 channel PWM driver(PCA9685) for the RoboRIO.
* @author Techplex (Blake Bourque)
*/
public class Lights {
I2C LightController = new I2C(I2C.Port.kOnboard, 0x40);
private final byte MAX_CHAN = 14;
package edu.wpi.first.smartdashboard.net;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
@TechplexEngineer
TechplexEngineer / automate.py
Created December 18, 2015 19:08
Server automation using paramiko
import paramiko, time
def run_commands(ip_address, user, password, commandList, buff=5000):
print "Configuring " + ip_address
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(ip_address, username=user, password=password)
chan = client.invoke_shell()
import paramiko, time
def run_commands(ip_address, user, password, commandList, platform='', buffer=5000):
""" this function runs the specified commands on the node and returns a
list with unfiltered results.
"""
print "Configuring " + ip_address
remote_conn_pre = paramiko.SSHClient()
remote_conn_pre.set_missing_host_key_policy(paramiko.AutoAddPolicy())
remote_conn_pre.connect(ip_address, username=user, password=password)