Just a small example that shows the use of Task.
private async void Button_Click(object sender, RoutedEventArgs e) { string text = await Task.Run(() => Compute()); this.TextBlock.Text = text; }
Just a small example that shows the use of Task.
private async void Button_Click(object sender, RoutedEventArgs e) { string text = await Task.Run(() => Compute()); this.TextBlock.Text = text; }
The javascript code:
var dataString = "{Id:'" + id+ "',name:'" + name+ "'}";
$j.ajax({
type: "POST",
url: "Default.aspx/SubmitName",
data: dataString ,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (message) {
alert('Thank you!');
},
error: function (jqXhr, textStatus, errorThrown) {
alert("" + textStatus + "; " + errorThrown);
}
});
The server side function:
[System.Web.Services.WebMethod()]
public static bool SubmitName(string id, string name)
{
//some logic here
return false;
}
This code would receive an “Internal Server Error” 500 because in the JS the first parameter name is “Id” while on the server side it is “id”. The parameter names have to be the same (including casing!).
As long as hyperlink is not in a page control, should handle “RequestNavigate”:
<TextBlock> <Hyperlink NavigateUri="http://www.google.com" RequestNavigate="Hyperlink_RequestNavigate">Click here!</Hyperlink> </TextBlock>
private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e) { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(e.Uri.AbsoluteUri)); e.Handled = true; }
I always forget the exact syntax and waste time searching for an example on the web.
1: $.ajax({
2: type: "POST",
3: url: "Default.aspx/WebMethodWithParameters",
4: data: { param1: $('#val1').val(),
5: param2: $('#val2').val(),
6: param3: $('#val3').val()
7: },
8: success: function(msg) {
9: //on success callback
10: },
11: error: function(msg){
12: //on error callback
13: }
14: });
Well, I bought an iPhone. YEY!
I started to play with it (jailbreak off course…) and I did something wrong with the configuration for the tethering.
Next thing I know, I can’t connect to 3G nor to WiFi.
Some exploring brought me to the conclusion that restore is supposed to solve the issue. The problem is that when I choose to restore my phone with settings from backup – the problem came back.
I had to do a clean restore and to recreate everything!!! :(
I was ready to reinstall all my apps (both appstore and cydia), but I totally forgot about my contacts! (note to myself: iPhone is also a phone!)
Well, here comes the interesting part of this story. It took me some googling, but I managed to find a way to restore the contacts from the previous backups!
Here is how it is done:
Disclaimer: This is probably not the only way, and maybe even not the best one, but it worked for me. I take no responsibility if something happens (or doesn’t) with your iPhone, cat, wife or grandfather during the process.
1. Jailbreak your iPhone (Google to know how) and install Cydia
2. Install OpenSSH from Cydia on iPhone
3. Install WinSCP on your computer.
4. Download iPhoneBackupExtractor (Free version allows to extract only one file, but it was good enough for me…). No need to install, just execute the exe file.
5. Run the iPhoneBackupExtractor, choose the backup date:
Click next.
Choose the following option:
Next.
Now you will have to choose the file to restore. There are two of them for the contacts. If you use the free version of the backupextractor you will need to follow the previous steps twice to get both of the files. The files you need are located under (surprisingly) “AddressBook” folder:
As the file names imply, the first is the address book, the second is the images for the address book.
Store the files in some folder you will be able to find later…
6. Now let’s copy the file to the iPhone.
Connect with WinSCP to iPhone (here is how)
7. Browse to /var/mobile/Library/AddressBook
You should see there two files with suspiciously familiar names. Where did you see these names before?
8. Drag&Drop the files you just restored from backup to the above folder in winSCP program, and agree to replace the existing files.
9. You have your contacts back!!!
//get the IFRAME element - note no hashes in the name, we're using browser functionality
var iframeRef = document.getElementById("IFRAMEID");//focus the IFRAME element
$(iframeRef).focus();
//use JQuery to find the control in the IFRAME and set focus
$(iframeRef).contents().find("#CONTROLID").focus();
Source
Imdb (with preview) - http://gist.github.com/59109
Mozilla Add-ons - http://projects.fligtar.com/ubiquity/add-on.php
music is a command that use google hacks in order to find mp3 or ogg music.
video is a command that use google hacks in order to find video.
Note in Reader: Adds the current selection to your Google Reader Shared Items page and allows you to add a note to it
Google Image Search (preview, links, embedding) - http://www.jimmy2k.it/getimagescommand
jQuery
jquery: Searches the jQuery documentation.
[script] with two commands:
Others
notepad - Opens Notepad on Windows
paint - Opens MS Paint on Windows
note - The purpose of this command is to quickly save the inputted text (can be selected text or your own text) to a file on your disk without having to launch a text editor.
All taken from here
function pageLoad(sender, args) { if (args.get_isPartialLoad()) { alert(”Ajax call”); } else { alert(”PostBack or initial load”); } }
This plug-in formats and highlights code and also does the following:
I found that it is more flexible and readable for me to use the ToString formatting for dates
objDate.ToString("MM/dd/yyyy");
than to use this:
objDate.ToShortDateString()
Just an example from the original article, but it is self explanatory
<asp:DropDownList ID="ddlMimeType" runat="server">
<asp:ListItem Value="mp3">audio/mpeg</asp:ListItem>
<asp:ListItem Value="wma">audio/wma</asp:ListItem>
<asp:ListItem Value="other">Other</asp:ListItem>
</asp:DropDownList>
<asp:TextBox id="txbOtherMimetype" runat="server" />
<asp:RequiredFieldValidator id="valOtherMimetypeRequired" runat="server"
ControlToValidate="txbOtherMimetype" ForeColor="#990066"
ErrorMessage="You have to specify a custom mimetype." />
<script type="text/javascript">
$(document).ready(function()
{
$("#<%= ddlMimeType.ClientID %>").change(function()
{
toggleOtherMimeType(this);
});
}
function toggleOtherMimeType(elem)
{
if(elem!=undefined)
{
if(elem.value=="other")
{
$("#<%= txbEnclosureOtherMimetype.ClientID %>").show();
ValidatorEnable($("#<%= valEncOtherMimetypeRequired.ClientID %>")[0], true);
}
else
{
$("#<%= txbEnclosureOtherMimetype.ClientID %>").hide();
ValidatorEnable($("#<%= valEncOtherMimetypeRequired.ClientID %>")[0], false);
}
}
}
</script>
SELECT
GETDATE() AS DefaultFormat,
CONVERT(nvarchar(30), GETDATE(), 101) AS US,
CONVERT(nvarchar(30), GETDATE(), 103) AS UK,
CONVERT(nvarchar(30), GETDATE(), 111) AS Japan,
CONVERT(nvarchar(30), GETDATE(), 104) AS German,
CONVERT(nvarchar(30), GETDATE(), 112) AS ISO,
CONVERT(nvarchar(30), GETDATE(), 109) AS Date_with_Milliseconds