Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
using namespace std;
#include <boost/scoped_ptr.hpp>
using namespace boost;
class clonable{
public:
virtual ~clonable(){}
virtual clonable *clone() const = 0;
#include <iostream>
using namespace std;
#include <boost/scoped_ptr.hpp>
using namespace boost;
class clonable{
public:
virtual ~clonable(){}
virtual clonable *clone() const = 0;
APPNAME = 'gdbtest'
VERSION = '0.0.0'
srcdir = '.'
blddir = 'build'
def set_options(opt):
opt.tool_options('compiler_cxx')
opt.add_option('--gdb', action='store_true', default=False,
help='run gdb')
mport Client
add :: RpcMethod (Int -> Int -> IO Int)
add = method "add"
echo :: RpcMethod (String -> IO String)
echo = method "echo"
main :: IO ()
main = do
string GetPythonErrorString()
{
try{
PyObject *ptype, *pvalue, *ptraceback;
PyErr_Fetch(&ptype, &pvalue, &ptraceback);
object prev_stderr = import("sys").attr("stderr");
object output_cacher = import("cStringIO").attr("StringIO")();
import("sys").attr("stderr") = output_cacher;
void rsort(uint64_t *a, uint64_t n, uint64_t *b)
{
uint32_t cnt[0x4001]={};
for (size_t i=0;i<n;i++) cnt[(a[i]&0x1fff)+1]++;
for (size_t i=0;i<0x2000;i++) cnt[i+1]+=cnt[i];
for (size_t i=0;i<n;i++) b[cnt[a[i]&0x1fff]++]=a[i];
std::swap(a, b);
for (size_t i=0;i<0x2000;i++) cnt[i]=0;
import Data.Vector.Primitive.Mutable
import Control.Monad
import Prelude hiding (read)
newUF :: Int -> IO (IOVector Int)
newUF n = do
v <- new n
forM_ [0..n-1] $ \i -> write v i i
return v
#include <vector>
using namespace std;
struct a{
a(int &r): r(r) {}
a(a &&rr): r(rr.r) {}
int &r;
};
int main()
{-# LANGUAGE TemplateHaskell #-}
module IP where
import Control.Applicative
import Language.Haskell.TH
import Network
ipPortFile :: FilePath -> Q Exp
ipPortFile fp = do
[ip, port] <- runIO $ lines <$> readFile fp
@tanakh
tanakh / file0.txt
Created March 8, 2012 05:35
文字列連結ベンチ ref: http://qiita.com/items/3066
{-# LANGUAGE OverloadedStrings #-}
import Data.Monoid
import Blaze.ByteString.Builder as B
import Blaze.ByteString.Builder.Char.Utf8 as BT
import qualified Data.ByteString.Char8 as BS
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import Criterion.Main