Sunday, December 12, 2010

Post to wcf service windows phone 7

namespace sendsms
{
public partial class Page1 : PhoneApplicationPage
{
public Page1(string s , string u , string t)
{
InitializeComponent();
smssendClient client = new smssendClient();
client.sendsmsCompleted += new EventHandler(client_sendsmsCompleted);
client.sendsmsAsync(s, u, t);

}
void client_sendsmsCompleted(object sender, sendsmsCompletedEventArgs e)
{
textBlock1.Text = e.Result;
}
}
}

Saturday, August 28, 2010

Populate drop down liast repeater

protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
DropDownList dll = (DropDownList )e.Item.FindControl("ddOptions");
if (dll != null)
{
string ID = //Grab the id here
DataTable dt = // call the method from your Class library that returns a DataTable and pass the value of ID as the paramter

if (dt.Rows.Count > 0)
{
dll.DataSource = dt;
dll.DataTextField = "ColumnName";
dll.DataValueField = "ColumnName";
dll.DataBind();
}
}

}

}

Tuesday, August 10, 2010

web site tools

http://www.feedbackarmy.com/

https://www.usertesting.com/

Saturday, August 7, 2010

BIt.ly api asp.net c#

C# class bitlyapi.cs

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

///
/// Summary description for bitly
///

public static class BitlyApi
{
private const string apiKey = "YOUR API KEY";
private const string login = "YOUR LOGIN";

public static BitlyResults ShortenUrl(string longUrl)
{
var url =
string.Format("http://api.bit.ly/shorten?format=xml&version=2.0.1&longUrl={0}&login={1}&apiKey={2}",
HttpUtility.UrlEncode(longUrl), login, apiKey);
var resultXml = XDocument.Load(url);
var x = (from result in resultXml.Descendants("nodeKeyVal")
select new BitlyResults
{
UserHash = result.Element("userHash").Value,
ShortUrl = result.Element("shortUrl").Value
}
);
return x.Single();
}
}

public class BitlyResults
{
public string UserHash { get; set; }

public string ShortUrl { get; set; }
}


Any c# .cs code behind page

string longurl = "http://www.longurl.com;
var shortUrl = BitlyApi.ShortenUrl(longurl).ShortUrl;
bitlyurl = shortUrl.ToString();

Thursday, July 22, 2010

unique entries stored procedure

IF NOT EXISTS(SELECT @uid,@post_id,@travelerid FROM web_like_log WHERE uid=@uid and post_id=@post_id or travelerid=@travelerid)

Friday, July 2, 2010

get you tube thumbnail images

http://img.youtube.com/vi//1.jpg
http://img.youtube.com/vi//2.jpg
http://img.youtube.com/vi//3.jpg
http://img.youtube.com/vi//0.jpg

Friday, June 25, 2010

Iphone APN code sample

- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Add the tab bar controller's current view as a subview of the window
[window addSubview:tabBarController.view];
NSLog(@"Initiating remoteNoticationssAreActive");
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound |UIRemoteNotificationTypeAlert)];
}
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSLog(@"devToken=%@",deviceToken);
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSLog(@"Error in registration. Error: %@", err);
}

Wednesday, June 9, 2010

Twitter like notfication jquery notifier asp.net

So was looking at something like twitter uses for notficaiton of events (Tweet sent , something updated , something wrong etc. etc.) Came across jnotify. anyway here is the code ..

page.cs - Pretend we are using a web service to log the user in

protected void Button1_Click(object sender, EventArgs e)
{
com.webservice.user ulup = new com.webservice.user();
int username = ulup.Checkuser_mobile(mobile.Text);
if (username != 0) //If the login failed you could send back something other than 0 thats just what i am doing .
{

Panel2.Enabled = true; //This panel is hidden in the .aspx onload


}

Friday, May 21, 2010

bind asp.net checkbox to bool

Check box asp.net - asp:checkbox id="social_facebook" runat="server" Checked='<%# Bind("True") %>

Code behind - cmd.Parameters.Add("@p_facebook", SqlDbType.Bit).Value = social_facebook.Checked;

using a stored procedure with p_facebook as a parameter

Tuesday, May 18, 2010

random number asp.net c#

this is true random and unique

string number = String.Format("{0:d9}", (DateTime.Now.Ticks / 10) % 1000000000);

Friday, April 30, 2010

CODE FB feed

FB Feed iframe

Sunday, April 25, 2010

Flickr API

1. Get your nsid of the user

add your api key

2.http://api.flickr.com/services/rest/?&method=flickr.people.getPublicPhotos&api_key=&user_id=36897512@N03&format=json&per_page=50

3. make the response json or xml

4. get the value of the image id http://www.flickr.com/photos/36897512@N03/image_id_value_here/

4. photo set id



Sunday, March 21, 2010

Create a linux job to delete zip files 3 days old

find /var/www/html/*.zip -mtime +3 -exec rm {} \;

Monday, March 15, 2010

ignore eclipse project files in git

place .gitignore in your eclipse project with these parameters

.settings
.project
.buildpath
.gitignore

Wednesday, March 3, 2010

Recursivly copy files linux

find . -type f -name \*.eps -exec cp \{\} \;