Skip to content

Instantly share code, notes, and snippets.

Avatar
🦅
microservice party

Daniel Pritchett ⚡ dpritchett

🦅
microservice party
View GitHub Profile
View alligator.coffee
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
View 1) original todos.js
Todos.Task = SC.Record.extend(
/** @scope Todos.Task.prototype */ {
isDone: SC.Record.attr(Boolean),
description: SC.Record.attr(String),
}) ;
View find coffee files.txt
~/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
View unc_example.py
#! /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)
View split to dict.py
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 Nov 8, 2010
Download a file using python
View get_file_from_web.py
"""
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 Nov 15, 2010
Draw a polygon with an arbitrary number of sides using turtle graphics
View drawPolygon.py
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 Nov 17, 2010
find users named 'wes' in your AD
View active_directory_search.py
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 Nov 17, 2010
Use this as a cron job maybe?
View search_fatwallet.py
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 Nov 17, 2010
Parse out the squinkies on ebay that are almost expired
View ebay_squinkies_timeleft.py
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), \