Skip to content

Instantly share code, notes, and snippets.

View kernelhcy's full-sized avatar
🚁
living~

Congyu Huang kernelhcy

🚁
living~
View GitHub Profile
#!/bin/bash
URL="https://www.zq12369.com/"
DATA=`curl --noproxy "*" -s $URL`
FORECAST_DATA=`echo $DATA | pup 'div[class="forecast"] json{}'`
AQI_DATA=`echo $DATA | pup 'div[class="aqidetail"] json{}' | jq '.[0].children'`
curl -s 'https://www.zq12369.com/' | pup 'div[class="aqibg aqibanner1"]' | pup 'div[class="aqi"] json{}' | jq -cMr '.[0].text'
@kernelhcy
kernelhcy / weather.sh
Last active March 11, 2020 14:14
get current location's current weather
#! /bin/bash
#set -x
VERSION="1.6.1"
JQ_BIN=jq
LAST_TIME_FILE='/tmp/wea_last_time'
LAST_WEATHER='/tmp/wea_last_weather'
@kernelhcy
kernelhcy / weather.20m.sh
Last active March 10, 2020 06:00
bitbar
#!/bin/bash
JQ_BIN=/usr/local/bin/jq
#MENUFONT="size=13 font=UbuntuMono-Bold"
MENUFONT="size=15"
COLORS=("#0ed812" "#ffde33" "#ff9933" "#cc0033" "#660099" "#7e0023")
CURRENT_WEA_URL="https://tianqiapi.com/api/?version=v6&appid=76961778&appsecret=K1Evb4rc"
DATA=`curl --noproxy "*" -s "${CURRENT_WEA_URL}"`
#!/bin/bash
# <bitbar.title>Homebrew Updates</bitbar.title>
# <bitbar.author>killercup</bitbar.author>
# <bitbar.author.github>killercup</bitbar.author.github>
# <bitbar.desc>List available updates from Homebrew (OS X)</bitbar.desc>
exit_with_error() {
echo "err | color=red";
exit 1;
}
@kernelhcy
kernelhcy / bootup.sh
Created October 12, 2019 13:51
raspberry bootup script
#!/bin/bash
echo -e "\033[34m[umount] /home/hcy/mycloud/data... \033[0m"
umount /home/hcy/mycloud/data > /dev/null 2>&1
echo -e "\033[34m[umount] /home/hcy/mycloud/public... \033[0m"
umount /home/hcy/mycloud/public > /dev/null 2>&1
echo -e "\033[34m[umount] /home/hcy/mycloud/tddownloads... \033[0m"
umount /home/hcy/mycloud/tddownloads > /dev/null 2>&1
echo -e "\033[34m[mount] /nfs/Data to /home/hcy/mycloud/data... \033[0m"
class Linux_0_01
{
int restart_syscall(); //0
int exit(); //1
int fork(); //2
int read(); //3
int write(); //4
int open(); //5
int close(); //6
int waitpid(); //7
@kernelhcy
kernelhcy / btree_cpp.h
Created October 4, 2013 14:11
STX B+ Tree实现
/**
* \file include/stx/btree.h
* Contains the main B+ tree implementation template class btree.
*/
/*
* STX B+ Tree Template Classes v0.9
* Copyright (C) 2008-2013 Timo Bingmann <tb@panthema.net>
*
* Boost Software License - Version 1.0 - August 17th, 2003
@kernelhcy
kernelhcy / check_intent_exist.java
Created September 5, 2013 15:37
检查一个Intent是否能被处理。
public boolean isIntentExisting(Context context, String action) {
final PackageManager packageManager = context.getPackageManager();
final Intent intent = new Intent(action);
List<ResolveInfo> resolveInfo =
packageManager.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
if (resolveInfo.size() > 0) {
return true;
}
return false;
@kernelhcy
kernelhcy / parallel_job.sh
Created August 7, 2013 09:39
多任务并行执行脚本
#!/bin/bash
#
# 多个进行并行执行任务
#
SEND_THREAD_NUM=8
tmp_fifofile="/tmp/$$.fifo" # 脚本运行的当前进程ID号作为文件名
mkfifo "$tmp_fifofile" # 新建一个随机fifo管道文件
exec 6<>"$tmp_fifofile" # 定义文件描述符6指向这个fifo管道文件
rm $tmp_fifofile
@kernelhcy
kernelhcy / crop_image.java
Created August 7, 2013 05:06
Android中剪裁图片
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(Uri.fromFile(capturePicFile), "image/*");
//如何选择
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
//输出大小
intent.putExtra("outputX", 96);