Curl – HttpPost Example

Categories: Development Notes June 13th, 2015 0:34

Http Post without Parameter

$ curl -X POST -H ‘Content-Length: 0′ http://127.0.0.1:8080/_qs/listAllInstitutions

Set content-Lenght=0 to avoid HTTP ERROR 411 – ‘Length required’

 

Http Post with Parameters

curl  –data “userId=user-id”  http://127.0.0.1:8080/_qs/getUserInfo

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

Categories: AndroidDevelopment NotesJava 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 May 16th, 2015 12:10

Config your build server

0. su – 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.   git@bitbucket.org:user/project.git

 

Issues:

Failed to connect to repository : Command “git -c core.askpass=true ls-remote -h git@bitbucket.org: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 git@bitbucket.org:accout/project.git
...
Are you sure you want to continue connecting (yes/no)? yes
 

PyQt ProgressBar: Update progress from other threads

Categories: Python 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: 分享 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

Older Posts


Popular Tags

Archives


AD


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