Skip to content

Instantly share code, notes, and snippets.

@mag5323
mag5323 / foo.go
Created December 26, 2024 03:38
Fortify: Insecure Randomness
func NewPusher(host string, isSkipVerify bool) *Pusher {
tr := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: isSkipVerify,
PreferServerCipherSuites: true,
}, // cause Insecure Randomness
MaxIdleConnsPerHost: 100,
MaxConnsPerHost: 100,
IdleConnTimeout: 60 * time.Second,
}
<?php
$keyByPureString = [
'foo' => 'bar',
'foo2' => 'bar2',
];
$keyByIntAsString = [
'100' => 'hundred',
'1000' => 'thousand',
@mag5323
mag5323 / fb-chat.md
Last active September 29, 2017 02:05

運作分幾大類(auto reply、小精靈、按鈕、Filter text)

  • FB Developer Page
  • FB API explore
  • FB API auto reply (只有粉絲團有這個功能)
  • Graph API (私訊回覆使用者, 只能回覆一次)
  • 加入 scheduled_publish_time (unix timestamp) & published = false 設定排程發文
@mag5323
mag5323 / PHPUnit.md
Created November 30, 2016 10:13
A guide of PHPUnit

測試

  1. test class 要繼承 PHPUnit_Framework_TestCase e.g. class CartTest extends PHPUnit_Framework_TestCase {}

  2. PHPUnit 會將 test 開頭的方法視為測試方法 e.g. public function testEmpty() {}

    或者也可以在 docblock 中標註 @test, 範例如下

    /**
     * @test
v: [5] R: [1, 2] P: [5] X: []
BK( [1, 2, 5] , [] , [] )
v: [2] R: [1] P: [2, 5] X: []
BK( [1, 2] , [5] , [] )
v: [5] R: [1] P: [5] X: [2]
BK( [1, 5] , [] , [2] )
v: [1] R: [] P: [1, 2, 3, 4, 5, 6] X: []
BK( [1] , [2, 5] , [] )
v: [3] R: [2] P: [3, 5] X: [1]
Bitmap bmp1 = new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "STU.bmp");
Bitmap bmp2 = new Bitmap(256, 256);
Color myColor = new Color();
int T = 75;
for (int r = 0; r < bmp1.Height; r++) {
for (int c = 0; c < bmp1.Width; c++) {
myColor = bmp1.GetPixel(c, r);
if (myColor.G > T) {
import json
from networkx import *
from networkx.readwrite import json_graph
# gnp_random_graph(Nodes, Probability for edge creation)
G = gnp_random_graph(10, 0.4)
Degrees = G.degree()
MaxDeg = max(Degrees, key=Degrees.get)
Neighbors = G.neighbors(MaxDeg)

What is Git?

A free and open source distributed version control system.

Context

A simple situation showing when and how to use git

  • git init
  • git add
  • git commit
  • git remote
.highlight { background-color: #181818}
.highlight pre { font-size: 1em;
padding: 16px;
color: #F8F8F8;
font-family: "Lucida Console";
word-wrap: break-word;
word-break: break-all; }
.highlight pre .c { color: #75715e } /* Comment */
.highlight pre .err { color: #960050; background-color: #1e0010 } /* Error */