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
docker run --name=acdb -d -p 3306:3306 --env MYSQL_ROOT_PASSWORD=root mysql/mysql-server:5.7 | |
CREATE USER 'ac'@'%' IDENTIFIED BY 'ac'; | |
GRANT ALL PRIVILEGES ON * . * TO 'ac'@'%'; | |
FLUSH PRIVILEGES; |
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
" au BufRead,BufNewFile *.js set filetype=javascript | |
" Note: Skip initialization for vim-tiny or vim-small. | |
if 0 | endif | |
if has('vim_starting') | |
if &compatible | |
set nocompatible " Be iMproved | |
endif |
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
#!/bin/bash | |
echo "install scudcloud ( slack ubuntu client ) and change icon to slack" | |
sudo apt-add-repository -y ppa:rael-gc/scudcloud | |
sudo apt-get update | |
sudo apt-get install scudcloud | |
wget http://iosicongallery.com/iosicongallery/img/128/slack-2014.png -O ~/scudcloud.png | |
sudo dpkg-divert --add --rename --divert /opt/scudcloud/resources/scudcloud.png.real /opt/scudcloud/resources/scudcloud.png | |
sudo cp ~/scudcloud.png /opt/scudcloud/resources/ | |
sudo chmod +r /opt/scudcloud/resources/scudcloud.png | |
rm ~/scudcloud.png |
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 <string.h> | |
int match(int x, char s[]) { | |
int i = strlen(s)-1; | |
for ( ; i >= 0; i-- ) { | |
if ( s[i] == '?' ) { | |
x /= 10; | |
continue; | |
} |
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> | |
void print(int val, int base) { | |
int p = 0, i, out[1000]; //out: 儲存結果的陣列, p: 計算位數 | |
for ( ; val > 0; val /= base ) { //以 ascii code 將val % base 儲存在out內 | |
out[p++] = val % base > 9 ? val % base + 55 : val % base + 48 ; | |
for ( i = p - 1; i >= 0; i-- ) //從後面開始將每個字元印出來 | |
printf("%c", out[i]); | |
printf("\n"); | |
} | |
int main() { |
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> | |
void print(int val, int base) { | |
int i; | |
char output[100]; | |
for(i = 0 ;val != 0; i++, val /= base) | |
val%base < 9?(output[i]=(char)(val%base+'0')):(output[i]=(char)(val%base+'A'-10)); | |
for(;i >= 0 ;i--) | |
printf("%c",output[i]); | |
printf("\n"); | |
} |
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> | |
//讀入兩值,將val以base進位印出 | |
//若base > 10,以A, B, C....,代表10, 11, 12.... | |
void print(int val, int base){ | |
int tmp[100], digit = 0; | |
while(val != 0) { | |
tmp[digit++] = val % base; | |
val = val / base; | |
} | |
for(; digit > 0; digit--) { |
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> | |
void print(int val, int base) { | |
// 把原始值複製一份(tempVal),除一次看結果會有幾位(digit) | |
int digit = 0, tempVal = val; | |
while( tempVal > 0 ) { | |
tempVal /= base; | |
digit++; | |
} | |
// 讓一位可以存一個位址,並依序取餘數後存起來 | |
int i, result[digit]; |
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> | |
//recursion | |
int func(int n) { | |
if(n == 0) { | |
return 0; | |
} | |
if(n % 2 != 0) { | |
return n + func(n - 1); | |
} else { | |
return - n + func(n - 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> | |
//計算階乘 | |
int factorial(int x) { | |
int i, result = 1;; | |
for (i = 2; i <= x; i++) { | |
result *= i; | |
} | |
return result; | |
} | |
//判定是否為質數 |
NewerOlder