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
class Solution(object): | |
def countSmaller(self, nums): | |
""" | |
:type nums: List[int] | |
:rtype: List[int] | |
""" | |
idx = [0 for x in range(len(nums))] | |
for i in range(len(nums)): | |
idx[i] = (nums[i], 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
/** | |
* Problem Link: http://codeforces.com/problemset/problem/6/C | |
* Alice = getDivideIndex(..)+1; | |
* Bob = arrayLength - Alice; | |
*/ | |
public class Codeforces6C { | |
private static int getDivideIndexRec(int[] arr, int i, int j, boolean isLeft){ | |
if(i==j){ | |
if(isLeft) return i-1; | |
else return 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
public class StringSimilarity { | |
public static int calculate(String s){ | |
char[]arr=s.toCharArray(); | |
int length=arr.length; | |
int count=length; | |
for(int i=1;i<length;i++){ | |
int len=length-i; | |
int j=0; | |
for(;j<len;j++) | |
if(arr[j]!=arr[j+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
var a = Rx.Observable.create(function(observer) { | |
setInterval(function() { | |
var curA = Math.floor((Math.random() * 100) + 1); | |
console.log("Current value of a " + curA); | |
observer.onNext(curA); | |
}, 3000); | |
}); | |
var b = 0; | |
a.subscribe(function(val) { | |
b=val+1; |
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 a = 10; | |
var b = a + 1; | |
a = 20; | |
console.log(b); |
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
[EnableCors(origins: "*", headers: "*", methods: "*")] | |
// [Authorize] | |
public class ValuesController : ApiController | |
{ | |
private static List<string> values = new List<string>(); | |
// GET api/values | |
public IEnumerable<string> Get() | |
{ | |
return values; | |
} |
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
[RequireHttps] | |
[EnableCors(origins: "*", headers: "*", methods: "*")] | |
[Authorize] | |
[RoutePrefix("api/Account")] | |
public class AccountController : ApiController {/*class definition*/} |
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
OAuthOptions = new OAuthAuthorizationServerOptions | |
{ | |
//other stuff | |
TokenEndpointPath = new PathString("/Token") | |
// AllowInsecureHttp = true | |
}; |
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 RequireHttpsAttribute : AuthorizationFilterAttribute | |
{ | |
public override void OnAuthorization(HttpActionContext actionContext) | |
{ | |
if (actionContext.Request.RequestUri.Scheme != Uri.UriSchemeHttps) | |
{ | |
actionContext.Response = new HttpResponseMessage(System.Net.HttpStatusCode.Forbidden) | |
{ | |
ReasonPhrase = "HTTPS Required" | |
}; |
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
beforeSend: function (xhr) { | |
xhr.setRequestHeader("Authorization", 'Bearer ' + _access_token); | |
}, |
NewerOlder