Skip to content

Instantly share code, notes, and snippets.

Avatar
🤕
How can I have a good chat with her?

Ting Chen yo1995

🤕
How can I have a good chat with her?
View GitHub Profile
@yo1995
yo1995 / downloadImages.js
Last active Nov 25, 2019
Download all images in a web page
View downloadImages.js
// Image count
var imgTotal = 0;
var imgLoaded = 0;
// Get file name from a URL
function getFileName(o) {
var pos = o.lastIndexOf("/");
return o.substring(pos+1);
}
@yo1995
yo1995 / color.swift
Created Oct 18, 2019
Swift any string to HEX color string
View color.swift
import Foundation
func stringColorCode(_ s: String?) -> String {
guard let IDString = s else {
return "000000"
}
let hashInt = IDString.hashValue
let c = hashInt & 0xFFFFFF
let hexString = String(format:"%06x", c)
return hexString.suffix(6).uppercased()
@yo1995
yo1995 / LCGrand.cpp
Last active Jul 8, 2019
C++线性同余随机数生成
View LCGrand.cpp
// Example program
#include <iostream>
#include <string>
inline int random1() {
static int seed = 703; // seed can be picked randomly
return seed = int(seed*48271LL%2147483647);
}
int main() {
You can’t perform that action at this time.