This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |