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
// 原始程式來源: http://practicalcryptography.com/ciphers/enigma-cipher/ 網頁內的 javascript 程式碼 | |
var c = console; | |
var plaintext = 'ABCDEF'; | |
c.log('>> plaintext2 : '+plaintext); | |
var ciphertext = Encrypt(plaintext, 'AAA', 'AAA', '123', 'POMLIUKJNHYTGBVFREDC'); | |
c.log('>> ciphertext : '+ciphertext); | |
var plaintext2 = Encrypt(ciphertext, 'AAA', 'AAA', '123', 'POMLIUKJNHYTGBVFREDC'); | |
c.log('>> plaintext2 : '+plaintext); |
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
var http = require('http'); | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/html'}); | |
res.end('<html><head><meta charset="UTF-8"></head><body><a href="http://tw.yahoo.com">yahoo</a> Hello World 你好!</body></html>\n'); | |
}).listen(1337, '127.0.0.1'); | |
console.log('Server running at http://127.0.0.1:1337/'); |
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
D:\ccc\code\ch12>make | |
gcc.exe -D__DEBUG__ -c Parser.c -o Parser.o -g3 | |
gcc.exe -D__DEBUG__ -c Tree.c -o Tree.o -g3 | |
gcc.exe -D__DEBUG__ -c Lib.c -o Lib.o -g3 | |
gcc.exe -D__DEBUG__ -c Scanner.c -o Scanner.o -g3 | |
gcc.exe -D__DEBUG__ -c Array.c -o Array.o -g3 | |
gcc.exe -D__DEBUG__ -c Compiler.c -o Compiler.o -g3 | |
gcc.exe -D__DEBUG__ -c HashTable.c -o HashTable.o -g3 | |
gcc.exe -D__DEBUG__ -c Generator.c -o Generator.o -g3 | |
gcc.exe -D__DEBUG__ -c Assembler.c -o Assembler.o -g3 |
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
// file df.c | |
#include <stdio.h> | |
#include <math.h> | |
double dx = 0.0001; | |
double df(double x, double (*f)(double)) { | |
double dy = (*f)(x+dx)-(*f)(x); | |
return dy/dx; | |
} |
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
// 第一種寫法,直接宣告函數 | |
function sub(a,b) { | |
return a-b; | |
} | |
// 第二種寫法,將匿名函數指定給變數。 | |
var add = function(a,b) { | |
return a+b; | |
} | |
console.log("add(3,5)=", add(3,5), " sub(7,2)=", sub(7,2)); |
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
/* | |
* Copyright (c) 2006-2010, Intel Mobile Communications. All rights reserved. | |
* | |
* This program is free software; you can redistribute it and/or modify it | |
* under the terms of the GNU General Public License version 2 as published by | |
* the Free Software Foundation. | |
* | |
* This program is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
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
#include <pthread.h> // 引用 pthread 函式庫 | |
#include <unistd.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
void *print_george(void *argu) { // 每隔一秒鐘印出一次 George 的函數 | |
while (1) { | |
printf("George\n"); | |
sleep(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
#include <pthread.h> // 引用 pthread 函式庫 | |
#include <unistd.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
void *print_george(void *argu) { // 每隔一秒鐘印出一次 George 的函數 | |
while (1) { | |
printf("George\n"); | |
sleep(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
#include <stdio.h> | |
#include <pthread.h> | |
#define LOOPS 100000 | |
int counter = 0; | |
void *inc() | |
{ | |
for (int i=0; i<LOOPS; i++) { | |
counter = counter + 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
#include <stdio.h> | |
#include <pthread.h> | |
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; | |
#define LOOPS 100000 | |
int counter = 0; | |
void *inc() | |
{ | |
for (int i=0; i<LOOPS; i++) { |
OlderNewer