Skip to content

Instantly share code, notes, and snippets.

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;
@knowtheory
knowtheory / prettyprint.js
Created April 11, 2011 05:44
A pretty printer for Javascript objects that looks like Ruby's pp formatter. In use on Rhino, untested elsewhere.
function pp(object, depth, embedded) {
typeof(depth) == "number" || (depth = 0)
typeof(embedded) == "boolean" || (embedded = false)
var newline = false
var spacer = function(depth) { var spaces = ""; for (var i=0;i<depth;i++) { spaces += " "}; return spaces }
var pretty = ""
if ( typeof(object) == "undefined" ) { pretty += "undefined" }
else if ( typeof(object) == "boolean" ||
typeof(object) == "number" ) { pretty += object.toString() }
else if ( typeof(object) == "string" ) { pretty += "\"" + object + "\"" }
anonymous
anonymous / stack_impl1.c
Created September 4, 2011 07:27
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
struct Stack {
uint32_t used;
int *array;
};
anonymous
anonymous / stack_impl2.c
Created September 4, 2011 07:28
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
struct Stack {
uint32_t used;
int *array;
};
anonymous
anonymous / stack_impl3.c
Created September 4, 2011 07:29
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <stdio.h>
#include <setjmp.h>
sigjmp_buf return_point;
/* 適切で無いハンドラ */
#include <iostream>
#include <thread>
#include <future>
#include <chrono>
#include <functional>
#include <deque>
struct task_queue {
task_queue() = default;
task_queue(const task_queue &) = delete;
@fjnl
fjnl / nvcc.jam
Created February 5, 2012 17:30
add -code and -arch support to nvcc.jam.
# nvcc.jam Boost.Build Jam file for extended toolset.
# Copyright (c) 2010 - 2011 Kohei Takahashi (Flast).
# Distributed under the MIT license. for more detail see COPYING.
import "class" : new ;
import common ;
import feature : feature ;
import generators ;
import modules ;
@yohhoy
yohhoy / threads.h
Last active February 15, 2025 21:51
C11 <threads.h> emulation library
/*
* C11 <threads.h> emulation library
*
* (C) Copyright yohhoy 2012.
* Distributed under the Boost Software License, Version 1.0.
* (See copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef EMULATED_THREADS_H_INCLUDED_
#define EMULATED_THREADS_H_INCLUDED_
# -*- coding: utf-8 -*-
import datetime
from threading import Thread
from Queue import Queue as queue
import SocketServer
import logging
import logging.handlers
class UTC(datetime.tzinfo):
@y-yu
y-yu / kana-rule.conf
Created May 15, 2012 06:43
kana-rule
a,あ,ア,ア
bb,っ,ッ,ッ,b
ba,ば,バ,バ
bi,び,ビ,ビ
bu,ぶ,ブ,ブ
be,べ,ベ,ベ
bo,ぼ,ボ,ボ
# DvorakJP
# コンビネーションキー