px = dp * (dpi / 160)
This file contains 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
Bitmap origBitmapOrig = BitmapFactory.decodeFile(imageFilePath); | |
//Resize the image | |
double width = origBitmapOrig.getWidth(); | |
double height = origBitmapOrig.getHeight(); | |
int newWidth = 1600 | |
int newHeight = (int)((newWidth/width)*height); | |
Bitmap newBitmap = Bitmap.createScaledBitmap(origBitmapOrig, newWidth, newHeight, true); | |
This file contains 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
git config --global credential.helper store |
This file contains 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
<?php | |
use Zend\Mail\Transport\Smtp as SmtpTransport; | |
use Zend\Mail\Transport\SmtpOptions; | |
use Zend\Mail\Message; | |
public function sendEmail($to, $subject, $body){ | |
$message = new Message(); | |
$message->addTo($to) | |
->addFrom('helpdesk@example.com') |
This file contains 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 |
This file contains 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 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 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 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 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` |
OlderNewer