Skip to content

Instantly share code, notes, and snippets.

@deskid
deskid / rc.lua
Last active December 17, 2015 07:39
awesome config for awesome 3.4
-- Standard awesome library
require("awful")
require("awful.autofocus")
require("awful.rules")
-- Theme handling library
require("beautiful")
-- Notification library
require("naughty")
vicious = require("vicious")
-- Load Debian menu entries
@deskid
deskid / jdk.sh
Created May 16, 2013 11:53
jdk download & install, modify needed if update
#!/usr/bin/env sh
JDK_URL="http://download.oracle.com/otn-pub/java/jdk/7u21-b11/jdk-7u21-linux-i586.tar.gz"
JDK_DOWNLOAD_PATH="~/Downloads"
JDK_NAME="jdk-7u21-linux-i586"
JDK_FILE=$JDK_NAME".tar.gz"
JDK_INSTALL_PATH="/usr/lib/jvm/jdk1.7.0/"
JDK_EXTRACTED_DIR="jdk1.7.0_21/*"
cd $JDK_DOWNLOAD_PATH && wget -c $JDK_URL
@deskid
deskid / bitmap circle .java
Last active August 29, 2015 14:21
come from http://square.github.io/picasso/ . Aiming to get a square thumbs, note about the way to get the central size for both width and height
Transformation transformation = new Transformation() {
@Override
public Bitmap transform(Bitmap source) {
if(null == source){
return null;
}
int size = Math.min(source.getWidth(), source.getHeight());
@deskid
deskid / uri parse.java
Created May 22, 2015 03:22
uri parma map
Uri.Builder builder = Uri.parse(baseUrl).buildUpon();
builder.appendQueryParameter(key, value);
return builder.build().toString();

--
-- 表的结构 `area`
--
DROP TABLE IF EXISTS `area`;
CREATE TABLE IF NOT EXISTS `area` (
`id` int(11) NOT NULL auto_increment,
`areaID` int(11) NOT NULL,
`area` varchar(20) character set gbk NOT NULL,
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
#parse("File Header.java")
public class ${NAME} extends Fragment {
private static final String FRAG_TAG = ${NAME}.class.getCanonicalName();
@deskid
deskid / WebView404.java
Last active August 29, 2015 14:24
WebView set default 404 page and some security setting
final String offlineMessageHtml = "DEFINE THIS";
final String timeoutMessageHtml = "DEFINE THIS";
WebView browser = (WebView) findViewById(R.id.webview);
browser.setNetworkAvailable(isConnected);
browser.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (isConnected) {
// return false to let the WebView handle the URL
public class ImageUtils {
public static final String TMP_CAPTURE_FILE_NAME = "tmp.jpg";
private static final String CACHE_FILE_DIR = "/app";
public static Bitmap getCircle(Bitmap bitmap, boolean recyle) {
if (null == bitmap)
return null;
int w = bitmap.getWidth();
int h = bitmap.getHeight();
@deskid
deskid / Singleton.java
Created August 31, 2015 01:29
what Singleton should be
abstract class Singleton<T> {
private T mInstance;
protected abstract T create();
public final T get() {
synchronized (this) {
if (mInstance == null) {
mInstance = create();
}
@deskid
deskid / Logger.java
Created September 18, 2015 09:38
hello world at MainActivity.java.onCreate (MainActivity.java:37) 在Android studio中这种格式的log可以类似超链接响应点击跳到对应文件行数
package com.example.zhou.helloword.log;
import android.util.Log;
import com.example.zhou.helloword.BuildConfig;
public class Logger {
private Logger() {
}