Skip to content

Instantly share code, notes, and snippets.

View henrybear327's full-sized avatar

Chun-Hung Tseng henrybear327

View GitHub Profile
@joepie91
joepie91 / vpn.md
Last active May 16, 2025 06:17
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

  • A Russian translation of this article can be found here, contributed by Timur Demin.
  • A Turkish translation can be found here, contributed by agyild.
  • There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.
@amoshyc
amoshyc / binary_search_tutorial.md
Last active April 6, 2020 18:17
二分搜教學

二分搜:講解

以下出現 A[l, r] 代表 A 陣列中 [l, r] 這個區間。 同理 A[l, r) 代表 A 陣列中 [l, r) 這個區間。

以下範例皆不處理 IO 的部份,都假設變數皆已被讀入。

基本使用

大一時學過,我們可以用二分搜在一個單調(遞增或遞減)的陣列中,尋找某個值在哪裡:

#define _CRT_SECURE_NO_WARNINGS
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <time.h>
#include <string>
#include <vector>
#include <math.h>
@amoshyc
amoshyc / ipsc_2015_s.md
Last active August 29, 2015 14:23
IPSC 2015 Problem S – Solitaire

IPSC 2015 Problem S – Solitaire

題目

接龍啊…

小測資照著題目做就可以過,但大測資不行,必須優化,可以優化成 O(n)


@james2doyle
james2doyle / simple-json-reponse.php
Last active March 7, 2024 06:02
A simple JSON response function for PHP. Used in various PhileCMS plugins.
<?php
function json_response($code = 200, $message = null)
{
// clear the old headers
header_remove();
// set the actual code
http_response_code($code);
// set the header to make sure cache is forced
header("Cache-Control: no-transform,public,max-age=300,s-maxage=900");
@pastleo
pastleo / GithubEduSSL_nginx.md
Last active August 29, 2015 14:15
Github edu SSL solution with Nginx

Github edu SSL with Nginx

這篇文章寫到最後才發現 Cloudflare 自己就已經提供免費的 SSL 可以使用,如果你已經有在用 (真的蠻好用的,重點是永久免費),所以可以先直接往下滑找到 設定 Cloudflare 的 SSL 模式 區塊看看

之前有用過 StarSSL 來作為 SSL for https 的 CA,原因當然是因為不用錢 (好像是永久免費,每年 renew 一次即可),但是使用後發現他的免費憑證 (Class 1) 在手機上還是會顯示出無法驗證憑證的訊息,所以就放棄使用 https 了

之前 Github 推出 Student Developer Pack 提供給窮學生們免費使用各種付費服務,其中有 VPS by Digital Ocean, Domain name by namecheap and SSL by namecheap,最近正好想到 中興大學學生會 ILT 會員系統 理論上必須要架設在 https 環境下使用,今天就是要來使用 PositiveSSL by namecheap 把原本沒有 SSL 的 ILT 系統加上 SSL 使之更安全

這個簡單的教學只是把我申請、設定的過程記錄下來而已,在開始前已經

@rwaldron
rwaldron / i2c_backpack_master.ino
Created February 18, 2015 15:38
I2C slave: Wire.write() sending only one byte?
#include <Wire.h>
byte i2cdata[4];
void setup() {
Wire.begin();
Serial.begin(9600);
}
void loop() {
@henrybear327
henrybear327 / How to array function call.c
Created November 16, 2014 07:52
How to array function call.c
#include <stdio.h>
#include <stdlib.h>
void Function(int c[2][2]);
int main(){
int c[2][2],i,j;
printf("Enter 4 numbers:\n");
for(i=0;i<2;++i)
for(j=0;j<2;++j){
scanf("%d",&c[i][j]);
@henrybear327
henrybear327 / 7-1-4 how to use function to do array swap.c
Created November 16, 2014 07:50
7-1-4 how to use function to do array swap.c
#include <stdio.h>
#include <stdlib.h>
void func(int []);
int main()
{
int a[2] = {3,6};
printf("Original %d %d\n", a[0], a[1]);
func(a);
@turret-io
turret-io / aes_enc_dec.php
Last active March 26, 2025 08:04
AES encryption/decryption in PHP
<?php
// DEFINE our cipher
define('AES_256_CBC', 'aes-256-cbc');
// Generate a 256-bit encryption key
// This should be stored somewhere instead of recreating it each time
$encryption_key = openssl_random_pseudo_bytes(32);
// Generate an initialization vector
// This *MUST* be available for decryption as well