px = dp * (dpi / 160)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.eclipse.jetty.util.ConcurrentHashSet; | |
import java.util.*; | |
import java.util.function.Function; | |
import java.util.stream.Collectors; | |
import io.reactivex.Observable; | |
import static java.util.Comparator.comparing; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void logBatteryInfoByApi() { | |
IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); | |
Intent batteryStatus = MainActivity.this.registerReceiver(null, ifilter); | |
assert batteryStatus != null; | |
Log.e(LOG_TAG, "STATUS: " + String.valueOf(batteryStatus.getIntExtra(BatteryManager | |
.EXTRA_STATUS, -1))); | |
Log.e(LOG_TAG, "PLUG: " + String.valueOf(batteryStatus.getIntExtra(BatteryManager.EXTRA_PLUGGED, | |
-1))); | |
Log.e(LOG_TAG, "LEVEL: " + String.valueOf(batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
kill -sighup `ps -e | grep Finder.app | grep -v grep | cut -c1-6` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
date.today().strftime(u'%Y年%m月%d日'.encode('utf-8')).decode('utf-8') | |
#输出:2012年11月27日 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static $periods = array( | |
'天' => 86400, | |
'小时' => 3600, | |
'分钟' => 60, | |
'秒' => 1 | |
); | |
public function friendlyTime($timestamp) | |
{ | |
$timeStr = ''; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DATE_FORMATTER = '%Y-%m-%d %H:%M:%S' | |
def unix_time(dt): | |
epoch = datetime.utcfromtimestamp(0) | |
delta = dt - epoch | |
return delta.total_seconds() | |
def unix_time_millis(dt): | |
return unix_time(dt) * 1000.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ComplexEncoder(json.JSONEncoder): | |
def __init__(self, skipkeys=False, ensure_ascii=True, | |
check_circular=True, allow_nan=True, sort_keys=False, | |
indent=None, separators=None, encoding='utf-8', default=None, excluded=None): | |
super(ComplexEncoder, self).__init__(skipkeys, ensure_ascii, check_circular, allow_nan, sort_keys, indent, | |
separators, encoding, default) | |
self.excluded = excluded | |
def default(self, obj): | |
if hasattr(obj, "__dict__"): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def todict(obj, classkey=None): | |
if isinstance(obj, dict): | |
data = {} | |
for (k, v) in obj.items(): | |
data[k] = todict(v, classkey) | |
return data | |
elif hasattr(obj, "_ast"): | |
return todict(obj._ast()) | |
elif hasattr(obj, "__iter__"): | |
return [todict(v, classkey) for v in obj] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generate a private key | |
keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000 | |
// View generated key store | |
keytool -list -v -keystore release.keystore | |
// Sign the application | |
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore my_application.apk alias_name |
NewerOlder