Skip to content

Instantly share code, notes, and snippets.

View rhyzx's full-sized avatar

Bin Xin rhyzx

  • Hangzhou, China
View GitHub Profile
@rhyzx
rhyzx / kuberedir.sh
Last active May 30, 2019 09:17
Kubernetes port redirect
#!/usr/bin/env bash
# https://github.com/txn2/kubefwd/issues/35#issuecomment-462524408
# Usage
# kuberedir 3306 172.10.0.10:3306
ID="kuberedir-$(date +%s)"
LOCAL_PORT=${1}
REMOTE=(${2//:/ })
REMOTE_ADDR=${REMOTE[0]}
@rhyzx
rhyzx / CSGO.md
Last active September 27, 2017 08:12 — forked from nickbudi/README.md
Budi's Counter-Strike: Global Offensive config

Budi's CS:GO Config

This is my constantly updated CS:GO autoexec config. Changelogs can be found under revisions here

Put autoexec.cfg in ...\Steam\steamapps\common\Counter-Strike Global Offensive\csgo\cfg or take what you want from it and add to your autoexec config!

After the Wild West Simulator 2015 update, video.txt needs to be put in ...\Steam\userdata\<Steam3 ID>\730\local\cfg

Launch Options

@rhyzx
rhyzx / list-ps4-multiplayer-games.js
Last active April 16, 2019 06:24
List PS4 multiplayer games
// paste to chrome console
;(async (count=2000 /*current 1200+ games*/) => {
const links = []
let start = 0
while (start < count) {
const size = Math.min(90, count - start) // max 99/req
start += size
@rhyzx
rhyzx / scroll.js
Last active August 29, 2015 14:08
full page scroll
// need jquery.mousewheel
// TODO disable fullpage scroll while scrolled to no sections
var $sections = $('.section')
var $window = $(window)
var deltaY = 0
$window.on('mousewheel', function (evt) {
evt.preventDefault()
deltaY += evt.deltaY
@rhyzx
rhyzx / selectize.js
Created July 11, 2014 09:06
disable Selectize sifter search engine
Selectize.prototype.search = function (query) {
return {
query: query,
tokens: [], // disable highlight
items: $.map(this.options, function (item, key) {
return {id: key}
})
}
}
@rhyzx
rhyzx / magnet.js
Created June 14, 2014 16:36
Magnet parsing API in node
// parse magnet
var magnetUri = require('magnet-uri')
var readTorrent = require('read-torrent')
var humanForamt = require('human-format')
app.get('/magnet', function (req, res) {
var uri = req.param('u')
var info = magnetUri(uri)
readTorrent('http://torrage.com/torrent/' + info.infoHash.toUpperCase() + '.torrent', function(err, torrent) {
if (err) return res.jsonp(500, { error: err })
@rhyzx
rhyzx / jquery-headroom.css
Last active October 29, 2020 17:50
jQuery and minimal version of headroom.js http://wicky.nillia.ms/headroom.js/ demo http://jsfiddle.net/JNAQD/1/
.headroom {
position: fixed;
top: 0;
-webkit-transition: top 0.15s;
transition: top 0.15s;
}
.headroom-hidden {
top: -60px;
}
@rhyzx
rhyzx / paginate.go.html
Last active October 28, 2017 05:54
Paginate logic
{{ $page := 10 }}
{{ $count := 20 }}
{{ $url := "/users?page=%v" }}
<ul class="pagination" role="navigation" aria-label="Pagination">
{{ if gt $page 1 }}
<li class="pagination-previous"><a href="{{ printf $url 1 }}" aria-label="Previous page"></a></li>
{{ else }}
<li class="pagination-previous disabled"></li>
{{ end }}
<h1>Fix multi button:submit for IE6</h1>
<form action="">
<button type="submit" name="s" value="1">S1</button>
<button type="submit" name="s" value="2">S2</button>
</form>
<!--[if lt IE 7]>
<script>
$('button:submit[name]').click(function () {
var $this = $(this)
$('button:submit', this.form).removeAttr('name')
@rhyzx
rhyzx / tap.js
Last active December 18, 2015 13:59
fast click for touch-based(mobile) browsers. require jQuery.
!function () {
if ('ontouchstart' in document) {
var touched, startX, startY
$(document)
.on('touchstart', function (evt) {
touched = evt.target
var touch = evt.originalEvent.touches[0]
startX = touch.clientX
startY = touch.clientY