Skip to content

Instantly share code, notes, and snippets.

View ccjeng's full-sized avatar

Andy Cheng ccjeng

  • Taiwan
View GitHub Profile
@ccjeng
ccjeng / productkey.vbs
Created November 25, 2020 00:38
Get Windows 7 Product Key
Set WshShell = CreateObject("WScript.Shell")
MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"))
Function ConvertToKey(Key)
Const KeyOffset = 52
i = 28
Chars = "BCDFGHJKMPQRTVWXY2346789"
Do
Cur = 0
@ccjeng
ccjeng / gulpfile.js
Last active April 10, 2017 02:25
gulpfile.js
'use strict';
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var sass = require('gulp-sass');
var cssminify = require('gulp-clean-css');
var imagemin = require('gulp-imagemin');
var connect = require('gulp-connect');
var livereload = require('gulp-livereload');
@ccjeng
ccjeng / TextToSpeech.swift
Created November 3, 2016 05:41
Swift TextToSpeech sample
import UIKit
import AVFoundation
class ViewController: UIViewController {
@IBOutlet weak var txtFieldText: UITextField!
@IBOutlet weak var labelMessage: UILabel!
let synth = AVSpeechSynthesizer()
var myUtterance = AVSpeechUtterance(string: "")
@ccjeng
ccjeng / FirebaseRemoteConfig.java
Last active September 26, 2016 04:30
Firebase Remote Config
final FirebaseRemoteConfig mRemoteConfig = FirebaseRemoteConfig.getInstance();
// cache expiration in seconds
long cacheExpiration = 3600; //1 hour
//Settings
FirebaseRemoteConfigSettings remoteConfigSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(true)
.build();
mRemoteConfig.setConfigSettings(remoteConfigSettings);
@ccjeng
ccjeng / getPersons.java
Last active September 11, 2016 13:27
Realm rxjava sample
public Observable<List<Person>> getPersons() {
final Realm realm = Realm.getDefaultInstance();
return realm.where(Person.class).findAll() //get Persons from DB
.asObservable()
.map(new Func1<RealmResults<Person>, List<Person>>() {
@Override
public List<Person> call(RealmResults<Person> person) {
return realm.copyToRealm(person); //Convert RealmResults to List
}
@ccjeng
ccjeng / addPerson.java
Created September 11, 2016 12:50
Realm Transaction Block
public void addPerson() {
final Realm realm = Realm.getDefaultInstance();
//It automatically handles begin/commit, and cancel if an error happens
realm.executeTransactionAsync(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
Person p = realm.createObject(City.class);
p.setId("00002");
c.setName("Steve Jobs");
@ccjeng
ccjeng / deleteRealmIfMigrationNeeded.java
Created September 11, 2016 12:43
deleteRealmIfMigrationNeeded
import android.app.Application;
import io.realm.RealmConfiguration;
public class MyApplication extends Application {
public static RealmConfiguration realmConfiguration;
@Override
public void onCreate() {
super.onCreate();
realmConfiguration = new RealmConfiguration.Builder(this)
@ccjeng
ccjeng / PlaceAutoComplete.java
Created September 10, 2016 12:54
Google Places Autocomplete API
private PlaceAutocompleteAdapter adapter;
private AutoCompleteTextView autocompleteView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
buildGoogleApiClient();
import requests
from bs4 import BeautifulSoup
urlRoot = 'http://book.tpml.edu.tw/webpac/'
dateRange = '2016-08-01%2C2016-08-31'
rows = '1000'
link = urlRoot + 'newbooknotftdList.do?sortfield=MarcInsertDate&sorttype=1&showtuple=' + rows + '&newbookdatebet='+ dateRange +'&pubyear=all&language=chi&classtype=all&classno=all&classno10=all&keepsiteid=all&type=&categoraycode=-1&bookstatus=all&collection=all&viewmode=0'
res = requests.get(link)
soup = BeautifulSoup(res.text.encode('utf-8'), 'html.parser')
@ccjeng
ccjeng / NewTaipeiRecycle.json
Last active August 12, 2018 07:12
新北市黃金資收站設置資訊 / 臺北市垃圾資源回收、廚餘回收限時收受點 / 臺北市週三、週日廚餘專用限時收受點
[{"number":"1","district":"板橋區","village":"中山里","no":"01-001","name":"林爽","address":"板橋區大觀路2段37巷280號","tel":"02-82752345","recycle_address":"板橋區大觀路2段37巷280號","open_time":"每週六早上 06:00--10:00","state":"營運中","twd97X":"295382.67","twd97Y":"2765962.44","wgs84aX":"121.449601129258","wgs84aY":"25.0009896915842"},{"number":"2","district":"板橋區","village":"廣德里","no":"01-002","name":"周建和","address":"板橋區重慶路283號","tel":"02-29643797","recycle_address":"同里辦及新北市板橋區廣德里5鄰重慶路353巷7號對面","open_time":"每週一至日9~12點+15~18點","state":"營運中","twd97X":"296817.42","twd97Y":"2765792.68","wgs84aX":"121.463808943393","wgs84aY":"24.9994134533018"},{"number":"3","district":"板橋區","village":"景星里","no":"01-003","name":"林志成","address":"板橋區景福路11號","tel":"02-29531072","recycle_address":"新北市板橋區景星里3鄰景福路11號","open_time":"每週四 09:00~16:00","state":"營運中","twd97X":"296532.5","twd97Y":"2766464.62","wgs84aX":"121.461009012507","wgs84aY":"25.0054885651095"},{"number":"4","district":"板橋區","village":"滿翠里","no":"01-004","name":"林重光","address":"板橋區四維路266巷5弄16號","tel