Skip to content

Instantly share code, notes, and snippets.

View edwardinubuntu's full-sized avatar

Edward Chiang edwardinubuntu

View GitHub Profile
@edwardinubuntu
edwardinubuntu / ContactsAPITest.java
Created October 16, 2017 10:55
AndroidTestCase Example
package tw.com.dynasafe.cix.service;
import android.test.AndroidTestCase;
import android.util.Log;
import com.google.gson.JsonObject;
import java.util.List;
import java.util.concurrent.CountDownLatch;
package tw.soleil.tscdemo;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
//
// View+Extension.swift
// carce-ios
//
// Created by Edward Chiang on 12/14/15.
// Copyright © 2015 Soleil Studio. All rights reserved.
//
import UIKit
String summary = garage.getDescription();
if (summary != null) {
// Handle summary code
Log.d(Carce.TAG, "Summary: " + summary);
Document document = Jsoup.parse(summary);
// document.select("img[attribute]").remove();
document.select("img").removeAttr("style");
document.select("img").attr("width", "100%");
document.select("img").attr("height", "auto");
logging.debug('sheet_id: ' + str(sheet_id))
logging.debug('row.id: ' + str(eachUpdate['row.id']))
# Find the row by id
row_to_update = self.smart_sheet_authorized.Sheets.get_row(sheet_id, int(eachUpdate['row.id']))
# Check the update from GS is in SS Columns
if eachUpdate['column'] in column_map:
# Get the SS column id from columns map
smart_sheet_column = column_map[eachUpdate['column']]
# Get cell whict want to update
@edwardinubuntu
edwardinubuntu / callcred.py
Last active July 7, 2017 07:48
Support soft wrap
flow = flow_from_clientsecrets('client_secret.json',
scope='https://spreadsheets.google.com/feeds',
redirect_uri='http://localhost/auth_return')
storage = Storage('creds.data')
credentials = run_flow(flow, storage)
logging.info("access_token: %s" % credentials.access_token)
@edwardinubuntu
edwardinubuntu / log.txt
Created June 28, 2017 07:14
TSC printer print command log
Command: 
 TEXT 290,50,”TST24.BF2",0,1,1,3,”0001(1/1)”
 TEXT 25,78,”TST24.BF2",0,1,1,”檸檬汁(中)”
 TEXT 25,106,”TST24.BF2",0,1,1,””
 TEXT 25,134,”TST24.BF2",0,1,1,”售價$45 (外帶)”
 TEXT 25,162,”TST24.BF2",0,1,1,”一小時內飲用最佳”
 TEXT 25,190,”TST24.BF2",0,1,1,”日傑茶坊 TEL:0000–0000"
@edwardinubuntu
edwardinubuntu / OrderParseWriter.java
Last active June 27, 2017 17:04
How to convert source object to target object.
private Order convert(ShoppingOrder shoppingOrder) {
ModelMapper modelMapper = new ModelMapper();
Order order = modelMapper.map(shoppingOrder, Order.class);
return order;
}
@edwardinubuntu
edwardinubuntu / TripMembersSection.java
Last active June 27, 2017 07:52
Use DownloadImageTask in UI.
userImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
DownloadImageTask downloadImageTask = new DownloadImageTask();
downloadImageTask.setOnBitmapDownloadListener(new DownloadImageTask.OnBitmapDownloadListener() {
@Override
public void result(Bitmap bitmap) {
if (bitmap != null) {
userImageView.setImageBitmap(BitmapLoader.resizeImageForImageView(bitmap,
Math.max(userImageView.getMeasuredWidth(), userImageView.getMeasuredHeight())));
}
}
@edwardinubuntu
edwardinubuntu / DownloadImageTask.java
Created June 27, 2017 05:01
Download image with OKHttpClient in AsyncTask.
package io.triptime.android.service;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.util.Log;
import java.io.IOException;
import io.triptime.android.TripTime;