Skip to content

Instantly share code, notes, and snippets.

View dpritchett's full-sized avatar
🦅
microservice party

Daniel Pritchett ⚡ dpritchett

🦅
microservice party
View GitHub Profile
SSJSWriter (str, request, response, file, lastMod, sessionId) ->
parsedTextArray = []
externalParsedTextArray = []
startTag = globalSettings.server_script.begin
startWriteAddition = globalSettings.server_script.write
startGlobalAddition = globalSettings.server_script.global
endTag = globalSettings.server_script.end
lineArray = str.split(new RegExp( "\n", "g" ))
isInScript = no
Todos.Task = SC.Record.extend(
/** @scope Todos.Task.prototype */ {
isDone: SC.Record.attr(Boolean),
description: SC.Record.attr(String),
}) ;
~/myapps/todos$ find | grep coffee$
./apps/todos/fixtures/task.coffee
./apps/todos/main.coffee
./apps/todos/models/task.coffee
./apps/todos/resources/main_page.coffee
#! /usr/bin/env ipy
import os
folder = r'\\s02axiprod02\events'
for (path, dirs, files) in os.walk(folder):
for file in files:
print os.path.join(path, file)
myVal = r'input="lolwut"'
myVal = myVal.split('=')
myVal[1] = myVal[1].replace('"', '') #remove doublequote
myDict = {}
myDict.update({ myVal[0]: myVal[1] })
print myDict.get('input')
# prints lolwut
@dpritchett
dpritchett / get_file_from_web.py
Created November 8, 2010 22:56
Download a file using python
"""
See the python docs for more on file writes:
http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files
"""
import urllib
img = urllib.urlopen(r'http://www.google.com/logos/2010/xraydiscovery2010-res.gif')
f = open ('/pythonwrite.gif', 'wb') # wb = binary write mode
@dpritchett
dpritchett / drawPolygon.py
Created November 15, 2010 16:33
Draw a polygon with an arbitrary number of sides using turtle graphics
import turtle
def drawPolygon(sides, fillcolor='DarkOliveGreen'):
init pen
turtle.reset()
turtle.fillcolor(fillcolor)
turtle.fill(True)
#draw a shape
degree = 360.0 / sides
@dpritchett
dpritchett / active_directory_search.py
Created November 17, 2010 16:14
find users named 'wes' in your AD
import clr
clr.AddReference('System.DirectoryServices')
from System.DirectoryServices import (
DirectorySearcher,
DirectoryEntry
)
filter = "(&(objectCategory=person)(objectClass=user)(givenName=wes*))"
@dpritchett
dpritchett / search_fatwallet.py
Created November 17, 2010 22:07
Use this as a cron job maybe?
import feedparser, re #feedparser available at http://feedparser.org/
def search_fatwallet(keyword):
fw = feedparser.parse(r'http://feeds.feedburner.com/FatwalletHotDeals')
for entry in fw.entries:
if re.search(keyword, entry['title']):
print entry['title'], '\n', entry['feedburner_origlink']
print ''
"""
>>> search_fatwallet('car')
@dpritchett
dpritchett / ebay_squinkies_timeleft.py
Created November 17, 2010 23:02
Parse out the squinkies on ebay that are almost expired
import time, datetime, feedparser
ebay = feedparser.parse(r'http://shop.ebay.com/i.html?rt=nc&_nkw=squinkies&_rss=1')
def timeleft(in_time):
then = int(in_time[:-3])
now = int(time.time())
delta = then - now
#print time.gmtime(then) #sanity debug
return ' '.join([str(delta / 3600), "hours", str((delta % 3600) / 60), \