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
from pyPdf import PdfFileWriter, PdfFileReader | |
import StringIO | |
from reportlab.pdfgen import canvas | |
from reportlab.lib.pagesizes import letter | |
packet = StringIO.StringIO() | |
# create a new PDF with Reportlab | |
can = canvas.Canvas(packet, pagesize=letter) | |
can.drawString(100,100, "Hello world") | |
can.save() |
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
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) { | |
// Load resources for iOS 6.1 or earlier | |
} else { | |
// Load resources for iOS 7 or later | |
} |
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
import urllib2, os | |
image_path = "png\\01.png" | |
url = 'http://xx.oo.com/webserviceapi/postfile/' | |
length = os.path.getsize(image_path) | |
png_data = open(image_path, "rb") | |
request = urllib2.Request(url, data=png_data) | |
request.add_header('Cache-Control', 'no-cache') | |
request.add_header('Content-Length', '%d' % length) | |
request.add_header('Content-Type', 'image/png') | |
res = urllib2.urlopen(request).read().strip() |
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
// Simulate abstract method | |
-(CGFloat)abstractFoo { | |
[self doesNotRecognizeSelector:_cmd]; | |
return 0.0f; | |
} |
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 diff --name-only --diff-filter=U |
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
//Remove if exists, the file MUST be created using the lines below | |
File f = new File(getFilesDir(), "Captured.jpg"); | |
f.delete(); | |
//Create new file | |
FileOutputStream fos = openFileOutput("Captured.jpg", Context.MODE_WORLD_WRITEABLE); | |
fos.close(); | |
//Get reference to the file | |
File f = new File(getFilesDir(), "Captured.jpg"); |
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
/** | |
* Helper class for handling ISO 8601 strings of the following format: | |
* "2008-03-01T13:00:00+01:00". It also supports parsing the "Z" timezone. | |
*/ | |
public final class Iso8601 { | |
/** Transform Calendar to ISO 8601 string. */ | |
public static String fromCalendar(final Calendar calendar) { | |
Date date = calendar.getTime(); | |
String formatted = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ") | |
.format(date); |
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
import android.content.Context; | |
import android.database.Cursor; | |
import android.support.v4.content.AsyncTaskLoader; | |
/** | |
* Used to write apps that run on platforms prior to Android 3.0. When running | |
* on Android 3.0 or above, this implementation is still used; it does not try | |
* to switch to the framework's implementation. See the framework SDK | |
* documentation for a class overview. | |
* |
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
package my.app; | |
import android.graphics.Paint; | |
import android.graphics.Typeface; | |
import android.text.TextPaint; | |
import android.text.style.TypefaceSpan; | |
public class CustomTypefaceSpan extends TypefaceSpan { | |
private final Typeface newType; |
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
# Mac OS X clutter | |
*.DS_Store | |
# Windows clutter | |
Thumbs.db | |
# built application files | |
*.apk | |
*.ap_ |
OlderNewer