Skip to content

Instantly share code, notes, and snippets.

View yamanyar's full-sized avatar

Kaan Yamanyar yamanyar

View GitHub Profile
@yamanyar
yamanyar / sample.xml
Created April 7, 2012 05:25
beginning of the xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://com.yamanyar.ish"
xmlns="http://com.yamanyar.ish">
<xs:element name="TransactionalInfo">
<xs:complexType>
...
@yamanyar
yamanyar / optionspart.java
Created April 7, 2012 05:24
Options part
static XmlOptions opts;
static {
opts = new XmlOptions();
opts.setUseDefaultNamespace();
}
@yamanyar
yamanyar / DocumentCreateExample.java
Created April 7, 2012 05:24
Crete document example
//...
TransactionalInformationsDocument transactionalInformationsDocument = TransactionalInformationsDocument.Factory.newInstance();
final TransactionalInformationsDocument.TransactionalInformations transactionalInformations = transactionalInformationsDocument.addNewTransactionalInformations();
//use requierd locale and shop id
transactionalInformations.setLocale(requiredLocale.getName());
transactionalInformations.setShopId(requiredShopId);
final TypeDocument.Type type = transactionalInformations.addNewType();
type.setType(sourceType.toString());
@yamanyar
yamanyar / test.java
Created April 7, 2012 05:23
Parse example
import org.apache.xmlbeans.XmlException;
import org.junit.Ignore;
import com.yamanyar.ish.TransactionalInfoDocument;
import java.io.File;
import java.io.IOException;
import static junit.framework.Assert.assertEquals;
/**
@yamanyar
yamanyar / buildpart.xml
Created April 7, 2012 05:21
auto compile at building
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<version>2.2.0</version>
<executions>
<execution>
<goals>
<goal>xmlbeans</goal>
@yamanyar
yamanyar / part.xml
Created April 7, 2012 05:20
maven dependicies for xml beans
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
@yamanyar
yamanyar / sample.java
Created April 7, 2012 05:15
capture parameters example
//... lines of codes... templateService is mocked...
//here is regular expectation; we know the parameter that will be passed and we are verifying it
expect(nodeService.getProperties(fakeChildNodeRef2)).andReturn(new HashMap());
//create a capturer; which will capture a map item
Capture<Map> capturer = new Capture<Map>();
//write your expectaion again; this time we want to have a reference to whatever passed to
//our method processTemplate in mocked item templateService
expect(templateService.processTemplate(isA(String.class), and(isA(Map.class), capture(capturer)))).andReturn("fake");
//replay; let the action begin
replay(nodeService, templateService);
@yamanyar
yamanyar / logback.xml
Created April 7, 2012 05:10
environment specific log back config
<configuration>
<if condition='"prd".equals(property("environment"))
|| "stg".equals(property("environment"))'>
<then>
<property name="APPLINK_LOG_LEVEL" value="warn"/>
</then>
<else>
<property name="APPLINK_LOG_LEVEL" value="debug"/>
</else>
@yamanyar
yamanyar / encrypt.java
Created April 7, 2012 05:08
encrypt in java
protected String encrypt(String token) throws Exception {
// Instantiate the cipher
final SecretKeySpec key = new SecretKeySpec("oldhouse".getBytes("ISO-8859-1"), "DES");
AlgorithmParameterSpec paramSpec = new IvParameterSpec("houseold".getBytes());
Cipher cipher = Cipher.getInstance("DES/CFB8/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
byte[] binaryData = cipher.doFinal(token.getBytes("ISO-8859-1"));
return new String(org.apache.commons.codec.binary.Base64.encodeBase64(binaryData), "ISO-8859-1");
@yamanyar
yamanyar / sample.py
Created April 7, 2012 05:07
resolving in python
#!/usr/bin/python
# Rewrite URL Script for Secure Web Issue
# author: Kaan Yamanyar
from Crypto.Cipher import DES
from datetime import datetime, timedelta
import sys
import re
import base64
def parseToken(str):