This file contains hidden or 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
#include <iostream> | |
#include <boost/lexical_cast.hpp> | |
template <typename Result> | |
class manip | |
{ | |
public: | |
typedef manip base_type; | |
typedef std::ios_base::fmtflags flags_type; | |
typedef Result result_type; |
This file contains hidden or 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
module EventMachine | |
module Twitter | |
class Connection < EM::Connection | |
public :on_headers_complete, :on_body | |
end | |
end | |
end |
This file contains hidden or 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 'nokogiri' | |
require 'cgi' | |
class Google | |
include Donkun::Plugin | |
match /(?:google|g)\s+(.+)/ | |
def execute(m, query) | |
m.target.notice search(query) | |
end |
This file contains hidden or 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
<html class="normal" type="channel" channelname="#test"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<meta http-equiv="Content-Script-Type" content="text/javascript"> | |
<meta http-equiv="Content-Style-Type" content="text/css"> | |
<style> | |
html {font-family:'Osaka-Mono';font-size:10pt;background-color:white;color:black;word-wrap:break-word;margin:0;padding:3px 4px 10px 4px;} | |
body {margin:0;padding:0} | |
img {border:1px solid #aaa;vertical-align:top;} | |
object {vertical-align:top;} |
This file contains hidden or 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
#include <iostream> | |
#include <boost/chrono.hpp> | |
#include <boost/asio.hpp> | |
#include <boost/asio/steady_timer.hpp> | |
#include <boost/bind.hpp> | |
namespace asio = boost::asio; | |
using asio::ip::tcp; | |
class client |
This file contains hidden or 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 ($matched) { | |
Auto::Utils::sendto_channel_closure( | |
$receiver, $command, undef, undef, undef, 0 | |
)->($text); | |
my $log_channel = $this->_runloop->mod_manager->get('Log::Channel'); | |
if ($log_channel) { | |
$log_channel->message_arrived( | |
Tiarra::IRC::Message->new( | |
Command => $command, |
This file contains hidden or 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
$response = ''; | |
while (!feof($this->_socket_resource)) { | |
$response .= fgets($this->_socket_resource, 128); | |
} | |
// $response = fgets($this->_socket_resource, 128); | |
if(!preg_match('@^' . preg_quote(Net_Socket_Tiarra::protocol, '@') . ' 200 OK@', $response)) { | |
throw new Net_Socket_Tiarra_Exception("error: " . $response); | |
}; | |
fclose($this->_socket_resource); |
This file contains hidden or 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
val ids = new VIntArrayWritable | |
override def reduce(key: IntWritable, values: Iterable[VIntArrayWritable], context: Context): Unit = { | |
ids.set(values.map(_.toArray.asInstanceOf[Array[IntWritable]].toList).fold(Nil)(_ ++ _).distinct.toArray) | |
context.write(key, ids) | |
} |
This file contains hidden or 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
-- data.txt | |
-- 10 1,2,3 | |
-- 20 1,2 | |
A = LOAD 'data.txt' USING PigStorage('\t') AS (key:int, values:chararray); | |
-- B = FOREACH A GENERATE key, FLATTEN(TOKENIZE(values, ',')) AS (value:int); | |
B = FOREACH A GENERATE key, FLATTEN(TOKENIZE(values, ',')) AS value; | |
C = FOREACH B GENERATE key, (int)value; | |
D = FILTER C BY value > 1; | |
DUMP D; |
This file contains hidden or 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
module WhereLikeExtension | |
def where_like(opts, *rest) | |
return self if opts.blank? | |
spawn.where_like! opts, *rest | |
end | |
def where_like!(opts, *rest) | |
self.where_values += build_where(opts, rest).map { |r| Arel::Nodes::Matches.new r.left, r.right } | |
self | |
end |