This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun add-at (a l pos) | |
(if (= pos 0) | |
(cons a l) | |
(cons (car l) (add-at a (rest l) (1- pos))))) | |
(defun insert-everywhere/in-a-word (char word) | |
(loop for position from 0 to (length word) | |
collecting (add-at char word position))) | |
(defun insert-in-all (char word) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use threads; | |
my $num_thr = $ARGV[0] or die "Specify the number of threads first.\n"; | |
my $rate = $ARGV[1] || 1; | |
my $contiune = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
sub AUTOLOAD { | |
( my $cmd = our $AUTOLOAD ) =~ s/.*:://; | |
for ( map { ; "$_/pkg_$cmd", "$_/pkg$cmd" } qw(/usr/sbin /usr/local/sbin) ) | |
{ | |
system( $_, @_ ) and last if -x; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Plugins/Purple Service/ESPurpleMSNAccount.m b/Plugins/Purple Service/ESPurpleMSNAccount.m | |
index 14f1b1d..29b8248 100644 | |
--- a/Plugins/Purple Service/ESPurpleMSNAccount.m | |
+++ b/Plugins/Purple Service/ESPurpleMSNAccount.m | |
@@ -361,7 +361,8 @@ | |
currentMaxNumberOfPreEncodedCharacters -= 10; | |
} | |
- purple_account_set_alias(account, friendlyNameUTF8String); | |
+ purple_account_set_alias(account, friendlyNameUTF8String); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ruN a/XMPP-0.1.2/Network/XMPP/Stanzas.hs b/XMPP-0.1.2/Network/XMPP/Stanzas.hs | |
--- a/XMPP-0.1.2/Network/XMPP/Stanzas.hs 2012-07-11 16:31:35.000000000 +0800 | |
+++ b/XMPP-0.1.2/Network/XMPP/Stanzas.hs 2012-07-11 16:33:32.000000000 +0800 | |
@@ -31,7 +31,7 @@ | |
import Network.XMPP.XMLParse | |
import Network.XMPP.JID | |
import System.Random | |
-import Maybe | |
+import Data.Maybe | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DoRec #-} | |
data Tree a = L a | B (Tree a) (Tree a) | |
deriving (Show) | |
rpMinWithIO :: (Ord a, Show a) => (Tree a, a) -> IO (Tree a, a) | |
rpMinWithIO (L a, m) = print a >> return (L m, a) | |
rpMinWithIO (B l r, m) = | |
rpMinWithIO (l, m) >>= | |
\(l', lmin) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is an example of implementing set with binary tree, original Scala code: | |
abstract class IntSet { | |
def incl(x: Int): IntSet | |
def contains(x: Int): Boolean | |
def union(other: IntSet): IntSet | |
} | |
class Empty extends IntSet { | |
def contains(x: Int): Boolean = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Arrow ((&&&)) | |
import Data.Bits (shiftR, (.&.), Bits(..)) | |
import Data.Functor ((<$>)) | |
import Data.List (intercalate) | |
import Data.Maybe (listToMaybe, fromMaybe) | |
import Network.BSD (getHostByName, HostEntry(..)) | |
import System.Environment (getArgs) | |
main :: IO () | |
main = do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad.State | |
half :: Int -> State [Int] Int | |
half x = do | |
xs <- get | |
put (x:xs) | |
return (x `div` 2) | |
main = print $ runState (half >=> half >=> half >=> half >=> half >=> half >=> half >=> half >=> half >=> half $ 1024) [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XCODE_ROOT=`xcode-select -print-path` | |
SDK_ROOT=${XCODE_ROOT}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk | |
FRAMEWORK_ROOT=${SDK_ROOT}/System/Library/Frameworks | |
sed -i.bak -e 's|/Developer/Headers/FlatCarbon/Files.h|CarbonCore/Files.h|' fontforge/macbinary.c fontforge/startui.c gutils/giomime.c | |
sed -i.bak -e 's|/Developer/Headers/FlatCarbon/CarbonEvents.h|HIToolbox/CarbonEvents.h|' fontforge/startui.c | |
env CFLAGS="-isysroot ${SDK_ROOT} -F${FRAMEWORK_ROOT}/CoreServices.framework/Frameworks -F${FRAMEWORK_ROOT}/Carbon.framework/Frameworks" \ | |
./configure --prefix=$HOME/local --with-freetype-src=$HOME/local/src/freetype-2.5.0.1 \ | |
--enable-double --without-freetype-bytecode --without-python --with-static-imagelibs |