Skip to content

Instantly share code, notes, and snippets.

View kaleocheng's full-sized avatar
🦀

Kaleo kaleocheng

🦀
View GitHub Profile
@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 / 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 / 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 / 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()
#!/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
// 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"
#!/usr/bin/env python2
from SimpleHTTPServer import SimpleHTTPRequestHandler
import BaseHTTPServer
class CORSRequestHandler (SimpleHTTPRequestHandler):
def end_headers (self):
self.send_header('Access-Control-Allow-Origin', '*')
SimpleHTTPRequestHandler.end_headers(self)
if __name__ == '__main__':
@kaleocheng
kaleocheng / rs-connect.js
Created August 24, 2017 09:26 — forked from chrisckchang/rs-connect.js
replica set connection with nodejs native
/**
* MongoDB NodeJS Driver Production Connection Example
*
* Copyright (c) 2015 ObjectLabs Corporation
* Distributed under the MIT license - http://opensource.org/licenses/MIT
*/
var MongoClient = require('mongodb').MongoClient;
/**
@kaleocheng
kaleocheng / equals.go
Created September 12, 2017 02:46
Equals check if two Resources are equals.
// Equals check if two Resources are equals.
func Equals(r1, r2 *Obj) bool {
r1JSON, _ := json.Marshal(r1)
r2JSON, _ := json.Marshal(r2)
if string(r1JSON) == string(r2JSON) {
return true
}
return false
}
# Add init repo
mkdir hello
cd hello
git init
echo "Hello World" > README.md
git add . && git commit -m "Add README.md"
# Add empty vendor dir
git checkout --orphan vendor