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
/* | |
* FACEBOOK Loading | |
*/ | |
window.fbAsyncInit = function () { | |
FB.init({ | |
appId: FB_APPID, | |
fileUpload: true, | |
status: true, // check login status | |
cookie: true, // enable cookies to allow the server to access the session | |
xfbml: true, // parse social plugins on this page |
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
function close_popupWindow() { | |
window.self.opener = window.self; | |
window.self.close(); | |
} |
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
static WebRequest request; | |
private static void sendAndReceive() | |
{ | |
// The request with a big timeout for receiving large amout of data | |
request = HttpWebRequest.Create("http://localhost:8081/index/"); | |
request.Timeout = 100000; | |
// The connection timeout | |
var ConnectionTimeoutTime = 100; | |
Timer timer = new Timer(ConnectionTimeoutTime); |
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
using (var client = new HttpClient()) | |
{ | |
var values = new List<KeyValuePair<string, string>>(); | |
values.Add(new KeyValuePair<string, int>("n", "42")); | |
values.Add(new KeyValuePair<string, string>("s", "string value")); | |
var content = new FormUrlEncodedContent(values); | |
var response = await client.PostAsync("http://www.domain.org/receiver.aspx", content); |
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
public void test(){ | |
//var request = System.Net.HttpWebRequest.CreateHttp("http://localhost:8081/index/"); | |
var request = System.Net.HttpWebRequest.Create("http://localhost:8081/index/"); | |
request.Method = "POST"; | |
string filename = "foo\u00A0bar.dat"; // Invalid characters in filename, the server will refuse it | |
request.Headers["Content-Disposition"] = string.Format("attachment; filename*=utf-8''{0}", Uri.EscapeDataString(filename)); | |
request.ContentType = "application/octet-stream"; | |
request.ContentLength = 100 * 1024 * 1024; | |
// Upload the "file" (just random data in this case) |
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
//Disable F5 | |
$(document).on("keydown", function disableF5(e) { | |
if ((e.which || e.keyCode) == 116) e.preventDefault(); | |
}); | |
//Disable resizing | |
var size = [window.outerWidth, window.outerHeight]; | |
$(window).resize(function () { | |
window.resizeTo(size[0], size[1]); | |
}); |
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
/** | |
* | |
* Base64 encode / decode | |
* http://www.webtoolkit.info/javascript-base64.html | |
**/ | |
var Base64 = { | |
// private property | |
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", |
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
//Simple way: | |
var utf8 = unescape(encodeURIComponent(utf16_str)); | |
//Or (http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array): | |
function toUTF8Array(str) { | |
var utf8 = []; | |
for (var i=0; i < str.length; i++) { | |
var charcode = str.charCodeAt(i); | |
if (charcode < 0x80) utf8.push(charcode); | |
else if (charcode < 0x800) { |
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
public static class Helper | |
{ | |
public static MvcHtmlString HelperMethod(this HtmlHelper<TModel> htmlHelper) | |
{ | |
htmlHelper.Resource("<link rel='stylesheet' href='/Content/bootstrap-multiselect.css' type='text/css'/>", "css"); | |
htmlHelper.Resource("<script type='text/javascript' src='/Scripts/bootstrap-multiselect.js'></script>", "js"); | |
//... | |
} | |
} |
OlderNewer