Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View iamcxa's full-sized avatar
🎯
Focusing

Kent Chen iamcxa

🎯
Focusing
View GitHub Profile
@iamcxa
iamcxa / react-native-android-release-gradle-fix.js
Created September 16, 2019 15:34
react-native-android-release-gradle-fix.js
const fs = require('fs')
try {
var curDir = __dirname
var rootDir = process.cwd()
var file = `${rootDir}/node_modules/react-native/react.gradle`
var dataFix = fs.readFileSync(`${curDir}/android-react-gradle-fix`, 'utf8')
var data = fs.readFileSync(file, 'utf8')
@iamcxa
iamcxa / pr.md
Created May 26, 2018 19:38 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@iamcxa
iamcxa / SoftKeyboard.java
Created December 21, 2017 05:04 — forked from felHR85/SoftKeyboard.java
A solution to catch show/hide soft keyboard events in Android http://felhr85.net/2014/05/04/catch-soft-keyboard-showhidden-events-in-android/
/*
* Author: Felipe Herranz (felhr85@gmail.com)
* Contributors:Francesco Verheye (verheye.francesco@gmail.com)
* Israel Dominguez (dominguez.israel@gmail.com)
*/
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import android.os.Handler;
@iamcxa
iamcxa / capture.js
Created November 9, 2016 18:50
Capture video streaming using Javascript
var SCREENSHOTS = (function () {
console.log("SCREENSHOTS START");
var css = '#screenshot-container{background:#eee;width:480px;height:360px;overflow:hidden;position:relative;}';
var head = document.head || document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
style.appendChild(document.createTextNode(css));
head.appendChild(style);
// find controlbar
var controls = document.getElementById('video-controls');
@iamcxa
iamcxa / control.js
Created November 9, 2016 18:48
Let stream video rotation and zoom in/out
/* predefine zoom and rotate */
var zoomScale = 1;
var rotate = 0;
var videocontrols = (function () {
console.log("VIDCONTROL START");
var css =
'#video-container{background:#eee;width:480px;height:360px;overflow:hidden;position:relative;}' +
'#ideo-container span{font-size:20px;color:#666;display:block;padding:2em;}' +
'video{width:480px;height:360px;position:absolute;top:0;left:0;}' +
'change button{width:50px;border:none;background:#333;color:wheat;}';
//rootProject.file(): 取得根目錄中的檔案
def ksFile = rootProject.file('keystore.properties')
def props = new Properties();
if (ksFile.canRead()) {
props.load(new FileInputStream(ksFile))
if (props != null) {
android.signingConfigs.sign.storeFile file(props['KEYSTORE_FILE'])
android.signingConfigs.sign.storePassword props['KEYSTORE_PASSWORD']
android.signingConfigs.sign.keyAlias props['KEYSTORE_ALIAS']
android.signingConfigs.sign.keyPassword props['KEYSTORE_ALIAS_PASSWORD']
/** Create a File for saving an image or video */
private File getOutputMediaFile(){
// To be safe, you should check that the SDCard is mounted
// using Environment.getExternalStorageState() before doing this.
// p.s: MODIFY THE PATH YOU WANT YOUR IMAGE TO STORE HERE
// 嗨嗨如果你想改儲存路徑記得改這邊
// for example, you can just using this way to save image into the root of sdcard
// File mediaStorageDir = new File(Environment.getExternalStorageDirectory().toString());
File mediaStorageDir = new File(Environment.getExternalStorageDirectory()
+ "/Android/data/"
@iamcxa
iamcxa / getExternalStorageDirectory.java
Created November 9, 2016 17:50
How to get your SDcard path by using Environment
Environment.getExternalStorageDirectory()
+ "/Android/data/"
+ getApplicationContext().getPackageName()
+ "/Files"
@iamcxa
iamcxa / storeImage.java
Created November 9, 2016 17:49
How to store a bitmap into file
private void storeImage(Bitmap image) {
File pictureFile = getOutputMediaFile();
if (pictureFile == null) {
Log.d(TAG,
"Error creating media file, check storage permissions: ");// e.getMessage());
return;
}
try {
FileOutputStream fos = new FileOutputStream(pictureFile);
image.compress(Bitmap.CompressFormat.PNG, 90, fos);
@iamcxa
iamcxa / activity_main.xml
Created November 9, 2016 17:46
RTSP Player using VideoView
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"