Skip to content

Instantly share code, notes, and snippets.

Leo Zhu leoleozhu

  • Shanghai
Block or report user

Report or block leoleozhu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@leoleozhu
leoleozhu / GuessContentTypeTest.java
Created Oct 30, 2019
guess image content type from URL
View GuessContentTypeTest.java
public class GuessContentTypeTest extends TestCase {
@Test
public void testGuessFileTypeFromUrl() throws Exception {
String[] urls = {
// your image urls here
};
for(String s : urls) {
int pushbackLimit = 100;
@leoleozhu
leoleozhu / taopix-payment-icon.css
Created Sep 6, 2019
add payment icons for taopix checkout
View taopix-payment-icon.css
div.paymentmethodlist>input[value="PAYPAL"] ~ label:after {
background-repeat: no-repeat;
background-image: url(/images/payments/paypal-640x188.png);
background-size: 48px 14px;
display: inline-block;
width: 48px;
height: 14px;
content: "";
margin-left: 20px;
@leoleozhu
leoleozhu / PdfGenerator.java
Created Aug 19, 2019
Draw transparent text with iText 7
View PdfGenerator.java
class TextBox {
private UUID uuid;
private float x;
private float y;
private float width;
private float height;
@leoleozhu
leoleozhu / fonttools_fontinfo.py
Created Aug 16, 2019
Get FontFamily, Styles from a TTFont object (python fonttools lib)
View fonttools_fontinfo.py
class TTFontInfo(object):
bold_names = ("bold", "demibold", "demi-bold", "demi bold", "negreta", "demi",)
italic_names = ("italic", "cursiva", "oblique", "inclined",)
bold_italic_names = ("bolditalic", "bold-italic", "bold italic", "boldoblique", "bold-oblique",
"bold oblique", "demibold italic", "negreta cursiva", "demi oblique",)
@leoleozhu
leoleozhu / AffineTransformTests.java
Last active Aug 17, 2019
Affine Transform Example
View AffineTransformTests.java
package document.transform;
import com.itextpdf.kernel.geom.AffineTransform;
import com.itextpdf.kernel.geom.Point;
import junit.framework.TestCase;
import org.junit.Test;
public class AffineTransformTests extends TestCase {
View find-first-docker-machine.sh
VM=`docker-machine ls 2>/dev/null | sed -n 2p | awk '{print $1}'`
[ -z "$VM" ] && VM=default
@leoleozhu
leoleozhu / python-server.py
Created Mar 5, 2014
Python Simple HTTP Server
View python-server.py
import os
import posixpath
import urllib
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
# modify this to add additional routes
ROUTES = (
# [url_prefix , directory_path],
['', 'E:\Dropbox\Other\python-server'], # empty string for the 'default' match
@leoleozhu
leoleozhu / http-server.py
Created Jan 26, 2014
SimpleHTTPServer different port
View http-server.py
#!/usr/bin/env python
import SimpleHTTPServer
import SocketServer
# minimal web server. serves files relative to the
# current directory.
PORT = 8080
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
View change-iptables.sh
#! /bin/bash
# Set the default policies to allow everything while we set up new rules.
# Prevents cutting yourself off when running from remote SSH.
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
# Flush any existing rules, leaving just the defaults
iptables -F
@leoleozhu
leoleozhu / random-str.py
Last active Dec 23, 2015
Generate random string with python. Charset used can be specified via parameters.
View random-str.py
#!/usr/bin/env python
import getopt
import sys
import random
import string
DEFAULT_LENGTH = 16
def main():
You can’t perform that action at this time.