Skip to content

Instantly share code, notes, and snippets.

View vgmoose's full-sized avatar
🌱
making my way downtown, walking fast

vgmoose vgmoose

🌱
making my way downtown, walking fast
View GitHub Profile
@vgmoose
vgmoose / exclaim.ex
Created August 20, 2015 15:16
outputs an exclamation point in the center of the terminal
# clear the screen
IO.write("\e[3;J\e[H\e[2J")
# get the height and width
h = elem(Integer.parse(elem(System.cmd("tput", ["lines"]),0)),0)
w = elem(Integer.parse(elem(System.cmd("tput", ["cols"]),0)),0)
# get the center of the screen
xmid = round(w/2)
ymid = round(h/2)
cd /hosting/3D-Monopoly/3D-Monopoly/
screen -S monopoly -d -m forever monopolyserver.js
cd /hosting/geochat/
screen -S geochat -d -m forever app.js
cd /hosting/quill-ws/
screen -S quill -d -m forever server.js
import urllib2, urllib
import json
# needs the "Google Maps Geocoding API" enabled for your API key
apikey = "YOUR_API_KEY_HERE"
address = "165 Dascomb Road, Andover, MA".replace(" ", "+")
response = urllib2.urlopen("https://maps.googleapis.com/maps/api/geocode/json?address="+address+"&key="+apikey)
data = json.load(response)["results"][0]["geometry"]["location"]
import sys
count = 0
board = [x[:] for x in [[0]*8]*8]
def drawBoard():
for i in range(0, len(board)):
if(i>0):
sys.stdout.write(" | "+str(i-1))
from Tkinter import *
import time, thread
master = Tk()
master.title("Switch test")
w = Canvas(master, width=200, height=200)
w.pack()
w.create_rectangle(0, 0, 200, 100, fill="white")
import sys
if len(sys.argv) <= 1:
sys.argv.append("/usr/share/dict/words")
f = open(sys.argv[1], "r")
order = "qazwsxedcrfvtgbyhnujmikolp"
for line in f:
import sys
matrix = [[0 for i in range(9)] for j in range(9)]
#m = [list("003020600"),list("900305001"),list("001806400"),list("008102900"),list("700000008"),list("006708200"),list("002609500"),list("800203009"),list("005010300")]
#
#for x in range(0, len(matrix)):
# for y in range(0,len(matrix[0])):
# matrix[x][y] = int(m[x][y])
@vgmoose
vgmoose / gist:5719336
Created June 6, 2013 04:31
convert.py
output = ""
for x in range(0, 9):
line = raw_input()
for y in range(0, 9):
if (line[y] != 0):
output += str(x) + " " + str(y) + " " + line[y]
output += "\n"
output += "0 0 0\n"
require 'net/http'
require 'net/https'
@toSend = '{"currency":"USD","models":[{"toolID":"","modelReference":"model.xml","materialID":"12a65a42-df49-47a9-8828-0efaf84c5509","finishID":"c9c27ce3-eee4-47e4-a896-a9010a7971fd","quantity":1,"xDimMm":24.053077028234622,"yDimMm":24.671680341529406,"zDimMm":9.59760028403155,"volumeCm3":0.27144738160643134,"surfaceCm2":7.8405772975064245}],"shipmentInfo":{"countryCode":"US","stateCode":"NH","city":"Nashua","zipCode":"03063"}}'
uri = URI.parse("https://i.materialise.com/web-api/pricing")
https = Net::HTTP.new(uri.host,uri.port)
https.use_ssl = true
req = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json', 'Accept' => 'json', 'APICode' => '0FE2EF5F-95E3-4552-B637-55B824E3EF35'})
req.body = "#{@toSend}"
@vgmoose
vgmoose / gist:6478345
Created September 7, 2013 19:08
accepts <foo<bar> input as valid html and doesn't throw malformed start tag
def check_for_whole_start_tag(self, i):
rawdata = self.rawdata
locatestarttagend = re.compile(r"""
<[a-zA-Z][-.a-zA-Z0-9:_]* # tag name
(?:\s+ # whitespace before attribute name
(?:[a-zA-Z_][-.:a-zA-Z0-9_]* # attribute name
(?:\s*=\s* # value indicator
(?:'[^']*' # LITA-enclosed value
|\"[^\"]*\" # LIT-enclosed value
|[^'\">\s]+ # bare value