Skip to content

Instantly share code, notes, and snippets.

@ihciah
ihciah / README.MD
Last active August 19, 2024 12:56
A reverse proxy for Telegram Bot API on Aliyun Function Compute / Cloudflare Workers

A reverse proxy for Telegram Bot API on Aliyun Function Compute / Cloudflare Workers

To help users in China mainland access telegram api stably and conveniently with low cost, this script maybe the one you need.

The server-less means you don't have to run a server to proxy the requests, just pay as you go.

Usage

Edit key_prefix, set it to the prefix of you bot address(like /bot563441998:) can avoid abusing.

@andreasplesch
andreasplesch / README.md
Last active September 19, 2015 13:20
d3 color scale from ncar ncl color table

I am interested in an easy way to generate a color table with a defined number of colors for use with this:

http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_spheresensor.xhtml

Here is a D3 way to use the many color maps NCAR's NCL provides. The original source file is read, so all of the parsing and then color scale (mapping) work takes place in the callback. The original tables directly map to D3 linear scales with a segmented definition. Hcl interpolation looks better for oversampling. The resampling is then simply an application of a new input domain to the piecewise color scale function. Since I use table cells to draw the color tables, there is a somewhat clever function to keep the table at a constant total width by inserting an extra width pixel every so many columns.

@andriimartynov
andriimartynov / CityHash.java
Created March 22, 2015 15:46
CityHash for Java
/*
* Copyright (C) 2012 tamtam180
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@SaneMethod
SaneMethod / jquery-ajax-blob-arraybuffer.js
Last active March 14, 2022 17:57
Ajax transports to allow the sending/receiving of blobs and array buffers via the familiar jquery ajax function.To send, set data to the blob or arraybuffer to be sent, and add 'processData:false' to the ajax options.To receive, specify the 'dataType' as blob or arraybuffer in the ajax options.
(function($){
/**
* Register ajax transports for blob send/recieve and array buffer send/receive via XMLHttpRequest Level 2
* within the comfortable framework of the jquery ajax request, with full support for promises.
*
* Notice the +* in the dataType string? The + indicates we want this transport to be prepended to the list
* of potential transports (so it gets first dibs if the request passes the conditions within to provide the
* ajax transport, preventing the standard transport from hogging the request), and the * indicates that
* potentially any request with any dataType might want to use the transports provided herein.
*
@vishvananda
vishvananda / tunnel.sh
Created October 22, 2013 03:16
Script to set up an ipsec tunnel between two machines For Example: ./tunnel.sh 10.10.10.1 10.10.10.2 192.168.0.1 192.168.0.2 would set up an ipsec tunnel over 10.10.10.1 address using 192.168.0.1 as a virtual address passwordless sudo required for user on remote machine
#!/bin/bash
if [ "$4" == "" ]; then
echo "usage: $0 <local_ip> <remote_ip> <new_local_ip> <new_remote_ip>"
echo "creates an ipsec tunnel between two machines"
exit 1
fi
SRC="$1"; shift
DST="$1"; shift
@dmitshur
dmitshur / gist:6927554
Last active October 5, 2024 06:15
[Legacy GOPATH mode] How to `go get` private repos using SSH key auth instead of password auth.
@jesperdj
jesperdj / MersenneTwister.scala
Created March 25, 2011 22:28
Mersenne Twister - Random number generator
// Mersenne Twister 19937
// Based on code from: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
// Note: This implementation is not thread-safe!
final class MersenneTwister (seed: Int = 5489) {
private val N = 624
private val M = 397
private val MatrixA = 0x9908b0dfL
private val UpperMask = 0x80000000L
@is
is / msgpack-http.py
Created September 27, 2010 16:11
Sample code, msgpack over http post in Python.
import msgpack
import urllib2
def main():
m = msgpack.packb(['hello', 12])
u = urllib2.urlopen('http://localhost:8080/0', m)
s = u.read()
u.close()
print (len(m), len(s))
@is
is / settings.xml
Created September 25, 2010 06:52
My maven settings file
<settings>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://si.io8.org/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>