Skip to content

Instantly share code, notes, and snippets.

View Arnie97's full-sized avatar

Arnie97

View GitHub Profile
@guojiex
guojiex / railway_graph.py
Created July 27, 2017 03:14
一个用来计算给定铁路线路图,对应两点所有路径的程序,用的深度优先回溯
# -*- coding: UTF-8 -*-
import sys, locale
import csv
import copy
reload(sys)
sys.setdefaultencoding('utf-8')
class Vertex(object):
@huyinghuan
huyinghuan / encrypt_file_pkcs5_pkcs7.go
Created May 31, 2017 07:44
golang encrypt with pkcs5 and pkcs7
package main
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"errors"
"io"
"io/ioutil"
@denisbrodbeck
denisbrodbeck / main.go
Last active February 2, 2023 22:35
How to generate secure random strings in golang with crypto/rand.
// License: MIT
package main
import (
"crypto/rand"
"fmt"
"math/big"
)
// GenerateRandomASCIIString returns a securely generated random ASCII string.
@fnielsen
fnielsen / Federated queries with Virtuoso.py
Created May 10, 2017 12:11
Federated queries with Virtuoso
"""Federated queries with Virtuoso."""
import sys
from SPARQLWrapper import SPARQLWrapper, JSON
QUERY_WIKIDATA = """
PREFIX wd: <http://www.wikidata.org/entity/>
@VojtechVitek
VojtechVitek / slice-batch-in-parallel.go
Last active December 17, 2024 21:46
Golang - Loop over slice in batches (run something in parallel on a sub-slice)
package main
import "fmt"
func main() {
slice := make([]int, 159)
// Split the slice into batches of 20 items.
batch := 20
@PSJoshi
PSJoshi / ip-ranges.txt
Created April 6, 2017 12:21
IP ranges for Google, Amazon etc
* CloudFare IP list: https://www.cloudflare.com/ips/
* Google's IP addresses:
nslookup -q=TXT _netblocks.google.com 8.8.8.8
nslookup -q=TXT _netblocks2.google.com 8.8.8.8
nslookup -q=TXT _netblocks3.google.com 8.8.8.8
Each of the above line will display a CIDR block or Google’s IP addresses.
* Amazon IP addresses: https://ip-ranges.amazonaws.com/ip-ranges.json
@danielv99
danielv99 / l2tpclient.sh
Last active July 28, 2025 20:35
L2TP VPN client on Linux Debian
# Requirements
# debian/ubuntu
apt-get -y update && apt-get -y upgrade
apt-get -y install strongswan xl2tpd libstrongswan-standard-plugins libstrongswan-extra-plugins
VPN_SERVER_IP=''
VPN_IPSEC_PSK='y'
VPN_USER=''
VPN_PASSWORD=''
@pts
pts / tinygccpe.scr
Last active November 20, 2024 18:45
GNU ld linker script for smaller PE .exe output
/* tinygccpe.scr: GNU ld linker script for smaller PE .exe output
* by [email protected] at Fri Feb 3 15:41:13 CET 2017
*
* It's different from the default by:
*
* * It drops initializers (e.g. .init, .ctors), and fails if the code tries
* to use them.
* * It drops exceptions (e.g. .pdata), and fails if the code tries
* to use them.
* * It merges .data and .rdata.
@jethrogb
jethrogb / coordinate.rs
Last active August 17, 2021 10:08
Custom Diesel wrapper type example
/// This defines a custom Diesel type for storing a 6-bit integer and a 58-bit
/// integer in the same 64-bit SQL column
use std::error::Error;
use std::fmt;
use std::io::Write;
use diesel::backend::Backend;
use diesel::types::{FromSqlRow,FromSql,ToSql,HasSqlType,IsNull,BigInt,Nullable};
use diesel::expression::AsExpression;
use diesel::row::Row;
@max-mapper
max-mapper / index.sh
Last active November 2, 2023 10:13
generate ES512 and RS256 elliptic curve keypairs for JWT JWK (JSON Web Token JSON Web Key) using openssl
# RS256
# private key
openssl genrsa -out rs256-4096-private.rsa 4096
# public key
openssl rsa -in rs256-4096-private.rsa -pubout > rs256-4096-public.pem
# ES512
# private key
openssl ecparam -genkey -name secp521r1 -noout -out ecdsa-p521-private.pem
# public key