Skip to content

Instantly share code, notes, and snippets.

View hugefiver's full-sized avatar
😴
Moing (🐟)

Hugefiver hugefiver

😴
Moing (🐟)
View GitHub Profile
#
# OpenSSL example configuration file.
# This is mostly being used for generation of certificate requests.
#
# This definition stops the following lines choking if HOME isn't
# defined.
HOME = .
RANDFILE = $ENV::HOME/.rnd
@hugefiver
hugefiver / demo_let_function_in_Python.py
Created December 20, 2018 11:47
一些奇怪的示范
from itertools import starmap
points = [
(5, 16),
(15, 11),
(3, 5),
(28, 9),
(24, 25),
(11, 7),
(14, 22),
@hugefiver
hugefiver / joy.py
Last active October 13, 2020 12:23
随便写写
import re
p = re.compile(r'(get|set)(_[_a-zA-Z0-9]+)')
class A:
_x = 0
def __getattr__(self, attr):
m = p.match(attr)
if m:
return (lambda: getattr(self, m.group(2))) \
if m.group(1) == 'get' \
package main
import (
"math/rand"
"testing"
)
const Max = 100_0000
const Offset = 100
use std::{env::args, fs::{self, remove_file}, io::Write};
fn main() {
let argv = args();
let f: Vec<String> = argv.collect();
let (path, size_str, turn_str) = (&f[1].clone(), f[2].clone(), f[3].clone());
let turn = if let Ok(turn) = turn_str.parse::<u64>(){
turn
} else {
@hugefiver
hugefiver / set_proxy.ps1
Last active August 23, 2023 07:59
powershell set default proxy for `Invoke-WebRequest`
# set to system default proxy
[System.Net.WebRequest]::DefaultWebProxy = [System.Net.WebRequest]::GetSystemWebProxy()
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
# or a custom one
[System.Net.WebRequest]::DefaultWebProxy = New-Object System.Net.WebProxy("http://localhost:8080")
# or use username and password auth
[System.Net.WebRequest]::DefaultWebProxy = New-Object System.Net.WebProxy("http://localhost:8080",$true)
[System.Net.WebRequest]::DefaultWebProxy.Credentials = New-Object System.Net.NetworkCredential($user, $passwd)
;;; church.scm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Composition helper functions
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define compose
(lambda (f g)
@hugefiver
hugefiver / y.rkt
Last active September 28, 2021 16:31
别老惦记你那破{self}了 scheme
(require lazy)
(((λ (f) ((λ (x) (f (x x))) (λ (x) (f (x x))))) (λ (f) (λ (n) (if (> n 0) (string-append "别老惦记着你那破" (f (- n 1)) "了") "")))) 10)
@hugefiver
hugefiver / compiler.scm
Created October 28, 2021 02:51
Scheme2llvm compiler - Submitted by Paul on Oct 02, 2012 at 08:41
; A small self applicable scheme->llvm compiler.
;; , Tobias Nurmiranta
;;
;; -- To Use It --
;; Reads scheme-code from standard input.
;; cat code.ss|mzscheme --script compile.ss|llvm-as -f -o=test.bc;lli test.bc
;;
;; The compiler is painfully slow since it for testing purposes
;; compiles all help functions as well (see variable bootstrap).
;; It extends standard scheme with a subset of available
@hugefiver
hugefiver / gpg.sh
Created October 29, 2021 07:10
gpg knowledge
# generate a key pair
gpg --gen-key
# , with choices
gpg --full-gen-key # or `--full-generate-key`
# , need more choice, such as ecc key pair
gpg --full-gen-key --expert
# list keys
gpg --list-keys # ,or shorter `-k`
# , or secret key