Skip to content

Instantly share code, notes, and snippets.

View ruyut's full-sized avatar
🤪

Ruyut ruyut

🤪
View GitHub Profile
@ruyut
ruyut / TimerLog.cs
Created June 14, 2021 11:15
使用Timer定時輸出全部Log,避免重複開關檔案影響效能
using System.Collections.Generic;
using System.IO;
using System.Timers;
namespace Ruyut
{
public class TimerLog
{
private static System.Timers.Timer _timer;
private static readonly string FileName = "D:\\log.log";
@ruyut
ruyut / SyncWriteFile.cs
Created June 13, 2021 02:15
[C#] 多執行緒快速讀寫同個檔案 強迫列隊
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace Ruyut
{
public class SyncWriteFile
{
private static readonly ManualResetEvent ManualResetEvent = new ManualResetEvent(true);
@ruyut
ruyut / kotlin_okhttp.kt
Last active September 15, 2020 07:02
Get network information by OkHttp
package app.ruyut.test.okhttp
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import okhttp3.OkHttpClient
import okhttp3.Request
var https = require("https");
var fs = require('fs');
var url = "https://data.ntpc.gov.tw/od/data/api/28AB4122-60E1-4065-98E5-ABCCB69AACA6?$format=json";
https.get(url, function (response) {
var data = "";
console.log("start");
response.on("data", chunk => {
#include "pch.h"
#include <iostream>
#include "stdlib.h"
#include "time.h"
#include "string.h"
#define SIZE 7
#define DIM 21
// 0, 1, 2 3 4 5 6
// A, B, C, D, E, F, ERD
char ERD[SIZE][SIZE] = { { 0, 1, 1, 0, 0, 0, 0 },//0
#include "pch.h"
#include <iostream>
#include "stdlib.h"
#include "time.h"
#include "string.h"
#define SIZE 7
#define DIM 21
// A,B,C,D,E,F,ERD
char ERD[SIZE][SIZE] = { {0,1,0,0,0,0,0},//A
{1,0,2,0,4,0,0},//B
{"lastUpload":"2020-03-14T01:30:09.898Z","extensionVersion":"v3.4.3"}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
class Program
{
//905-2
#include<stdlib.h>
#include<stdio.h>
int main() {
FILE *fi;//宣告檔案指標
double ss;//宣告雙精浮點數
fi = fopen("dnumber.dat", "r");//使用讀取的方式開啟檔名為dnumber.dat的檔案
while (fscanf(fi, " %lf ", &ss) != EOF) {//如果讀不到資料就跳出
printf("%.2lf\n", ss);//列印雙精浮點數
}
//905-1
#include<stdlib.h>
#include<stdio.h>
int main() {
FILE *fi;//宣告檔案指標
double ss;//宣告雙精浮點數
fi = fopen("dnumber.dat", "w");//使用寫入的方式開啟檔名為dnumber.dat的檔案
do {
printf("請輸入浮點數:");