This file contains hidden or 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
| def fib(n): | |
| if n==0:return 0 | |
| if n==1:return 1 | |
| return fib(n-1)+fib(n-2) |
This file contains hidden or 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
| cache_fib={} | |
| def c_fib(n): | |
| if cache_fib.has_key(n): | |
| return cache_fib[n] | |
| if n==0: | |
| cache_fib[0]=0 | |
| elif n==1: | |
| cache_fib[1]=1 | |
| else: | |
| cache_fib[n] = c_fib(n-1)+c_fib(n-2) |
This file contains hidden or 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
| def fib_gen_(): | |
| temp1,temp2 = 0,1 | |
| while 1: | |
| yield temp1 + temp2 | |
| temp2,temp1 = temp1,temp2+temp1 | |
| def alt_fib(n): | |
| if n==0:return 0 | |
| elif n==1:return 1 | |
| a = fib_gen_() |
This file contains hidden or 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 fib | |
| >>> fib.alt_fib(10) | |
| 55 | |
| >>> fib.alt_fib(100) | |
| 354224848179261915075L | |
| >>> fib.alt_fib(1000) | |
| 43466557686937456435688527675040625802564660517371780402481729089536555417949051890403879840079255169295922593080322634775209689623239873322471161642996440906533187938298969649928516003704476137795166849228875L | |
| >>> fib.alt_fib(10000) | |
| 33644764876431783266621612005107543310302148460680063906564769974680081442166662368155595513633734025582065332680836159373734790483865268263040892463056431887354544369559827491606602099884183933864652731300088830269235673613135117579297437854413752130520504347701602264758318906527890855154366159582987279682987510631200575428783453215515103870818298969791613127856265033195487140214287532698187962046936097879900350962302291026368131493195275630227837628441540360584402572114334961180023091208287046088923962328835461505776583271252546093591128203925285393434620904245248929403901706233888991085841065183173360437470737908552631764325733993712871937587746897479926305837065742830161637 |
This file contains hidden or 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
| // | |
| // USAGE: | |
| // $ clang++ main.cpp -framework CoreFoundation -framework IOKit -o SystemSerial | |
| // $ ./SystemSerial | |
| // Serial Number(System): XXXXXXXXXXX | |
| // | |
| // Reference. | |
| // http://developer.apple.com/library/mac/#technotes/tn1103/_index.html | |
| // | |
| // tmiz moo@tmiz.net |
This file contains hidden or 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
| // | |
| // Using CoreLocation on Mac OS X with command-line | |
| // $ clang CoreLocationTest.m -framework cocoa -framework CoreLocation | |
| // $ ./a.out | |
| // location service enabled | |
| // 2011-12-01 21:03:01.839 a.out[10214:903] latitude,logitude : 35.606647, 140.695538 | |
| // 2011-12-01 21:03:01.842 a.out[10214:903] timestamp : 2011-12-01 21:01:36 +0900 | |
| // tmiz moo@tmiz.net | |
| // | |
| #import <cocoa/cocoa.h> |
This file contains hidden or 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
| #!/bin/bash | |
| OPENSSL_VERSION="1.0.1g" | |
| curl -O http://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz | |
| tar -xvzf openssl-$OPENSSL_VERSION.tar.gz | |
| mv openssl-$OPENSSL_VERSION openssl_i386 | |
| tar -xvzf openssl-$OPENSSL_VERSION.tar.gz | |
| mv openssl-$OPENSSL_VERSION openssl_x86_64 | |
| cd openssl_i386 |
This file contains hidden or 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
| #include <stdio.h> | |
| #include <string.h> | |
| #include "openssl/opensslv.h" | |
| #include "openssl/sha.h" | |
| void printBufferOfSha256(const unsigned char *output) | |
| { | |
| int i = 0; | |
| for(; i < SHA256_DIGEST_LENGTH; i++) { |
This file contains hidden or 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 ipy | |
| import clr | |
| clr.AddReference("System.Windows.Forms") | |
| clr.AddReference('System.Drawing') | |
| import System.Windows.Forms | |
| import System.Drawing | |
| myForm = System.Windows.Forms.Form() | |
| myForm.Text = "2011 Mac Dev JP Advent Calendar" | |
| myForm.Show() |
This file contains hidden or 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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using MonoMac.Foundation; | |
| using MonoMac.AppKit; | |
| namespace MonoDemoProject | |
| { | |
| public partial class MainWindowController : MonoMac.AppKit.NSWindowController | |
| { |