Skip to content

Instantly share code, notes, and snippets.

View kaleocheng's full-sized avatar
🦀

Kaleo kaleocheng

🦀
View GitHub Profile
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build !plan9
package main
import (
"log"
#!/bin/bash
source ./admin.sh
nova list --all-tenant | grep ERROR|awk '{print $2}' > ./uuid.temp
cat ./uuid.temp | xargs -n1 nova reset-state --active
cat ./uuid.temp |xargs -n1 nova reboot --hard
rm -f ./uuid.temp
@kaleocheng
kaleocheng / image.py
Created June 19, 2016 15:16
更改图片文件名
import os.path, os, time, datetime
time_now = datetime.datetime.now()
for root, dirs, files in os.walk("image"):
for file_name in files:
file_path = root + '/' + file_name
file_exten = os.path.splitext(file_name)[1]
if not file_name[0] == '.':
if (file_exten == '.jpg' or file_exten == '.png' or file_exten == '.JPG' or file_exten == '.mp4' or file_exten == '.jpeg' or file_exten == '.mov' or file_exten == '.gif'):
#m_time = datetime.datetime.fromtimestamp(os.path.getmtime(file_path))
new_file_name = time_now.strftime('%Y-%m-%d %H.%M.%S') + file_exten.lower()
@kaleocheng
kaleocheng / gui.py
Last active August 29, 2015 14:25 — forked from sp3c73r2038/gui.py
responsible GUI with multiprocessing.
# -*- coding: utf-8 -*-
from datetime import datetime
from multiprocessing import Process
from time import sleep
import tkinter as tk
class Application(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
@kaleocheng
kaleocheng / delete_blank_images.py
Last active August 29, 2015 14:22
删除某个文件夹里的讨厌的空白图像(圣光)
# -*- coding: utf-8 -*-
# !/usr/bin/python
# Filename: change_tint2_color.py
# 删除某个文件夹里的讨厌的空白图像(圣光)
from PIL import Image
import fnmatch
import os
@kaleocheng
kaleocheng / pythonGtkTest.py
Created July 17, 2014 08:38
PyGtk写的51串口通信上位机
#!/usr/bin/python
#This is a PyGTK test
import gtk
import sys
class PyApp(gtk.Window):
def __init__(self):
super(PyApp,self).__init__()
self.set_title("PWM")
self.set_size_request(250,200)
@kaleocheng
kaleocheng / SpeedTest.c
Last active August 29, 2015 14:04
PWM调速和光电传感器测速
#include<reg52.h>
#include<stdio.h>
#define uchar unsigned char
#define uint unsigned int
#define KongNums 20 //码盘上孔的数量
#define HighTime 500 //高电平持续时间
#define LowTime 500 //低电平持续时间
@kaleocheng
kaleocheng / movie.tex
Created July 9, 2014 07:45
用LaTeX向pdf中插入多媒体文件
\documentclass[12pt,landscape]{article}
\usepackage{geometry}
\geometry{verbose,letterpaper}
\usepackage{movie15}
\usepackage{hyperref}
\begin{document}
Whispering-gallery mode in a auarter circle:
\begin{figure}[ht]
\includemovie[
poster,
@kaleocheng
kaleocheng / change_brightness.sh
Last active August 29, 2015 14:03
根据时间改变屏幕的亮度(配合crontab使用)
#!/usr/bin/env bash
#Filename: change_brightness.sh
#这个脚本会根据当前时间来改变系统屏幕的亮度,最好配合crontab来使用,而且我把他放在了/etc/rc.local中开机执行.
current_time=`date +%H`
case $current_time in
0|1|2|3|4|5|6|22|23)
#echo 'Night'
#这一句得用root权限来执行(sudo在这里也不行)
echo 0 > /sys/class/backlight/acpi_video0/brightness
#now=0
@kaleocheng
kaleocheng / shift_wallpaper.sh
Created June 30, 2014 08:15
随机换壁纸
#!/usr/bin/env bash
#Fielname: shiftwallpaper(.sh)
WALLPAPER_DIR='/home/kaleo/images/wallpapers/shared'
WAIT=1800
function load_wallpapers()
{
n=0