Skip to content

Instantly share code, notes, and snippets.

View hxsf's full-sized avatar

呼啸随风 hxsf

  • China Suzhou
View GitHub Profile
@hxsf
hxsf / License
Last active April 21, 2022 07:22
Golang to snake_case
MIT License
Copyright (c) [2021] [hxsf]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@hxsf
hxsf / route_match.js
Last active March 3, 2020 04:30
route match
function check_item(rule, url, params) {
var pos_s = rule.indexOf('{')
var pos_e = rule.indexOf('}')
if (pos_s >= 0 && pos_e) {
var r_after = rule.slice(0, pos_s)
var key = rule.slice(pos_s + 1, pos_e)
var r_be = rule.slice(pos_e + 1, rule.length)
var pos_2 = url.lastIndexOf(r_be)
var u_after = url.slice(0, pos_s)
var value = url.slice(pos_s, pos_2)
@hxsf
hxsf / git-shell.ts
Last active September 2, 2019 08:51
util to control git binary.
import * as cp from 'child_process'
import { EventEmitter } from 'events'
import * as fs from 'fs'
import * as iconv from 'iconv-lite'
import * as os from 'os'
import * as path from 'path'
import { assign, debug, denodeify, dispose, groupBy, IDisposable, mkdirp, toDisposable, uniqBy } from './utils';
// tslint:disable:member-ordering
#!/usr/bin/env node --harmony
var program = require('commander');
program
.version('0.1.0')
.description('list packages installed')
.parse(process.argv);
console.log('[demo-list]', process.execArgv)
@hxsf
hxsf / README.md
Last active January 10, 2018 09:06
JS Bin// source http://jsbin.com/lulezixobe

a IP/Subnet input component write by only javascript.

feature

  • auto complite
  • Delete & BackSapce Support
  • ArrowLeft & ArrowRight Support
  • IP Support
  • Subnet Support
  • Paste Support
@hxsf
hxsf / str_gen.js
Created February 26, 2017 01:56
实现长度为 m 的字符串 a 到长度为 n 的字符串 b 的遍历
function* gen(min, max) {
var arr = new Array(min).fill(0)
arr[arr.length - 1] = 1
while (arr.length <= max) {
yield arr.map(x => String.fromCharCode(96 + x)).join('')
arr[arr.length - 1]++
for (var i = arr.length - 1; i >= 0; i--) {
if (arr[i] > 26) {
arr[i] -= 26
if (i == 0) {