This file contains 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
$(function () { | |
$.when(getPosition()) | |
.then(lookupCountry) | |
.done(displayResults) | |
.fail(displayError) | |
}); |
This file contains 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
var Up1 = function() { | |
var State = { | |
PENDING: 0, | |
FULFILLED: 1, | |
REJECTED: 2 | |
}; | |
} |
This file contains 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
public class MyBrowser extends Activity { | |
private final String jsInjectCode = | |
"function parseForm(event) {" + | |
" var form = this;" + | |
" // make sure form points to the surrounding form object if a custom button was used | |
" if (this.tagName.toLowerCase() != 'form')" + | |
" form = this.form;" + | |
" var data = '';" + | |
" if (!form.method) form.method = 'get';" + | |
" data += 'method=' + form.method;" + |
This file contains 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 DataSource getDataSource() { | |
JdbcDataSource dataSource = new JdbcDataSource(); | |
dataSource.setURL(JDBC_URL); | |
dataSource.setUser(USER); | |
dataSource.setPassword(PASSWORD); | |
return dataSource; | |
} |
This file contains 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
- request: | |
method: GET | |
url: /hello-world | |
response: | |
status: 200 | |
headers: | |
content-type: application/json | |
body: '{"id": 1, "name": "Up1"}' |
This file contains 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
@Before | |
public void createCSVFile() throws Exception { | |
file = temporaryFolder.newFile("input.txt"); | |
PrintWriter out = new PrintWriter(file); | |
out.print("1,2,3,4,5"); | |
out.close(); | |
} |
This file contains 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.runner.RunWith; | |
import static org.junit.Assert.*; | |
import static com.mscharhag.oleaster.runner.StaticRunnerSupport.*; | |
import com.mscharhag.oleaster.runner.OleasterRunner; | |
@RunWith(OleasterRunner.class) | |
public class FizzBuzzTest { | |
private FizzBuzz fizzBuzz; |
This file contains 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
public class EmailFormatRule implements RegisterRule { | |
public void validate(User user) { | |
String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; | |
Pattern validEmailPattern = Pattern.compile(EMAIL_PATTERN); | |
if( !validEmailPattern.matcher(user.getEmail()).matches() ) { | |
throw new IllegalArgumentException("Email is wrong format"); | |
} | |
} |
This file contains 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
public abstract class AbstractCSVReader<T> { | |
public List<T> getAll(File file) throws Exception { | |
List<T> returnData = new ArrayList<>(); | |
try (BufferedReader reader = new BufferedReader(new FileReader(file))) { | |
String line = reader.readLine(); | |
while (line != null && !"".equals(line.trim())) { | |
String[] tokens = line.split("\\s*,\\s*"); | |
T data = unmarshall(tokens); | |
returnData.add(data); |
This file contains 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
<script> | |
var arr = []; | |
function onAdd() { | |
arr.push({ | |
key: Math.floor((Math.random() * 100) + 1), | |
cutomerCode: 1234, | |
clientCode: 2344 | |
}); |