Skip to content

Instantly share code, notes, and snippets.

View usagi's full-sized avatar
🍣
Sushi

Usagi Ito usagi

🍣
Sushi
View GitHub Profile
// Question: What's dimention(units of measure) of E in F# calculate.
// Generally, human brain will answer "<J>", but...
[<Measure>] type m
[<Measure>] type s
[<Measure>] type kg
[<Measure>] type N = kg m / s^2
[<Measure>] type J = N m
let E m g h = m * g * h
// [bugbeard] http://tricklib.com/cxx/ex/bugbeard/
// ver.2008-09-23 + temporary fix(http://twitter.com/USAGI_WRP/status/6680888390)
#define BUG_EVIL_CONTRACT
//#include <bug/bug.h>
//BUG_define_logger(new bugbeard::bug_tree_logger(new bugbeard::bug_file_writer("bug/trace.log")));
#define BUG_STATEMENT_HACK
#include <bug/bug.h>
int _tmain(int argc, _TCHAR* argv[])
using System;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.IO;
namespace wrp
{
namespace random_number_generator
{
public class XorShift
package
{
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.display.MovieClip;
@usagi
usagi / google_search_images_sample.cs
Created January 19, 2011 18:07
sample: how to use XPath for JSON easy with .net 4.0 and Google apps search images.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Runtime.Serialization.Json;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;
using System.Web;
@usagi
usagi / orchard_slug_ja_test.cs
Created January 28, 2011 02:39
The test of strange slug from a title with Japanese on Orchard CMS 1.0
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
using System.Globalization;
namespace code_test_dotnet
{
/// <summary>
@usagi
usagi / boost_geometry_index_rtree.cpp
Created August 18, 2011 11:11
R-Tree sample using boost::geometry::index::rtree
#include <boost/geometry.hpp>
#include <boost/geometry/extensions/index/rtree/rtree.hpp>
#include <random>
#include <iostream>
#include <exception>
int main() try{
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
#include <iostream>
#include <chrono>
main(){
namespace c = std::chrono;
typedef c::duration<double> real64_seconds;
@usagi
usagi / fizz-buzz.cpp
Created October 8, 2011 17:18
fizz-buzz.cpp
#include <iostream>
int main(){
for(size_t a = 1; a; ++a){
auto fizz = (a%3==0);
auto buzz = (a%5==0);
if(fizz)
std::cout << "Fizz";
if(buzz)
std::cout << "Buzz";
else if(!fizz)
@usagi
usagi / gist:1725014
Created February 2, 2012 18:33
C++ std::complex declaration
namespace std {
template<class T>
class complex {
public:
typedef T value_type;
complex(const T& re = T(), const T& im = T());
complex(const complex&);
template<class X> complex(const complex<X>&);
T real() const;
void real(T);