Stack Overflow question : Is there any eclipse refactoring API that I can call programmatically?
How to execute inline refactoring programmatically using JDT/LTK?
From MacJournal
Stack Overflow question : Is there any eclipse refactoring API that I can call programmatically?
How to execute inline refactoring programmatically using JDT/LTK?
From MacJournal
e = {"one": 1, "two": 2}The two items are mapped with ":" charactore, and each mapping is separated by a comman. Python builds dict object with '{' and '}' character.
dict()
method to build one.
class dict(**kwarg)You may not familiar with
**
notation. This is a simple example used in python method.
def hello(**x): print x hello(x=1,y=2)When you execute this code, you will get a dictionary object.
{'y': 2, 'x': 1}When python method sees
**something
, all the assignments (x = 1, y = 2 in this example) given as a parameter is wrapped inside an automatically generated dictionary, and parameter variable x
is pointing to the dictionary.
In short, you can think of **something
as collect (*) and make dictionary (*), and name it something.
**something
as a parameter to the function. You'll see that this code will make the same dictionary as before.
a = dict(one=1, two=2)You have more options to make the dictionary.
class dict(mapping, **kwarg) class dict(iterable, **kwarg)For the first case, when first item is a mapping (other dictionary), it will build a new dictionary with the contents of it together with the additional parameters.
b = dict({'one': 1, 'two': 2})For the next case, the first parameter can be a list with lists that has two elements.
c = dict(zip(('one', 'two'), (1, 2))) d = dict([['two', 2], ['one', 1]])
zip
method has two parameters, and iterate over the elements in each of the two elements to zip a list of list that contains two elements from each parameters.
items()
.
d = {'banana': 3, 'apple':4, 'pear': 1, 'orange': 2} print d print d.items()
{'orange': 2, 'pear': 1, 'banana': 3, 'apple': 4} [('orange', 2), ('pear', 1), ('banana', 3), ('apple', 4)]
ant
.
public class Hello { int add(int x, int y) { return (x + y); } int sub(int x, int y) { return (x - y); } }
import junit.framework.*; import static org.junit.Assert.assertEquals; public class HelloTest extends TestCase { private Hello tester = null; protected void setUp() { tester = new Hello(); } public void testAdd() { assertEquals("Result1", 15, tester.add(10, 5)); } }TestCase comes from junit.framework.*, And you need to have '.' for classpath in order to find the class under the test. You need to copy the junit.jar in the classpath also.
junit.textui.TestRunner
is called with the test class (HelloTest) parameter.
javac Hello.java javac -cp .:junit-4.11-SNAPSHOT.jar HelloTest.java java -cp .:junit-4.11-SNAPSHOT.jar junit.textui.TestRunner HelloTest
. Time: 0.001 OK (1 test)
import junit.framework.*; import static org.junit.Assert.assertEquals; public class Hello2Test extends TestCase { private Hello tester = null; protected void setUp() { super.setup(); tester = new Hello(); } public void testSub2() { assertEquals("Result1", 15, tester.sub(20, 5)); } public void testSub() { assertEquals("Result1", 15, tester.sub(20, 5)); } }
@Override protected void setUp() { tester = new Hello(); }
import junit.framework.*; import static org.junit.Assert.assertEquals; public class Hello2Test extends TestCase { private Hello tester = null; public Hello2Test(String str) { super(str); } @Override protected void setUp() { tester = new Hello(); } public void testAdd() { assertEquals("Result1", 15, tester.add(10, 5)); } public void testAdd2() { assertEquals("Result2", 25, tester.add(10, 15)); } public static Test suite() { TestSuite suite= new TestSuite(); suite.addTest( new Hello2Test("testAdd") { protected void runTest() { testAdd(); } } ); suite.addTest( new Hello2Test("testAdd2") { protected void runTest() { testAdd2(); } } ); return suite; } public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } }
public static Test suite() { // method 1 return new TestSuite(HelloTest.class); }You can just execute the test like normal java code
javac Hello.java javac -cp .:junit-4.11-SNAPSHOT.jar HelloTest.java java -cp .:junit-4.11-SNAPSHOT.jar HelloTest
import junit.framework.*; public class HelloTestSuite { public static Test suite() { TestSuite suite= new TestSuite(); suite.addTest(new HelloTest("testAdd")); suite.addTest(new Hello2Test("testAdd")); suite.addTest(new Hello2Test("testAdd2")); return suite; } public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } }One can even concatenate the test cases into suite.
public class HelloTestSuite { public static Test suite() { TestSuite suite= new TestSuite(); suite.addTestSuite(HelloTest.class); suite.addTestSuite(Hello2Test.class); return suite; } public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } }
$latex \displaystyle S(n)=\sum_{k=1}^{n}{\frac{1}{T_{k}}=\sum_{k=1}^{n}{\frac{6}{k(k+1)(k+2)}$
This is the result:
$latex \displaystyle S(n)=\sum_{k=1}^{n}{\frac{1}{T_{k}}=\sum_{k=1}^{n}{\frac{6}{k(k+1)(k+2)}$
The code is as follows:
blogger.com
, and choose your blogspot. Open layout.
Then, open "Add a Gadget", and select HTML/Javascript.
When you need to change some of the template, you also can edit the template HMTL code.
Then add your code in there. I have this for my code.
You can edit the code anytime you want.