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 HttpPost buildPostRequest(String _method, String _path, Map _params) | |
| throws ServerConnectionException { | |
| HttpPost request = new HttpPost(); | |
| try { | |
| request.setURI(URIUtils.createURI(scheme, host, port, _path, null, | |
| null)); | |
| MultipartEntity entity = new MultipartEntity( | |
| HttpMultipartMode.BROWSER_COMPATIBLE); |
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 byte[] requestImage(String path) throws ServerConnectionException { | |
| BufferedInputStream inStream = null; | |
| try { | |
| HttpResponse response = client.execute(buildGetRequest( | |
| HttpGet.METHOD_NAME, path, new HashMap())); | |
| HttpEntity entity = response.getEntity(); | |
| ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); | |
| if (entity == null) { | |
| return new byte[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
| private HttpGet buildGetRequest(String _method, String _path, Map _params) | |
| throws ServerConnectionException { | |
| List params = new ArrayList(); | |
| for (Iterator it = _params.keySet().iterator(); it.hasNext();) { | |
| String k = (String) it.next(); | |
| params.add(new BasicNameValuePair(k, (String) _params.get(k))); | |
| } | |
| HttpGet request = new HttpGet(); |
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
| /** | |
| * This code uses Apache Chemistry (http://chemistry.apache.org/). | |
| * License accords to Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | |
| */ | |
| import java.io.ByteArrayInputStream; | |
| import java.io.UnsupportedEncodingException; | |
| import java.util.HashMap; | |
| import java.util.Iterator; | |
| import java.util.Map; |
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
| /** | |
| * This program is under LGPL v2.1 as Liferay. | |
| */ | |
| package jp.hoge.liferay.experiment.ldap; | |
| import java.io.File; | |
| import java.io.FileInputStream; | |
| import java.io.FileNotFoundException; | |
| import java.io.IOException; | |
| import java.util.ArrayList; |
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 main(): | |
| """ | |
| Execute three actions. | |
| 1. get id, new title from a file. e.g. [(title, id),(title, id)] | |
| 2. update DB | |
| """ | |
| id_titles = get_id_titles(EXPECTED_LIST) | |
| conn = pymysql.Connect(host=DB_HOST, db=DB, user=DB_USER, passwd=DB_PSWD, charset=CHARSET) | |
| cursor = conn.cursor() |
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
| STACK_SIZE = 10 | |
| class ArrayStack: | |
| """ | |
| This class realize 3 stacks in 1 array. | |
| """ | |
| def __init__(self): | |
| self.buffer = [0] * STACK_SIZE * 3 | |
| self.stack_pointer = [-1, -1, -1] |
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 unittest | |
| from google.appengine.api import users | |
| from google.appengine.ext import db | |
| from google.appengine.ext import testbed | |
| from model import Group | |
| class GroupTestCase(unittest.TestCase): |
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
| language: python | |
| python: | |
| - '2.7' | |
| install: | |
| - 'pip install -r requirements.txt --use-mirrors' | |
| before_script: | |
| - wget http://googleappengine.googlecode.com/files/google_appengine_1.8.0.zip -nv |
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
| # dynamic dispatch | |
| puts '##### dynamic dispatch' | |
| class Student | |
| def initialize | |
| @name = 'Joe' | |
| end | |
| def original | |
| "#{@name}'s original score: { math: 60, eng: 56 }" |
OlderNewer