Skip to content

Instantly share code, notes, and snippets.

View slpsys's full-sized avatar
💭
💯

Marc Bollinger slpsys

💭
💯
View GitHub Profile
@slpsys
slpsys / Fuuuuuu-
Created April 22, 2011 00:43
fuuuuuuu-mysql.sql
-- This is T-SQL (SQL Server). This demonstrates two things MySQL can't do that I just ran into.
DECLARE @a TABLE
(
id int
)
DECLARE @b TABLE
(
id int,
name nvarchar(10),
fid int
public static DateTime today = DateTime.Today,
yesterday = today.AddDays(-1),
twoDaysAgo = yesterday.AddDays(-1),
threeDaysAgo = twoDaysAgo.AddDays(-1),
tomorrow = today.AddDays(1),
dayAfterTomorrow = tomorrow.AddDays(1),
twoDaysAfterTomorrow = dayAfterTomorrow.AddDays(1),
friday = today.AddDays((5 + 7 - (int)today.DayOfWeek) % 7), // http://www.imdb.com/title/tt0113118/
nextFriday = friday.AddDays(7), // http://www.imdb.com/title/tt0195945/
fridayAfterNext = friday.AddDays(7); // http://www.imdb.com/title/tt0293815/
@slpsys
slpsys / xignite-savon.rb
Created May 3, 2011 23:52 — forked from stw/gist:953289
Soap service test
#!/usr/bin/env ruby
require 'rubygems'
require 'savon'
require 'pp'
url = "http://www.xignite.com/xFinancials.asmx?WSDL"
client = Savon::Client.new(url)
response = client.request :get_other_ratios do
class Stuff:
dict = {}
def __getattr__(self, key):
if not key:
return self
elif self.dict.has_key(key):
return self.dict[key]
raise AttributeError,key
def __setitem__(self, key, value):
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));
@slpsys
slpsys / marcov.txt
Created September 27, 2015 16:19
marcov
"Pretty stoked on Gmail. Now I (Hate) New plans"
"Dominic Fernow's dad fronting New App to most conferences = fancy pirate hat hat?"
"#seapunk is the Console wizard's "Add a large American Life Choice""
"CSS is Google bus before coffee. And _that_ comfortable."
"Pro Tip: Blacklist coworkers."
"null objects don't want a webserver."
"Seems like sludge metal"
"Keep trollin' trollin' trollin' trollin' trollin' trollin' trollin' trollin' trollin' trollin' trollin' trollin' trollin' trollin' trollin'"
"I be to get rid of Emergency & Poor's."
"Editor's note: there was pitiful, in Ohio."
@slpsys
slpsys / tweet_harvest.rb
Created September 27, 2015 17:43
Tweet Harvest: Twitter User Data Dump-to-one-semi-clean-tweet-per-line file
require 'json'
fo = File.open('/tmp/tweetstorm.txt','w')
Dir['./data/js/tweets/*.js'].each do |file|
begin
fh = File.open(file)
data = fh.read
# My Twitter dump had a first line that assigns the JSON data to a variable,
# the rest was valid JSON. Example:
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')