Skip to content

Instantly share code, notes, and snippets.

View wgqimut's full-sized avatar
🎯
Focusing

wgqimut wgqimut

🎯
Focusing
View GitHub Profile
@wgqimut
wgqimut / cvim.rc
Created March 19, 2020 03:52
chrome vim config
set smoothscroll
map <C-d> scrollPageDown
map <C-u> scrollPageUp
@wgqimut
wgqimut / Embedded Python in BASH
Created July 19, 2018 13:33 — forked from welbornprod/Embedded Python in BASH
A little trick to embed python code in a BASH script.
#!/bin/bash
# Here are some embedded Python examples using Python3.
# They are put into functions for separation and clarity.
# Simple usage, only using python to print the date.
# This is not really a good example, because the `date`
# command works just as well.
function date_time {
@wgqimut
wgqimut / check_machine.sh
Last active September 21, 2017 06:10
linux top monitor
#!/usr/bin/env bash
node_num=10
top_command='ssh xt% top -d 2.0 -b -n 4 | grep -e Cpu -e "load average" -e "KiB Mem" -e RES -e gluster > top_stat%.txt'
seq ${node_num} | xargs -n 1 --max-procs=${node_num} -I % sh -c "${top_command}"
for i in {1..10}; do
echo "top_stat$i.txt"
done | xargs tail -vn +1 | grep --color -E '.*glusterfsd.*|$' # highline search pattern line
for i in {1..10}; do
@wgqimut
wgqimut / gene_fix_num.py
Created February 23, 2017 10:24
generate fix number
import random
import string
def generate_fixed_number(fixed_width):
random_number = random.sample(string.digits, fixed_width-1)
random_number.insert(0, str(random.randint(1, 9)))
gfid = int(''.join(random_number))
return gfid
def main():
@wgqimut
wgqimut / Base64.md
Last active August 29, 2015 14:21 — forked from barrysteyn/Base64.md

OpenSSL Base64 Encoding: Binary Safe and Portable

Herewith is an example of encoding to and from base64 using OpenSSL's C library. Code presented here is both binary safe, and portable (i.e. it should work on any Posix compliant system e.g. FreeBSD and Linux).

License

The MIT License (MIT)

Copyright (c) 2013 Barry Steyn

#!/usr/bin/env python
#taken from http://29a.ch/2009/3/17/autostart-autorun-with-python
#example:
#import os
#import autorun
#autorun.add("myapp", os.path.abspath(__file__))
"""A simple crossplatform autostart helper"""
#!/usr/bin/python
#-*- coding: utf-8 -*-
'''
http://segmentfault.com/q/1010000000174213
Python验证用户输入IP的合法性,有什么好方法吗?
如:<input type="text" name="ip" id="ip" /> 在text里表单输入的字符串
'''
//! @Alan
//!
//! Exercise 6.33:
//! Write a recursive function to print the contents of a vector.
//!
// question about this exercise on stackoverflow:
// http://stackoverflow.com/questions/20184299/how-to-understand-and-fix-the-segmentation-fault-in-this-code
#include <iostream>
#include <string>
@wgqimut
wgqimut / hash.c
Last active August 29, 2015 14:07
/* @create by ilbsmart */
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
typedef struct list_t {
char *str;
struct list_t *next;
}list_t;