Skip to content

Instantly share code, notes, and snippets.

View ccjeng's full-sized avatar

Andy Cheng ccjeng

  • Taiwan
View GitHub Profile
@ccjeng
ccjeng / gist:11284024
Last active August 29, 2015 14:00
heroku nodejs deployment
git init
## git link to github repo
## git remote add origin git@github.com:ccjeng/tptrash-api.git
git add .
# commit program to local git repo
git commit –m "First commit"
@ccjeng
ccjeng / gist:9378b607d55c45f21627
Last active August 29, 2015 14:02
sshfs mount
#mount
sshfs root@nexus5:/sdcard/ sdcard -p2222
#unmount
fusermount -u sdcard
# adb port forwarding
# This will redirect the local tcp port 22 to the port 2222 on the phone, on which the SSH server will be running now, served by QuickSSHd.
adb forward tcp:2222 tcp:22
@ccjeng
ccjeng / gist:5175351
Created March 16, 2013 07:11
SQL Server: get top 50 slow sql statement
--get top 50 slow sql statement
select top 50 * from
(
SELECT SUBSTRING(st.text, (qs.statement_start_offset/2)+1,
((CASE qs.statement_end_offset
WHEN -1 THEN DATALENGTH(st.text)
ELSE qs.statement_end_offset
END - qs.statement_start_offset)/2) + 1) AS StatementText,
last_execution_time as LastExecuted,
last_elapsed_time/1000000.0 as ElapsedTimeInSeconds,
@ccjeng
ccjeng / gist:5308533
Last active December 15, 2015 19:08
PeopleSoft - Query to determine which records user can see
SELECT DISTINCT B.TREE_NODE, Z.RECDESCR
FROM PSTREEDEFN A,
PSTREENODE B,
PS_SCRTY_ACC_GRP C,
PSTREENODE E,
PSROLECLASS X,
PSROLEUSER Y,
PSRECDEFN Z
WHERE A.SETID = ' '
AND A.TREE_STRCT_ID = 'ACCESS_GROUP'
@ccjeng
ccjeng / gist:5394020
Created April 16, 2013 07:19
To resolve "An error occurred during decryption" issue, when migrating SQL server.
alter service master key force regenerate
@ccjeng
ccjeng / gist:5417820
Created April 19, 2013 03:02
SQL server - Purge transaction log
USE DatabaseName
GO
DBCC SHRINKFILE(<TransactionLogName>, 1)
BACKUP LOG <DatabaseName> WITH TRUNCATE_ONLY
DBCC SHRINKFILE(<TransactionLogName>, 1)
GO
@ccjeng
ccjeng / json.py
Created December 25, 2015 14:02
export data to Parse.com json format
#!/usr/bin/python
# -*- coding: utf-8 -*-
import codecs, json,httplib
import urllib2
import ast
root = 'http://data.taipei/opendata/datalist/apiAccess?scope=resourceAquire&rid='
dict = {u'士林區':'97cc923a-e9ee-4adc-8c3d-335567dc15d3'
@ccjeng
ccjeng / SwipeRefreshLayout.xml
Last active December 26, 2015 09:44
Android SwipeRefreshLayout's Layout
<framelayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="MergeRootFrame" >
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="match_parent"
@ccjeng
ccjeng / SwipeRefreshLayout.java
Last active December 26, 2015 10:00
Android SwipeRefreshLayout Java
private SwipeRefreshLayout mSwipeLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......
mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
mSwipeLayout.setOnRefreshListener(this);
mSwipeLayout.setColorSchemeResources(android.R.color.holo_red_light,
@ccjeng
ccjeng / SwipeBack.java
Last active December 28, 2015 02:08
Android SwipeBack Sample : com.hannesdorfmann:swipeback
@Override
public void onCreate(Bundle saved){
super.onCreate(saved);
// Init the swipe back
SwipeBack.attach(this, Position.LEFT)
.setContentView(R.layout.activity_simple)
.setSwipeBackView(R.layout.swipeback_default);
}