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
/** | |
* this work's fine on mockito 1.9.5 | |
*/ | |
@Test | |
public void testServlet() throws Exception { | |
HttpServletRequest request = mock(HttpServletRequest.class); | |
HttpServletResponse response = mock(HttpServletResponse.class); | |
when(request.getParameter("username")).thenReturn("me"); | |
when(request.getParameter("password")).thenReturn("secret"); |
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
/** | |
* get recipe object from parse | |
* Object from parse query is not controlled by $scope, so using defer to pass it to $scope | |
*/ | |
// call $q.defer() | |
var RecipeDfd = $q.defer(); | |
// call parse query and resolve it | |
var Recipe = Parse.Object.extend("Recipe"); |
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
/** | |
* use $sce.trustAsResourceUrl(SOME_URL) to fix the security issue | |
*/ | |
$scope.videoUrl = $sce.trustAsResourceUrl(recipe.get("video").url); |
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
-- thanks to all in this article | |
-- https://community.oracle.com/thread/618903 | |
-- | |
FOR x IN (SELECT * FROM user_tables) | |
LOOP | |
EXECUTE IMMEDIATE 'GRANT SELECT ON ' || x.table_name || ' TO <<someone>>'; | |
END LOOP; |
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
/* | |
* bootstrap can use <a href='#' class='some-class' >link</a> as a button, | |
* and angular catches <a>link</a> click event to do the route. | |
* this is how to prevent the routing being triggered when user click the button. | |
*/ | |
$scope.doThings = function($event){ | |
$event.stopPropagation(); //prevent event propagation | |
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 String copyString(String input){ | |
if (input == null){ | |
return null; | |
} | |
try{ | |
StringBuildersb = newStringBuilder(); | |
for (inti=0;i<input.codePointCount(0,input.length());i++){ | |
sb.appendCodePoint(input.codePointAt(i)); |
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
//MD5 | |
import java.security.MessageDigest; | |
public class MD5 { | |
public static String hash(String plainText) { | |
MessageDigest cry = null; | |
try { | |
cry = MessageDigest.getInstance("MD5"); | |
} catch (Exception e) { |
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 static <T, E> Set<T> getKeysByValue(Map<T, E> map, E value) { | |
Set<T> keys = new HashSet<T>(); | |
for (Entry<T, E> entry : map.entrySet()) { | |
if (entry.getValue().equals(value)) { | |
keys.add(entry.getKey()); | |
} | |
} | |
return keys; | |
} |
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 React = require("react"); | |
module.exports = React.createClass({ | |
..., | |
// open new spotify oauth window | |
handleLoginRequest: function(){ | |
var url = 'https://accounts.spotify.com/authorize' + | |
'?client_id=' + this.props.clientId + | |
'&redirect_uri=' + encodeURIComponent(this.props.redirectUri) + | |
'&scope=' + encodeURIComponent(this.props.scope) + |
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
chocolatey install guide |
OlderNewer