Skip to content

Instantly share code, notes, and snippets.

@tangblack
tangblack / rxpermissions_template.java
Last active May 8, 2018 07:00
rxpermissions_template
public class FooActivity extends AppCompatActivity
{
private static final String TAG = FooActivity.class.getSimpleName();
private static final int REQUEST_PERMISSION_SETTING = 109;
@Override
protected void onCreate(Bundle savedInstanceState)
{
// 省略...
// The BlogId of a test blog.
String TEST_BLOG_ID = "8070105920543249955";
// Configure the Java API Client for Installed Native App
HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
JsonFactory JSON_FACTORY = new JacksonFactory();
// set up authorization code flow
AuthorizationCodeFlow flow = new AuthorizationCodeFlow.Builder(
BearerToken.authorizationHeaderAccessMethod(),
#!/usr/local/bin/python
import commands
def getIpList():
ipList = commands.getoutput("/sbin/ifconfig | grep -i \"inet\" | grep -iv \"inet6\" | " +
"awk {'print $2'} | sed -ne 's/addr\:/ /p'")
return ipList
import smtplib
#!/usr/local/bin/python
import time
import RPi.GPIO as GPIO
# http://coopermaa2nd.blogspot.tw/2010/12/arduino-lab6.html
B0 = 31
C1 = 33
CS1 = 35
D1 = 37
mkdir /path/to/your/jenkins_vm_project
cd /path/to/your/jeknins_vm_project
# 查看你抓下來的 box
vagrant box list
# centos64_x86_64 是我替 CentOS6.4 64 取的 box 名稱
vagrant init centos64_x86_64
# vagrant init 會自動產生 Vagranfile
<?xml version="1.0" encoding="UTF-8"?>
<job-scheduling-data
xmlns="http://www.quartz-scheduler.org/xml/JobSchedulingData"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.quartz-scheduler.org/xml/JobSchedulingData http://www.quartz-scheduler.org/xml/job_scheduling_data_2_0.xsd"
version="1.8">
<schedule>
<job>
org.quartz.threadPool.threadCount=2 # 用2個 Thread
org.quartz.plugin.jobInitializer.class=org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin # 用 XML(quartz_data.xml) 設定排程工作
<servlet>
<servlet-name>QuartzInitializer</servlet-name>
<servlet-class>org.quartz.ee.servlet.QuartzInitializerServlet</servlet-class>
<init-param>
<param-name>shutdown-on-unload</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>wait-on-shutdown</param-name>
<param-value>true</param-value>
#https://www.packtpub.com/books/content/introduction-logging-tomcat-7
#http://tomcat.apache.org/tomcat-7.0-doc/logging.html
handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler # 有 File 和 Console 兩個 Handler
############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0