Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
function cpuinfo() {
cpu_model=`cat /proc/cpuinfo|grep "model name"|head -1|awk -F: '{print $2}'`
cpu_num=`cat /proc/cpuinfo|grep "core id"|grep "0"|uniq -c|awk '{print $1}'`
cpu_cores=`cat /proc/cpuinfo|grep "processor"|wc -l`
single_cores=`expr ${cpu_cores} / ${cpu_num}`
printf "CPU: ${cpu_model} (${cpu_num}*${single_cores}Cores)\n"
#/bin/sh
#line='id:2377893499379884 ip:127.0.0.1 port:443 ak:sdjh sk:jsdhfhjdsh bucket:men object:zzzz.vhd size:10240 encryp:1'
line=`cat image.cfg|grep 2377893499379884`
function map_get()
{
dict=$1
key=$2
default_value=$3
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cjson/cJSON.h>
#define ERR_INVALID_URL (-10)
#define ERR (-1)
int filter_single_sensitive_word(const cJSON *item, char *name)
{
@cosysn
cosysn / readfree.py
Created July 13, 2017 06:09
能够自动在readfree网站上签到的脚本
import requests
import logging
url='http://readfree.me/accounts/checkin'
cookie_str='' # 需要登录到readfree上获取当时的cookie值,然后直接使用该cookie值进行登录签到
logging.basicConfig(level=logging.INFO,
filename='/var/log/readfree_auto_sig.log',
filemode='a',
format='%(asctime)s - [line:%(lineno)d] - %(levelname)s: %(message)s')
@cosysn
cosysn / hexdump.c
Created April 11, 2017 08:57
移植 Linux Kernel 的 print_hex_dump 函数到 Windows 驱动中,帮助 dump 二进制数据。
CHAR hex_asc[] = "0123456789abcdef";
#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
#define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4]
#define TracePrintEx(Fmt, ...) \
do\
{\
DbgPrintEx(DPFLTR_FASTFAT_ID, DPFLTR_ERROR_LEVEL, Fmt, __VA_ARGS__); \
}while (0)
@cosysn
cosysn / win_init.el
Last active April 9, 2017 11:48
支持Windows下将 Spacemacs 放置在 HOME 目录外指定的目录下
;;; init.el --- Spacemacs Initialization File
;;
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner sylvain.benner@gmail.com
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
@cosysn
cosysn / mpiodisk.ps1
Created March 22, 2017 06:53
通过WMI来获取MPIO Disk的信息
$MPIODisks = Get-WmiObject -Namespace "root\wmi" -Class mpio_disk_info |
Select-Object "DriveInfo"
foreach ($Disk in $MPIODisks) {
$mpiodrives = $disk.DriveInfo
foreach ($Drive in $mpiodrives) {
Write-Host "Drive : " $Drive.Name
Write-Host "Path : " $Drive.NumberPaths
Write-Host "Serial Num: " $Drive.SerialNumber
@cosysn
cosysn / mpiodisk.ps1
Created March 22, 2017 06:53
通过WMI来获取MPIO Disk的信息
$MPIODisks = Get-WmiObject -Namespace "root\wmi" -Class mpio_disk_info |
Select-Object "DriveInfo"
foreach ($Disk in $MPIODisks) {
$mpiodrives = $disk.DriveInfo
foreach ($Drive in $mpiodrives) {
Write-Host "Drive : " $Drive.Name
Write-Host "Path : " $Drive.NumberPaths
Write-Host "Serial Num: " $Drive.SerialNumber
@cosysn
cosysn / mkdir_kernel.c
Created March 22, 2017 00:36
在内核态创建目录
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/syscalls.h>
#include <linux/security.h>
#include <linux/namei.h>
static int my_mkdir(const char *name, umode_t mode)
{
@cosysn
cosysn / 0_reuse_code.js
Last active August 29, 2015 14:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console