Skip to content

Instantly share code, notes, and snippets.

View up1's full-sized avatar

Somkiat Puisungnoen up1

View GitHub Profile
function responseXML($url ='',$post_data ='', $parse=false){
$ch = curl_init(); //initiate the curl session
curl_setopt($ch, CURLOPT_URL, $url); //set to url to post to
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // tell curl to return data ina variable
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); // post the xml
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // set timeout in seconds
$xmlResponse = curl_exec ($ch);
if (curl_errno($ch)) {
<head>
<title>menu mockup</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<style type="text/css">
.show {display: none; }
.hide:focus + .show {display: inline; }
.hide:focus { display: none; }
.hide:focus ~ #list { display:none; }
@media print { .hide, .show { display: none; } }
</style>
BaseFont bf = BaseFont.createFont(
"c:\\windows\\fonts\\ANGSA.ttf",
BaseFont.IDENTITY_H,
BaseFont.EMBEDDED
);
Font f = new Font(bf, 12);
BaseFont bf = BaseFont.createFont(
"c:\\windows\\fonts\\ANGSA.ttf",
BaseFont.IDENTITY_H,
BaseFont.EMBEDDED
);
Font f = new Font(bf, 12);
@up1
up1 / flatten.py
Created July 8, 2012 06:58
flatten
def flatten(t):
result=[]
def remove(t):
for x in t:
if isinstance(x, list):
remove(x)
else:
result.append(x)
@up1
up1 / gist:3650931
Created September 6, 2012 03:43
Get fingerprint
keytool -list -alias androiddebugkey -keystore "C:\Documents and Settings\User\.android\debug.keystore" -storepass android -keypass android
public static String renderPageWithSetupsAndTeardowns(
PageData pageData, boolean isSuite
) throws Exception {
boolean isTestPage = pageData.hasAttribute(“Test”);
if (isTestPage) {
WikiPage testPage = pageData.getWikiPage();
StringBuffer newPageContent = new StringBuffer();
includeSetupPages(testPage, newPageContent, isSuite);
newPageContent.append(pageData.getContent());
includeTeardownPages(testPage, newPageContent, isSuite);
int x() {
int q = 0;
int z = 0;
for (int kk = 0; kk < 10; kk++) {
if (l[z] == 10) {
q += 10 + (l[z + 1] + l[z + 2]);
z += 1;
} else if (l[z] + l[z + 1] == 10) {
q += 10 + l[z + 2];
z += 2;
int score() {
int score = 0;
int frame = 0;
for (int frameNumber = 0; frameNumber < 10; frameNumber++) {
if (isStrike(frame)) {
score += 10 + nextTwoBallsForStrike(frame);
frame += 1;
} else if (isSpare(frame)) {
score += 10 + nextBallForSpare(frame);
frame += 2;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.*;
import static org.springframework.test.web.client.response.MockRestResponseCreators.*;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;