Skip to content

Instantly share code, notes, and snippets.

View slpsys's full-sized avatar
💭
💯

Marc Bollinger slpsys

💭
💯
View GitHub Profile
len_a=`head -n 4 a | wc | awk '{print $3}'` && len_b=`head -n 4 b | wc | awk '{print $3}'`; cmp a b -n `[ $len_a -gt $len_b ] && echo $len_a || echo $len_b`
@slpsys
slpsys / enum.cs
Created May 9, 2011 18:43
Filtering enum values by a set of strings we want to display, with full type information.
// Some enum, could be RateFamilyTypes
enum Letters { A, B, C}
void Main()
{
// List of stringified subset of enum values; could be sourced from XAML
HashSet<string> filterList = new HashSet<string>() { "B" };
// Get as typesafe array of enum values (allLetters is an array of Letters)
var letterArray = Enum.GetValues(typeof(Letters));
I am going to give a short talk on the software architecture of Memcached
during a workshop [1] I attend next week.
As far as I understand, Memcached architecture is simple + sweet: Libevent
+ Hashing + Slab allocator. But I haven't even looked at the code yet.
Does anyone have a UML diagram of Memcached or something similar ready I
could use in my slides next Wednesday? Or any other tips for me?
Thank you all a lot in advance!
def _postToZendesk(self, text, originalMsg):
try:
url = 'http://xignite.zendesk.com/tickets/%s.xml' % (text)
body = self._getZendeskMessage(originalMsg)
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password('Web Password', url,'username', 'password')
opener = urllib2.build_opener(auth_handler)
request = urllib2.Request(url, data=body)
request.add_header('Content-Type', 'application/xml')
@slpsys
slpsys / mysql_annoyances.sql
Created March 8, 2012 00:57
Herein I chronicle things that piss me off.
# Why do
DATE_DIFF('2012-3-1', '2012-3-2')
# and
DATE_ADD('2012-3-1', INTERVAL 1 DAY)
# have different naming conventions?
# this returns [0, n]
select count(*), datediff(`a`,`b`) from `table` group by datediff(`a`,`b`)
# this returns n - k, k > 0
// Axis2 does not handle .NET's WSDL serialized of enums very much.
AdjustmentMethods adj = AdjustmentMethods.Factory.create();
AdjustmentMethods_type0[] adjInnerTypes = new AdjustmentMethods_type0[1];
adjInnerTypes[0] = AdjustmentMethods_type0.Factory.fromString(AdjustmentMethods_type0._SplitOnly, SERVICE_URI);
adj.setAdjustmentMethods_type0(adjInnerTypes);
getQuotesArguments.setAdjustmentMethod(adj);
@slpsys
slpsys / marketing.txt
Created June 7, 2012 20:48
THIS IS THE WORST IDEA EVER, DO NOT EVER DO THIS
Method One - Visitor Retargeting
1) tons of websites have extra banner placements available.
2) retargeting companies buy those under-impressed locations at a discount.
3) visitors come to the site and are tagged/cookied with the retargeting codes.
4) tagged visitors leave[the site] and randomly surf the web.
5) tagged visitor come across one of the banner locations owned by the retargeting companies.
6) [Our] banner is displayed to the tagged visitor, frequently bringing them back to our site.
@slpsys
slpsys / euclids.py
Created July 8, 2012 19:52
I don't know enough about python yet to tell if this looks as bad as I think it does. Edit: It's terrible!
import recommendations as rec
from itertools import product
from math import sqrt
# Going through the exercises in: http://shop.oreilly.com/product/9780596529321.do
def all_euclideans(fileName):
key = "critics"
recdb = rec.read(fileName)
criticKeys = recdb[key].keys()
<outline title=".Net General" text=".Net General">
<outline text="Ayende @ Rahien" title="Ayende @ Rahien" type="rss" xmlUrl="http://feeds.feedburner.com/AyendeRahien" htmlUrl="http://ayende.com/blog/"/>
<outline text="BCL Team Blog" title="BCL Team Blog" type="rss" xmlUrl="http://blogs.msdn.com/bclteam/rss.xml" htmlUrl="http://blogs.msdn.com/b/bclteam/"/>
<outline text="Coding Horror" title="Coding Horror" type="rss" xmlUrl="http://feeds.feedburner.com/codinghorror" htmlUrl="http://www.codinghorror.com/blog/"/>
<outline text="Dare Obasanjo aka Carnage4Life" title="Dare Obasanjo aka Carnage4Life" type="rss" xmlUrl="http://feeds.feedburner.com/Carnage4Life" htmlUrl="http://www.25hoursaday.com/weblog/"/>
<outline text="Elegant Code" title="Elegant Code" type="rss" xmlUrl="http://elegantcode.com/feed/" htmlUrl="http://elegantcode.com"/>
<outline text="Fabulous Adventures In Coding" title="Fabulous Adventures In Coding" type="rss" xmlUrl="http://blogs.msdn.com/ericlippert/rss.xml" htmlUrl="http://blogs.msdn.com/b
@slpsys
slpsys / sf_recs.md
Created July 23, 2012 00:34
Marc's SF recommendations (off the top of my head)

things to see/do

  • musée mechanique
  • if you're in the financial district, check out the old pacific stock exchange (pre-hipster fixie movie Quicksilver with Kevin Bacon was filmed here!) it is now a gym. chuckle at that thought.
  • buena vista cafe (ridiculous irish coffee, get bombed so you can handle tourists)
  • sfmoma de young/park/beach/cal academy
  • twin peaks
  • walk around SOMA, where most startups live; majority are in square bounded by [Market, 1st, Folsom, 3rd]
  • do not walk around where new Twitter HQ will be; you will step on human feces, and it is next to one of the biggest peepshow theaters