Skip to content

Instantly share code, notes, and snippets.

View junjihashimoto's full-sized avatar
🏠
Working from home

junji hashimoto junjihashimoto

🏠
Working from home
View GitHub Profile
@junjihashimoto
junjihashimoto / scandir-sample.c
Last active December 21, 2015 21:49
scandir-sample
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
//#define _SVID_SOURCE
//#define __USE_BSD
#include <dirent.h>
typedef struct Vector{
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
char*
vstrf(char* format,va_list aq){
int n;
int buflen=64;
char* buf=malloc(sizeof(char)*buflen);
@junjihashimoto
junjihashimoto / setting password for xlconnect
Created September 26, 2013 07:36
How to set password for xlconnect
Before calling loadWorkbook, call following command.
> .jcall("org.apache.poi.hssf.record.crypto.Biff8EncryptionKey","V","setCurrentUserPassword","password")
@junjihashimoto
junjihashimoto / quicksort.cpp
Created October 10, 2013 13:31
short quicksort
void sort(int* v,int l){
if(l<=1) return;
int d[l],b=0,e=l;
memcpy(d,v,l*sizeof(int));
for(int i=l-1;i>=0;i--)
if(d[i]<=d[0]) v[b++]=d[i];
else v[--e]=d[i];
sort(v,b-1); sort(v+b,l-e);
}
@junjihashimoto
junjihashimoto / openstack.hs
Created February 25, 2014 21:14
restclint-sample
{-# LANGUAGE OverloadedStrings #-}
import Data.Aeson
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString.Lazy.Char8 as L
import Network.HTTP
import Network.HTTP.Base
import Network.URI
import Control.Applicative
import Control.Monad
@junjihashimoto
junjihashimoto / lis.hs
Created March 19, 2014 03:24
longest increacing subsequence
--import Data.List
--import Debug.Trace
--dat=[1,3,5,0,2,4]
--dat=[10,9,8,7,6,5]
--dat=[39,88,67,5,69,87,82,64,58,61]
dat=[2,1,4,3,6,5,8,7,10,9,12,11,14,13,16,15,18,17,20,19,22,21,24,23,26,25,28,27,30,29,32,31,34,33,36,35,38,37,40,39,42,41,44,43,46,45,48,47,50,49]
--dat=[10,20,11,12]
--tr v = trace (show v) v
@junjihashimoto
junjihashimoto / queen.hs
Created March 22, 2014 16:20
8queen solver
dat' n =replicate n [0..(n-1)]
qvalid=all (\v -> case v of
[] -> False
_ -> True)
qdrop:: Int->[[Int]]->[[Int]]
qdrop pos board=
let b=zip [1..] board
@junjihashimoto
junjihashimoto / knight.hs
Created March 24, 2014 15:37
knight's tour
import Debug.Trace
import Control.Monad
import qualified Data.Map as M
import qualified Data.Set as S
--tr a b = trace (a++show b) b
tr a b = b
flat=foldl (++) []
board=S.fromList $ flat $ map (\a -> map (\b -> (a,b)) [0..7]) [0..7]
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
import Control.Monad
import qualified Data.Map as M
import qualified Data.List as L
import qualified Data.Set as S
data Disk=
White
| Black deriving (Read,Eq,Ord)
cmd/run-inst.hs:40:12:
Couldn't match type `TerminateInstances' with `RunInstances'
When using functional dependencies to combine
Transaction TerminateInstances Value,
arising from the dependency `a -> r'
in the instance declaration in `Aws.Ec2.Commands.TerminateInstances'
Transaction RunInstances Value,
arising from a use of `simpleAws' at cmd/run-inst.hs:40:12-24
In the expression:
simpleAws cfg (QueryAPIConfiguration $ B.pack region)