Skip to content

Instantly share code, notes, and snippets.

View songzhiyong's full-sized avatar
🌍

Jerome Song songzhiyong

🌍
View GitHub Profile
^ #start of the line
[_A-Za-z0-9-\\+]+ # must start with string in the bracket [ ], must contains one or more (+)
( # start of group #1
\\.[_A-Za-z0-9-]+ # follow by a dot "." and string in the bracket [ ], must contains one or more (+)
)* # end of group #1, this group is optional (*)
@ # must contains a "@" symbol
[A-Za-z0-9-]+ # follow by string in the bracket [ ], must contains one or more (+)
( # start of group #2 - first level TLD checking
\\.[A-Za-z0-9]+ # follow by a dot "." and string in the bracket [ ], must contains one or more (+)
)* # end of group #2, this group is optional (*)
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSLUCENT);
params.gravity = Gravity.CENTER;
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
wm.addView(view, params);
@songzhiyong
songzhiyong / Android-App details
Created December 22, 2013 13:58
How to show details for installed application on Android?
Intent intent;
if (android.os.Build.VERSION.SDK_INT >= 9) {
/* on 2.3 and newer, use APPLICATION_DETAILS_SETTINGS with proper URI */
Uri packageURI = Uri.parse("package:" + pkgName);
intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS", packageURI);
ctx.startActivity(intent);
} else {
/* on older Androids, use trick to show app details */
intent = new Intent(Intent.ACTION_VIEW);
@songzhiyong
songzhiyong / Android-ShareCompat
Created December 9, 2013 06:32
Android 利用ShareCompat Build模式分享内容
//分享文本
ShareCompat.IntentBuilder.from(this)
.setType("text/plain")
.setText("I'm sharing!")
.startChooser();
//分享单个文件
ShareCompat.IntentBuilder.from(this)
.setType("text/plain")
.setStream(Uri.parse(SharingSupportProvider.CONTENT_URI + "/foo.txt"))
.startChooser();
<style name="MyTheme" parent="@android:style/Theme.Light">
<item name="android:windowNoTitle">true</item>
<item name="android:windowAnimationStyle">@style/MyAnimation.Window</item>
</style>
<!-- Animations -->
<style name="MyAnimation" />
<!-- Animations for a non-full-screen window or activity. -->
<style name="MyAnimation.Window" parent="@android:style/Animation">
package net.jthoenes.blog.spike.lambda;
import java.util.Arrays;
import java.util.List;
public class LambdaIntro {
public static interface ItemWithIndexVisitor<E> {
public void visit(E item, int index);
@songzhiyong
songzhiyong / JS-reg
Created November 28, 2013 09:23
6-20字符 javascript
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type='text/javascript'>
var reg=/^[\w\_\-]{6,20}$/;
alert(reg.test("12345"));
alert(reg.test("12345+"));
alert(reg.test("12345a-_"));
</script>
@songzhiyong
songzhiyong / Rabbit-by-Beard-Chicken.markdown
Created November 21, 2013 05:40
A Pen by Katy DeCorah.
body {
background:#e2b29f;
font-size:120%;
}
.rabbit {
width:5em;
height:3em;
background:#ffffff;
border-radius:70% 90% 60% 50%;