Skip to content

Instantly share code, notes, and snippets.

View 0312birdzhang's full-sized avatar
:accessibility:
Find a job

BirdZhang 0312birdzhang

:accessibility:
Find a job
View GitHub Profile
@rswofxd
rswofxd / PySched.py
Created June 23, 2012 10:45
Python:任务调度,定时执行
#coding=utf-8
import time
import sched
import os
import threading
"""
sched模块,准确的说,它是一个调度(延时处理机制),每次想要定时执行某任务都必须写入一个调度。
使用步骤如下:
(1)生成调度器:
s = sched.scheduler(time.time,time.sleep)
# Usage: cas-get.sh {url} {username} {password} # If you have any errors try removing the redirects to get more information
# The service to be called, and a url-encoded version (the url encoding isn't perfect, if you're encoding complex stuff you may wish to replace with a different method)
DEST="$1"
ENCODED_DEST=`echo "$DEST" | perl -p -e 's/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg' | sed 's/%2E/./g' | sed 's/%0A//g'`
#IP Addresses or hostnames are fine here
CAS_HOSTNAME=team.eea.sk
#Authentication details. This script only supports username/password login, but curl can handle certificate login if required
USERNAME=$2
@skvark
skvark / sailfishsdkrepos.md
Last active April 4, 2024 04:50
Describes how to add repositories to Sailfish OS SDK (emulator and targets) and how to install them so that they can be used straight from the SDK.

This guide uses my own repos from Mer Obs. I found it very hard to find information about this so hopefully someone sees this useful. This short guide was created as a side product while I was creating these RPM packages (which wasn't so clear to me either).

  1. Add the repositories to the Mer SDK armv7hl and i486 targets (you'll have to ssh to the Mer SDK):

    • sb2 -t SailfishOS-armv7hl -m sdk-install -R zypper ar -f http://repo.merproject.org/obs/home:/skvark/latest_armv7hl tesseract-ocr
    • sb2 -t SailfishOS-armv7hl -m sdk-install -R zypper ar -f http://repo.merproject.org/obs/home:/skvark/latest_armv7hl leptonica
    • sb2 -t SailfishOS-i486 -m sdk-install -R zypper ar -f http://repo.merproject.org/obs/home:/skvark/latest_i486 tesseract-ocr
    • sb2 -t SailfishOS-i486 -m sdk-install -R zypper ar -f http://repo.merproject.org/obs/home:/skvark/latest_i486 leptonica
  2. Refresh sb2 -t SailfishOS-i486 -m sdk-install -R zypper ref and sb2 -t SailfishOS-armv7hl -m sdk-install -R zypper ref

@gkazior
gkazior / cas-get.sh
Last active September 22, 2023 12:19 — forked from dodok1/cas-get.sh
#!/bin/bash
# Usage: cas-get.sh {url} {username} {password} # If you have any errors try removing the redirects to get more information
# The service to be called, and a url-encoded version (the url encoding isn't perfect, if you're encoding complex stuff you may wish to replace with a different method)
DEST="$1"
ENCODED_DEST=`echo "$DEST" | perl -p -e 's/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg' | sed 's/%2E/./g' | sed 's/%0A//g'`
#IP Addresses or hostnames are fine here
CAS_HOSTNAME=galaxy:9143
@xero
xero / irc.md
Last active May 21, 2024 12:38
irc cheat sheet

IRC Reference

Not intended as a guide for newbies, more like a "cheat sheet" for the somewhat experienced IRC user, especially one who wields some power over a channel.

The Basics

  • /join #channel
    • Joins the specified channel.
  • /part #channel
  • Leaves the specified channel.
@TakWolf
TakWolf / ini.lua
Last active June 19, 2022 00:02
Lua读取ini文件
--===================--
-- INI格式读取工具类
--===================--
ini = {}
--[[
载入一个INI文件
--]]
function ini.load(filename)
local data = {}
@wonderbeyond
wonderbeyond / access_ip_limit.lua
Last active February 6, 2017 09:34
nginx ip access limit with lua
-- Access limitation based on predefined IP groups
-- TODO: 添加黑名单支持(通过 $deny_ip_groups 来指定禁止的IP分组)
--
-- FIXME: 去掉默认允许 staff 的特性, 改为默认允许所有(allow all), 根据需要明确指定.
-- 这样就可以把该机制全局应用, 目前只能应用在那些能确定允许IP范围的地址(比如 /admin/).
--
-- TODO:
-- 1. 扫描顺序问题?
-- 2. 不满足任何禁止和允许规则(如果先扫描允许规则且默认允许所有, 则没有这种情况), 如何处理?
-- 3. 允许和禁止的分组定义默认值如何设置?
@john-science
john-science / gzip_files_in_python.md
Last active May 27, 2021 16:47
Reading & Writing GZIP Files Faster in Python

Reading & Writing GZIP Files in Python

I have been testing various ways to read and write text files with GZIP in Python. There were a lot of uninteresting results, but there were two I thought were worth sharing.

Writing GZIP files

If you have a big list of strings to write to a file, you might be tempted to do:

f = gzip.open(out_path, 'wb')

for line in lines:

title date tags
GCMForMojo 的部署与设置
2017-01-21 11:07:03 -0800
GCM
Android

2017年2月6日更新:完善部分内容,更新内容

2017年2月8日更新:发现自己脑抽少写了一步较为关键的步骤,赶紧补上orz,连带解决笔误