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
# From "Real-Time Cooperative Editing Systems", Chengzheng Sun et al. | |
import copy | |
def generic_operation_transform(new_op, HB): | |
""" | |
:param new_op: operation to be transformed | |
:param HB: history buffer | |
""" | |
# index of independent ops |
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
import json | |
import sqlalchemy.types | |
class JSONType(sqlalchemy.types.PickleType): | |
"""An example | |
>>> class User(declarative_base): | |
... friends = Column(JSONType()) | |
... |
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
import json | |
import sqlalchemy.types | |
class JSONType(sqlalchemy.types.PickleType): | |
"""An example | |
>>> class User(declarative_base): | |
... friends = Column(JSONType()) | |
... |
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
<a href="javascript:var curp = 'id(\'current-entry\')'; var titlep = curp + '//h2[@class=\'entry-title\']/text()'; var hostp = curp + '//span[@class=\'entry-source-title\']/text()'; var urlp = curp + '//a[@class=\'entry-original\']/@href'; function xpath(x) { var r; try { r=document.evaluate(x,document,null,0,null); switch(r.resultType) { case 1:r=r.numberValue;break; case 2:r=r.stringValue;break; case 3:r=r.booleanValue;break; case 4:var n=r,r=[],e;while(e=n.iterateNext())r.push(e);break; } } catch(ex){r=ex.message;} return r; } function parse() { var text = xpath(titlep)[0].nodeValue; text += '\nfrom '+xpath(hostp)[0].nodeValue; text += '\n['+xpath(urlp)[0].nodeValue+']'; alert(text); } parse();">Current Article</a> |
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
irb(main):001:0> require 'open-uri' | |
=> true | |
irb(main):002:0> require 'nokogiri' | |
=> true | |
irb(main):003:0> f = open('http://211.254.102.90/web').read | |
=> "<html><head><title>\xBB\xF5\xB7\xCE\xBF\xEE \xBC\xBC\xBB\xF3\xC0\xBB \xBF\xA9\xB4\xC2 \xB9\xAE, G\xB8\xB6\xC4\xCF</title><meta http-equiv='Content-Type' content='text/html; charset=euc-kr'>\n</head>\n</body>\n</html>\n" | |
irb(main):011:0> Nokogiri::HTML(f).encoding | |
=> "euc-kr" | |
irb(main):012:0> Nokogiri::HTML(f).meta_encoding | |
=> "euc-kr" |
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
package org.apache.lucene.analysis; | |
import java.io.IOException; | |
import org.apache.lucene.analysis.tokenattributes.TermAttribute; | |
/** | |
* Removes words that are too long or too short from the stream. | |
*/ | |
public final class LengthFilter extends TokenFilter { |
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
package org.apache.lucene.analysis; | |
import java.io.IOException; | |
import java.io.Reader; | |
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute; | |
import org.apache.lucene.analysis.tokenattributes.TermAttribute; | |
import org.apache.lucene.util.AttributeSource; | |
/** |
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
# If your workers are inactive for a long period of time, they'll lose | |
# their MySQL connection. | |
# | |
# This hack ensures we re-connect whenever a connection is | |
# lost. Because, really. why not? | |
# | |
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar) | |
# | |
# From: | |
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/ |
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
/** | |
* A simple preforking echo server in C. | |
* | |
* Building: | |
* | |
* $ gcc -Wall -o echo echo.c | |
* | |
* Usage: | |
* | |
* $ ./echo |
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 'open-uri' | |
# url dsl -- the ultimate url dsl! | |
# | |
# You just can't beat this: | |
# | |
# $ irb -r url_dsl | |
# >> include URLDSL | |
# => Object | |
# >> http://github.com/defunkt.json |