Skip to content

Instantly share code, notes, and snippets.

View brianhsu's full-sized avatar

Brian Hsu brianhsu

View GitHub Profile
//=============================================================================
// Copyright ? 2008 Point Grey Research, Inc. All Rights Reserved.
//
// This software is the confidential and proprietary information of Point
// Grey Research, Inc. ("Confidential Information"). You shall not
// disclose such Confidential Information and shall use it only in
// accordance with the terms of the license agreement you entered into
// with PGR.
//
// PGR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
#include <stdio.h>
void test(int x, void * userdata) {
printf("x.value:%d\n", x);
int * pointer = (int *) userdata; // userdata 指到的記憶體位置
printf("userdata.address:%d\n", pointer);
int value = *pointer; // 取出這個位置實際存放的值
printf("userdata.value:%d\n", value);
/*********************************************************
* 把「所有訊息」、「我發表的訊息」等控制項展開至右下角
********************************************************/
#filter_tab li {clear:none;width:auto;margin-right:5px;}
#filter_tab a {height:25px !important; margin:0 !important;}
.timeline_control {margin-left:0;}
#timeline_control_holder {width:100%;}
#updater {left:5px;}
/************************************************
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, new X509TrustManager[]{new X509TrustManager(){
public void checkClientTrusted(X509Certificate[] chain,
String authType) throws CertificateException {}
public void checkServerTrusted(X509Certificate[] chain,
String authType) throws CertificateException {}
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}}}, new SecureRandom());
import akka.actor._
import akka.testkit._
import org.scalatest._
import scala.concurrent.duration._
object VendingMachine {
// 自動販賣機會用到的資料:目前投了多少錢,有什麼產品,使用者選了什麼產品
case class Product(price: Int, stock: Int)
case class MoneyAndProducts(currentMoneyInside: Int, products: Map[String, Product], selectedItem: Option[String] = None)
protected def getDataSet: Future[List[MarkerItem]] = {
val datasets = Array(
Future { new TrashCanDataGetter(getContext, "97cc923a-e9ee-4adc-8c3d-335567dc15d3", "area01.txt").getJsonData },
Future { new TrashCanDataGetter(getContext, "5fa14e06-018b-4851-8316-1ff324384f79", "area02.txt").getJsonData },
Future { new TrashCanDataGetter(getContext, "f40cd66c-afba-4409-9289-e677b6b8d00e", "area03.txt").getJsonData },
Future { new TrashCanDataGetter(getContext, "33b2c4c5-9870-4ee9-b280-a3a297c56a22", "area04.txt").getJsonData },
Future { new TrashCanDataGetter(getContext, "0b544701-fb47-4fa9-90f1-15b1987da0f5", "area05.txt").getJsonData },
Future { new TrashCanDataGetter(getContext, "37eac6d1-6569-43c9-9fcf-fc676417c2cd", "area06.txt").getJsonData },
Future { new TrashCanDataGetter(getContext, "46647394-d47f-4a4d-b0f0-14a60ac2aade", "area07.txt").getJsonData },
import org.eclipse.swt.widgets._
import org.eclipse.swt.layout._
import org.eclipse.swt.SWT
import java.awt.Color
import org.jfree.chart.ChartFactory
import org.jfree.chart.plot.XYPlot
import org.jfree.data.time.Minute
import org.jfree.data.time.TimeSeries
val ResizeFactor(originWidth, originHeight, factor) = ImageSampleFactor(fixedURL, thumbnailSize, thumbnailSize)
val options = new BitmapFactory.Options
options.inSampleSize = factor
if (originWidth <= 48 || originHeight <= 48) {
options.inDensity = 160
options.inScaled = false
options.inTargetDensity = 160
}
scala> val calendar = Calendar.getInstance
calendar: java.util.Calendar = java.util.GregorianCalendar[time=1441772897065,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Taipei",offset=28800000,dstSavings=0,useDaylight=false,transitions=42,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2015,MONTH=8,WEEK_OF_YEAR=37,WEEK_OF_MONTH=2,DAY_OF_MONTH=9,DAY_OF_YEAR=252,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=2,AM_PM=1,HOUR=0,HOUR_OF_DAY=12,MINUTE=28,SECOND=17,MILLISECOND=65,ZONE_OFFSET=28800000,DST_OFFSET=0]
scala> calendar.set(Calendar.DATE, 31)
scala> calendar.get(Calendar.MONTH)
res7: Int = 9
scala> calendar.get(Calendar.DATE)
res8: Int = 1
> db["dailyMachineCount"].find();
{ "_id" : ObjectId("55d13cb0fd61a53133a436ad"), "count_qty" : NumberLong(21372), "event_qty" : NumberLong(1936), "insertDate" : "2015-08-17", "machineID" : "E54", "status" : "01" }
{ "_id" : ObjectId("55d13cb0fd61a53133a436ae"), "count_qty" : NumberLong(14679), "event_qty" : NumberLong(32135), "insertDate" : "2015-08-17", "machineID" : "G20", "status" : "01" }
{ "_id" : ObjectId("55d13cb1fd61a53133a436b1"), "count_qty" : NumberLong(21643), "event_qty" : NumberLong(1198), "insertDate" : "2015-08-17", "machineID" : "E28", "status" : "01" }