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
| resolvers += "Web plugin repo" at "http://siasia.github.com/maven2" | |
| //Following means libraryDependencies += "com.github.siasia" %% "xsbt-web-plugin" % <sbt version> | |
| libraryDependencies <+= sbtVersion("com.github.siasia" %% "xsbt-web-plugin" % _) |
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
| name := "myproject" | |
| organization := "com.booo" | |
| version := "1.0" | |
| scalaVersion := "2.8.1" | |
| scalacOptions += "-deprecation" |
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
| java -Dfile.encoding=UTF8 -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -jar /opt/local/lib/sbt/sbt-launch10.jar "$@" |
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 static com.my.utils.FileUtilities.*; | |
| /** | |
| * Demonstrating how to use FileUtilities http://gist.github.com/405510 | |
| * and IOUtilities http://bit.ly/dc9vn4 | |
| **/ | |
| public void fileUtilDemo() throws java.io.IOException { | |
| String content = readFileAsString("myfile.txt"); | |
| deleteDirectory("images"); //deletes directory recursively |
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
| //normal java | |
| public List<Item> getTitles(Collection<Item> items,String title) { | |
| List<Item> matching = new ArrayList<Item>(); | |
| Iterator<Item> iter = items.iterator(); | |
| while (iter.hasNext()) { | |
| Item item = iter.next(); | |
| if (item.getTitle().equals(title)) { | |
| matching.add(title); | |
| } | |
| } |
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 static com.my.utils.HttpHelper.*; | |
| //Perform a GET | |
| String response = performGet("http://mysite.com"); | |
| //do something with response | |
| //Perform a more complex GET | |
| Map<String,String> headers = new HashMap<String,String>(); | |
| headers.put("special","header"); | |
| String response = performGet("http://mysite.com","john","password",headers); |
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 static final String TAG = "MyActivity"; | |
| @As(Runnable.class) | |
| void foo(){Log.v(TAG,announcement);} | |
| //another example | |
| @As(OnTabChangeListener.class) | |
| void call(@As.Additional String param, String s) { | |
| //do something at tab change |
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 org.junit.Test; | |
| import org.junit.runner.RunWith; | |
| import org.powermock.core.classloader.annotations.PrepareForTest; | |
| import org.powermock.modules.junit4.PowerMockRunner; | |
| import com.my.mobile.provider.HtmlContentProvider; | |
| import android.content.ContentProvider; | |
| import static org.powermock.api.mockito.PowerMockito.*; |
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
| @As(Runnable.class) | |
| void feedReader() { | |
| try { | |
| List<String> titles = new ArrayList<String>(); | |
| //for this example, let's use a file | |
| VTDGen vg = new VTDGen(); | |
| File f = new File("./myfeed.xml"); | |
| FileInputStream fis = new FileInputStream(f); | |
| byte[] b = new byte[(int) f.length()]; | |
| fis.read(b); |
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 java.io.File; | |
| import java.io.IOException; | |
| /** | |
| * simply utility to deal with files, it's depending on IOUtilities | |
| * | |
| */ | |
| public class FileUtilities { | |
| // charsetName can be null to use the default charset. |