Skip to content

Instantly share code, notes, and snippets.

View Benjamin1021523's full-sized avatar

Benjamin Chang Benjamin1021523

View GitHub Profile
#!/bin/bash
function checkRoot {
if [ "$EUID" -ne 0 ]
then echo 請使用root帳號,或sudo指令執行
return 1
fi
return 0
}
checkRoot || exit
#!/bin/bash
function checkRoot {
if [ "$EUID" -ne 0 ]
then echo 請使用root帳號,或sudo指令執行
return 1
fi
return 0
}
checkRoot || exit 1
@Benjamin1021523
Benjamin1021523 / .LoadLocalXml
Last active October 29, 2021 02:42
嘗試取得java spring專案下resources目錄xml內容的寫法
gist的title是認檔名「字串排序」最小的為準,建立後將其他檔案改名或新增檔案都無效
參考資料:
https://stackoverflow.com/questions/9536737/load-a-xml-file-from-the-classpath-in-a-spring-web-app
https://zetcode.com/spring/classpathresource/
@Benjamin1021523
Benjamin1021523 / 1. install.sh
Last active December 24, 2019 10:14
在一台什麼都沒有裝的mac上安裝前後端程式,以及執行細則
#下載、安裝brew(如果需要
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
#安裝git
brew install git
#在終端機上登入個人github帳號
#下載前後端專案
git clone https://github.com/104corp/y19fresh-lottery-program
@Benjamin1021523
Benjamin1021523 / template.cpp
Last active August 16, 2019 03:04
c++的多維陣列嘗試
//c++想玩出不定維度陣列也是辦得到的,但是元素資料型態不固定大概就不行了。
#include<iostream>
using namespace std;
template <typename T>
struct Node{
T val;
Node* next;
Node* child;
@Benjamin1021523
Benjamin1021523 / ConnectWeb.java
Last active August 13, 2019 06:12
java練習
import java.io.*;
import java.net.*;
public class ConnectWeb{
public static void main(String[] args){
http();
https();
}
static void https(){//https目前還是不行,試過網路上的code失敗
String target = "https://gist.githubusercontent.com/Benjamin1021523/1701eb96206b779e1595ce0cc3f82466/raw/fc71033195bdec93457f39fe26cbef74701dcce2/Example.java";
@Benjamin1021523
Benjamin1021523 / prac_js.js
Last active October 14, 2018 08:10
根據網路上的javascript教學做的一些筆記
/*參考自
https://ithelp.ithome.com.tw/users/20065504/ironman/1259
*/
var 字串1 = '這是一個字串';
var 字串2 = '這也是一個字串';
console.log(字串1);
//可以用中文當變數名
if(isNaN(parseInt(字串1))){
@Benjamin1021523
Benjamin1021523 / py_schedule.py
Last active October 9, 2018 07:47
每隔30分鐘觸發網頁的程式
import requests
from apscheduler.schedulers.blocking import BlockingScheduler
from datetime import datetime
def job():
print("於{}開始抓取資料".format(datetime.now()))
requests.get('http://localhost/weather.php')
print("於{}結束抓取資料".format(datetime.now()))
job()#初次工作
@Benjamin1021523
Benjamin1021523 / tw_weather.php
Last active October 16, 2018 12:31
台灣氣象api稍微試用一下(api沒有的就用google了
<?php
set_time_limit(0);
header("Content-Type:text/html; charset=utf-8");
date_default_timezone_set("Asia/Taipei");
$CountryName = ["","基隆市", "新北市", "臺北市", "桃園市", "新竹市", "新竹縣", "苗栗縣", "臺中市", "彰化縣", "南投縣", "雲林縣", "嘉義市", "嘉義縣", "臺南市", "高雄市", "屏東縣", "宜蘭縣", "花蓮縣", "臺東縣", "金門縣", "連江縣", "澎湖縣"];
$CountyToTown = array(
1 => array([13,"仁愛區","1001704"],[14,"信義區","1001707"],[15,"中正區","1001701"],[16,"中山區","1001705"],[17,"安樂區","1001706"],[18,"暖暖區","1001703"],[19,"七堵區","1001702"]),
2 => array([20,"萬里區","6502800"],[21,"金山區","6502700"],[26,"板橋區","6500100"],[27,"汐止區","6501100"],[28,"深坑區","6501800"],[29,"石碇區","6501900"],[30,"瑞芳區","6501200"],[31,"平溪區","6502400"],[32,"雙溪區","6502500"],[33,"貢寮區","6502600"],[34,"新店區","6500600"],[35,"坪林區","6502000"],[36,"烏來區","6502900"],[37,"永和區","6500400"],[38,"中和區","6500300"],[39,"土城區","6501300"],[40,"三峽區","6500900"],[41,"樹林區","6500700"],[42,"鶯歌區","6500800"],[43,"三重區","6500200"],[44,"新莊區","6500500"],[45,"泰山區","6501600"],[46,"林口區","6501700"],[47,"蘆洲區","6501400"],[48,"五股區","6501500"],[49,"八里區