Skip to content

Instantly share code, notes, and snippets.

@tsurushuu
tsurushuu / findindigits.hs
Created Jul 12, 2012
find patterns in the difits of pi.
View findindigits.hs
module Main where
import Data.List
hexTo01s :: Char -> String
hexTo01s '0' = "0000"
hexTo01s '1' = "0001"
hexTo01s '2' = "0010"
hexTo01s '3' = "0011"
hexTo01s '4' = "0100"
View sublime_milkode.py
# -*- 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()
View Context.sublime-menu
[
{ "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" }
]
@tsurushuu
tsurushuu / open_with.py
Created Dec 12, 2011
for Sublime Text 2
View open_with.py
###########################
# windows only
###########################
#import sublime
import sublime_plugin
import os
import os.path
View separate_patch.hs
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]
View start_milk.vbs
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.Run "cmd.exe /c milk web", vbhide
View check.hs
module Main where
import System.Directory
import Control.Monad
import Data.List
import Text.Regex
import Text.Regex.Posix
recursiveFiles :: FilePath -> IO [FilePath]
View gist:1257473
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
View gist:1245571
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]
View gist:1240228
fromResult :: Result a -> Maybe a
fromResult (Ok k) = Just k
fromResult (Error e) = Nothing
maybeFromObj :: JSON a => String -> JSObject JSValue -> Maybe a
maybeFromObj k o = maybe (Nothing) (fromResult . readJSON) (lookup k (fromJSObject o))