Android: Cloud Messaging Hello world using GCM, AWS SNS and Parse

Categories: AndroidDevelopment NotesJava; Tagged with: ; @ May 24th, 2015 23:12

Quick start using GCM

0. Create your project via “Google developers console”;

1. Prepare Client App:

  – Get device registration ID

– Receive message from GCM

Example: https://github.com/hmkcode/Android/tree/master/android-gcm-client

2. Send Message to GCM server

– Send(Post) message to GCM server
Example: https://github.com/hmkcode/Android/tree/master/java-post-gcm

3. Start your app(#1), then send message ( #2)

 

Push message via AWS SNS to Android devices

Login to AWS console

1. Create new application with your GCM API key

2. ‘Create platform endpoint’ using your device registration ID;

3. Select your device and ‘Publish to endpoint’ to publish a message

4. Check your device;

 

Push Message via Parse Push

Need to modify the client app and then push message from Parse console;

Jenkins: How to build bitbucket private project

Categories: Development Notes; Tagged with: ; @ May 16th, 2015 12:10

Update on Jan 8, 2017

You may enter your private key directly in Jenkins “Configure Credentials”.  so that you don’t need to config your server/box.

Config your build server

0. su – jenkins  (sudo su -s /bin/bash jenkins) // no need for Windows

1. Generate RSA key:  ssh-keygen

2. Add public key to your bitbucket profile

for 1 and 2, You may follow this instruction:https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git

3. [Optional] try to do a git clone, make sure you can clone your project

 

Config your jenkins:

1. Install git plugin for you jenkins

2. config your jenkins job to use git repo: e.g.   [email protected]:user/project.git

Issues:

Failed to connect to repository : Command “git -c core.askpass=true ls-remote -h [email protected]:user/project.git HEAD” returned status code 128:
stdout:
stderr: Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

You may add bitbucket.org to your know_host by executing:

git ls-remote [email protected]:accout/project.git
...
Are you sure you want to continue connecting (yes/no)? yes

PyQt ProgressBar: Update progress from other threads

Categories: Python; Tagged with: ; @ May 14th, 2015 23:40

Issue 1: UI is no responding when the progress is running


Create new thread to perform the progress:
http://stackoverflow.com/questions/6783194/background-thread-with-qthread-in-pyqt

Issue 2: QThread: Destroyed while thread is still running

Try to keep a reference:
http://stackoverflow.com/questions/8359469/python-threading-thread-scopes-and-garbage-collection

Issue 3: QWidget::repaint: Recursive repaint detected


Use single to update progress:
http://stackoverflow.com/questions/9682376/progress-bar-with-pyqt

 

Example: UploadThread:

class UploadTaskQtThread(QtCore.QThread):
    tick = QtCore.pyqtSignal(int, name="upload_changed")

    def __init__(self, client, local_path, remote_path):
        QtCore.QThread.__init__(self)
        self.client = client
        self.local_path = local_path
        self.remote_path = remote_path
        
    def on_progress(self, progress):
        self.tick.emit(progress * 100)
        
    def run(self):
        self.client.upload_file(self.local_path, self.remote_path, self.on_progress)

Client:

    def upload(self, local_file_path, remote_path):
        self.upload_thread = UploadTaskQtThread(client, local_file_path, remote_path)
        self.upload_thread.start()
        self.upload_thread.tick.connect(ui.progressBar.setValue)

MacBook: How to replace hard drive and restore OS X from internet 苹果笔记本电脑更换硬盘并从网络安装系统

Categories: 分享; Tagged with: ; @ March 21st, 2015 12:47

Requirement: The hard drive not working and you want to replace the hard drive and restore OS X from internet. 
需求: 替换硬盘并从网络安装系统

Replace Hard Drive 更换硬盘

What you need 需要工具:

Screwdriver #00 and T6   螺丝刀 #00  & T6

Details Steps 详细步骤:

 https://www.ifixit.com/Guide/MacBook+Unibody+Model+A1342+Hard+Drive+Replacement/1670

 

OS X Internet Recovery 网络恢复系统

To start your computer from Recovery, restart your Mac and hold down the Command and R keys at startup.

开机时按 Command + R 以开始系统恢复。

Reinstalling OS X using Recovery requires broadband access to the Internet using a Wi-Fi or Ethernet connection.

OS X is downloaded over the Internet from Apple when OS X Recovery is used for reinstallation. You must use DHCP on your Wi-Fi or Ethernet network to reinstall OS X using OS X Recovery.

If you bought OS X from the Mac App Store, you may be prompted to enter the Apple ID and password you used to purchase OS X.

After got internet access, set up the new system following the wizards, it may take hours  to download and restore the OS.
获得网络连接后, 根据提示配置系统,整个下载及恢复过程可能会持续几个小时。 

More details: https://support.apple.com/en-us/HT201314

常见鸡蛋英文名称/翻译: 水煮嫩蛋 各种煎蛋 水煮蛋 蒸水蛋

Categories: Uncategorized March 15th, 2015 16:45

Yolk – 蛋黄

Poached Egg 水煮嫩蛋

水煮蛋, 蛋黄被蛋清包在里面,剪开/咬开后会流动;

image

http://www.bbcgoodfood.com/technique/how-poach-egg

Fried Eggs 煎蛋

Sunny Side Up

fried on one side (unturned), with the yolks golden and runny; 单面煎,蛋黄是黄色液态。

image

http://www.wikihow.com/Make-Sunny-Side-up-Eggs

Over Easy 双面煎 – 蛋黄液体

An egg cooked “over easy” means that it gets fried on both sides, but the yolk stays runny  双面煎, 但是蛋黄还是液体。

image

类似的, 还有:

Over Medium / Well — Flipped, unbroken yolk, yolk cooked to have a firm but wet-appearing center.

Over Hard — Flipped, broken, fully-cooked yolk.

Over Well — Flipped, intact, fully-cooked yolk.

Scrambled egg 炒蛋

Generally the eggs are mixed in a bowl before being put into the pan, and often stirred while cooking. 蛋清蛋黄搅在一起后的炒蛋;

image

Omelette 蛋卷/蛋饼

a dish made from beaten eggs quickly cooked with butter or oil in a frying pan. It is quite common for the omelette to be folded around a filling such as cheese, chives, vegetables, meat (often ham), or some combination of the above.

Boiled 水煮蛋

Soft — Yolk runny, potentially with slight unset white around the yolk.

Medium — White completely set, yolk firm but with a dark, wet appearance.

Hard — Yolk completely set and pale yellow.

Steamed eggs 蒸水蛋

Chinese steamed eggs or water egg is a Chinese home-style dish found all over China. Eggs are beaten to a consistency similar to that used for an omelette and then steamed.

 

Different Eggs:

http://cooking.stackexchange.com/questions/16990/can-someone-please-give-an-explanation-of-different-egg-preparations

Fried Eggs:

Sunny Side Up — Not flipped, unbroken yolk. The top of the egg is just barely set.

Basted — Sunny Side Up, hot fat spooned over until the white surrounding the yolk is opaque.

Over Easy — Flipped, unbroken yolk, yolk runny.

Over Medium / Well — Flipped, unbroken yolk, yolk cooked to have a firm but wet-appearing center.

Over Hard — Flipped, broken, fully-cooked yolk.

Over Well — Flipped, intact, fully-cooked yolk.

Broken / Lightly Scrambled — Broken in pan and gently stirred while cooking – yolk and whites should not be mixed entirely.

Scrambled Eggs — Made in many different ways. Generally the eggs are mixed in a bowl before being put into the pan, and often stirred while cooking. Some recipes add fat to the eggs in the form of milk, cream, butter, or oil. A distinction can be made between Wet/Loose or Dry, which refers to the degree of doneness.

Omelettes:

Filled Omelette — Eggs mixed before cooking, possibly with added fat as in Scrambled Eggs. Cooked in fat in a saute pan; when set but the interior still wet, previously-cooked fillings (cheese, onions, mushrooms, peppers, tomatoes…) are added, and the eggs folded over into a half-moon shape.

Spanish Omelette / Western Omelette — Same as filled, but the egg mixture is poured over the fillings in a hot pan and cooked, thus incorporating the fillings into the egg.

Fluffy Omelette — Whites and yolks beaten separately. Yolks are gently folded into the whites without breaking the structure of the whites. Optional toppings are added. Cooked slowly in a pan, or baked (an electric frying pan with a lid works well for this preparation).

Boiled:

Cooked in shell in water for a timed period. Some people will refer to degree of doneness by cooking time, i.e., a “3-minute egg” is soft-boiled with some runny white around the yolk. Some recipes call for eggs to be added to boiling water, others to be started in cold water. In the cold-water start, the pot may be left on the heat or removed when the water reaches a boil. The eggs may be shocked in ice water when removed.

Soft — Yolk runny, potentially with slight unset white around the yolk.

Medium — White completely set, yolk firm but with a dark, wet appearance.

Hard — Yolk completely set and pale yellow.

Poached:

Egg cooked, out of shell, in water, stock, or other liquid — excluding fats or oils — at a temperature in the range of 160-180˚F (70-82˚C). There are possible degrees of doneness, however the typical poached egg has a runny but warm and thickened yolk and fully-set white.

Coddled:

An egg that has been very lightly cooked (poached eggs are sometimes considered coddled). This can either be accomplished with an egg coddler or cooking an egg in its shell with water that is slightly below boiling point.

Shirred:

An egg cooked in an oven at the low-mid 300’s˚F (~160˚C), contained in a ramekin, until the whites are just set and the yolk is runny but thickened. Often butter or another fat is placed on top before cooking.

Steamed:

Very similar to shirred eggs, but the ramekin is covered with some aluminum foil and put in a steamer for 7-15 minutes.

In a basket: Eggs fried in a hole made in a slice of bread

Newer Posts <-> Older Posts



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.