Skip to content

Instantly share code, notes, and snippets.

View yen3's full-sized avatar

Yen3 yen3

  • Taiwan
View GitHub Profile
@yen3
yen3 / p01.hs
Last active December 25, 2015 14:19
Project Euler
sol1 = takeWhile (<1000) $ filter (\x -> x `mod` 3 == 0 || x `mod` 5 == 0) [1..]
sol2 = takeWhile (<1000) [x| x<-[1..], x `mod` 3 ==0 || x `mod` 5 ==0]
@yen3
yen3 / base.html
Last active December 25, 2015 10:19
Simple practice for Flask + jQuery
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
@yen3
yen3 / new_post_nikola.py
Last active December 23, 2015 01:49
Generate a new post with default contents in nikola.
#!/usr/bin/env python
DEFAULT_CONTENTS="""<!--
.. link:
.. description:
.. tags: all
.. date: $time
.. title: $title
.. slug: $slug
-->
@yen3
yen3 / read_pbpaste_2.hs
Created September 8, 2013 01:26
read the clipboard's contents
processPaste' :: (String -> String) -> IO ()
processPaste' pd = putStrLn . pd =<< readProcess "pbpaste" [] []
@yen3
yen3 / read_pbpaste.hs
Last active December 22, 2015 12:29
Read the contents from the clipboard in Mac OSX
-- Read the contents of clipboard
-- Ref: http://stackoverflow.com/questions/1712347/closest-equivalent-to-subprocess-communicate-in-haskell
import System.Process
processData :: String -> String
processData = (id :: String -> String)
processPaste :: (String -> String) -> IO ()
processPaste pd = do
@yen3
yen3 / h99_p01_10.hs
Last active September 15, 2016 15:43
Practice for H-99: Ninety-Nine Haskell Problems( http://www.haskell.org/haskellwiki/H-99:_Ninety-Nine_Haskell_Problems )
-- Problem 1
myLast [] = error "empty list."
myLast [x] = x
myLast (x:xs) = myLast xs
-- Problem 2
myButLast x = head . drop 1 . reverse $ x
-- Problem 3
elementAt (x:xs) n =
@yen3
yen3 / epubs2t_opencc.py
Last active November 21, 2018 12:18
Convert epub content from simple chinese to traditional chinese using OpenCC (https://code.google.com/p/opencc/)
#!/usr/bin/env python
#-*- coding: utf8 -*-
from __future__ import print_function
from optparse import OptionParser
import zipfile
from sys import argv, exit
from subprocess import Popen, PIPE, check_output
import os.path
@yen3
yen3 / custom.css
Last active December 4, 2016 13:20
My gitit custom css. The original link is loss. If you know the original link, tell me. I will add the link in the page.
@import url("reset-fonts-grids.css");
@import url("hk-pyg.css"); /* for syntax highlighting */
html { background: #f9f9f9; color: black; }
body { margin: 10px; font-family: verdana; }
fieldset { border: 1px solid #ccc; padding: 1em; }
legend { font-weight: bold; margin-left: 1em; padding: 4px; }
h1, h2, h3, h4, h5, h6 { font-weight: bold; font-family: Georgia, serif; }
table, tr, td, th { border: none; }
hr { height: 1px; color: #aaa; background-color: #aaa; border: 0; margin: .2em 0 .2em 0; }