Skip to content

Instantly share code, notes, and snippets.

View usagi's full-sized avatar
🍣
Sushi

Usagi Ito usagi

🍣
Sushi
View GitHub Profile
@usagi
usagi / GPipe.hs
Created February 3, 2012 00:22
how to use GPipe for starter from longgate; http://longgate.co.jp/blog/?p=21
import Graphics.GPipe
import Graphics.GPipe.Texture.Load
import Graphics.UI.GLUT( Window,
mainLoop,
postRedisplay,
idleCallback,
getArgsAndInitialize,
($=))
import qualified Data.Vec as Vec
import Data.Vec.Nat
const number_of_begin = 1;
const number_of_end = 20;
const word_of_fizz = "Fizz";
const word_of_buzz = "Buzz";
for(var n=number_of_begin;n<=number_of_end;++n){
var is_fizz = n % 3 === 0;
var is_buzz = n % 5 === 0;
if(is_fizz) console.log(word_of_fizz);
if(is_buzz) console.log(word_of_buzz);
const number_of_begin = 1;
const number_of_end = 20;
const word_of_fizz = "Fizz";
const word_of_buzz = "Buzz";
function fizz(n){ return n % 3 == 0; }
function buzz(n){ return n % 5 == 0; }
for(var n=number_of_begin;n<=number_of_end;++n){
var is_fizz = fizz(n);
#!/bin/sh
if [ $# -lt 2 ]; then
echo "usage: $0 <SOURCE> <DESTINATION>"
exit 1
fi
force_trailing_slash() {
case $1 in
*/) echo -n "$1" ;;
@usagi
usagi / PHP array size vs memory usage.php
Created March 3, 2012 12:04
PHP array size vs. memory usage
<?php
define ( 'K', 1024 );
define ( 'M', K * K );
define ( 'COUNT_MAX' , 10 * M );
define ( 'PRINT_STEP', 100 * K );
$memory_base = memory_get_usage();
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="google-code-prettify" />
<Content type="html"><![CDATA[
<head>
<style type="text/css">
@import "http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css";
</style>
<script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript"></script>
<script type="text/javascript">
<pre class="prettyprint lang-java linenums:0 " style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-style: initial; border-color: initial; border-image: initial; font: inherit; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word; border-style: initial; border-color: initial; font: inherit; font-family: monospace, sans-serif; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); color: rgb(68, 68, 68); font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: -webkit-auto; text-indent: 0px;
interface Enumerable<Source> extends Iterable
{
Enumerable<Source> where(bool filter(Source));
Enumerable select(/*Dynamic selector(Source)*/var selector);
}
class Enumerator<Source> implements Enumerable<Source>
{
Enumerable<Source> where(bool filter(Source)) => new Where<Source>(this, filter);
Enumerable select(/*Result selector(Source)*/var selector) => new Select<Source>(this, selector);
#!/usr/bin/runhaskell
\begin{code}
{-# LANGUAGE OverloadedStrings #-}
import Control.Arrow ((>>>))
import Control.Arrow ((>>^))
import Hakyll
import Text.CSS.CleverCSS
import System.IO.Unsafe
main = hakyll $ do
var month = 0;
var number_of_pairs = 1;
var before_number_of_pairs = 0;
while (month < 12) {
var b = number_of_pairs;
number_of_pairs
= number_of_pairs
+ before_number_of_pairs;
before_number_of_pairs = b;
month = month + 1;