Skip to content

Instantly share code, notes, and snippets.

@tsurushuu
tsurushuu / gist:1257473
Created October 2, 2011 13:51
Graph test
module Main where
import System.Cmd
import Data.Graph.Inductive
import Data.Graph.Inductive.Graphviz
import Data.Graph.Inductive.Example
myGraph :: Gr String ()
myGraph = mkGraph
@tsurushuu
tsurushuu / findindigits.hs
Created July 12, 2012 16:16
find patterns in the difits of pi.
module Main where
import Data.List
hexTo01s :: Char -> String
hexTo01s '0' = "0000"
hexTo01s '1' = "0001"
hexTo01s '2' = "0010"
hexTo01s '3' = "0011"
hexTo01s '4' = "0100"
# -*- coding: utf-8 -*-
import sublime
import sublime_plugin
import subprocess
class MilkGrepNewFileCommand(sublime_plugin.WindowCommand):
def panel_search_done(self, str):
pipe = subprocess.Popen('gmilk -a ' + str, shell=True, stdout=subprocess.PIPE).stdout
results = pipe.read()
@tsurushuu
tsurushuu / open_with.py
Created December 12, 2011 14:47
for Sublime Text 2
###########################
# windows only
###########################
#import sublime
import sublime_plugin
import os
import os.path
[
{ "caption": "-" },
{ "command": "open_with_default", "caption": "Open with Default App" },
{ "command": "cmd_window_here", "caption": "Command Window Here" },
{ "command": "bash_prompt_here", "caption": "Bash Prompt Here" },
{ "caption": "-", "id": "end" }
]
module Main where
import System
import Data.List
import Control.Monad
separateDiffPatch :: String -> [String]
separateDiffPatch str = map unlines . map (head . filter patchEnd . inits) . (filter patchStart . tails) . lines $ str
where
patchStart (l0 : l1 : l2 : ls) = and [isPrefixOf "From " l0, isPrefixOf "From: " l1, isPrefixOf "Date: " l2]
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.Run "cmd.exe /c milk web", vbhide
module Main where
import System.Directory
import Control.Monad
import Data.List
import Text.Regex
import Text.Regex.Posix
recursiveFiles :: FilePath -> IO [FilePath]
module Main (main) where
import System.Environment (getArgs)
import System.Console.GetOpt
data SearchOptions
= Query String | Rpp Int | Lang String | OutputFile String
deriving (Show)
options :: [OptDescr SearchOptions]
@tsurushuu
tsurushuu / gist:1240227
Created September 25, 2011 04:27
twitter query string encoding.
import Network.HTTP
import Codec.Binary.UTF8.String
queryString :: String
queryString = "ひとし+君"
queryRPP :: Int
queryRPP = 10
makeRequestUrl :: String