Monday, October 19, 2009

Send HTTP post in actionscript

var sendInfo:LoadVars = new LoadVars();



//Load up all the variables you want to POST
sendInfo.username = "";
sendInfo.password = "!";


sendInfo.sendAndLoad("http://urlhere",sendInfo,"GET");

Tuesday, August 25, 2009

Testing Sendmail Linux redhat 5

sudo echo "subject:testing send mail new linx servers" | /usr/lib/sendmail -v email@email.com > sendmail.out


sends output to sendmail.out file

Tuesday, July 14, 2009

Show and hide a div using jquery

A friend of mine asked about this so here is the result

Link to source

Monday, June 29, 2009

Monday, June 22, 2009

My Microsoft Tag









you can download tag at gettag.mobi
here is my Microsoft tag it dials my number


Thursday, June 11, 2009

Saving Skype voice mails to your pc

This is on Mac Leapord only -

Step 1. Install http://www.pamela-systems.com/products/
Step 2. Play the Skype voice mail
Step 3. The voice mail will be saved as a .mov into your movies folder
Step 4. Install ffmpeg on your mac
Step 5. convert the .mov into an .mp3 or wav using ffmpeg

converting mp3 to wav file try to get the file around 800 kb if you can

  1. Step2

    Run Audacity and import the music you want to convert. To do this, click on "File" and select "Open." Then select the file you want to convert to mono. Make sure the file you are converting is already in stereo.

  2. Step3

    Look at the box that appears after you import your file. You should see blue waveforms. To the left of the waveforms, you will see a bunch of numbers and other settings in a box. In the top left corner of the box, locate the arrow (which is to the left of the 1.0 number).

  3. Step4

    Click the arrow and select "Split Stereo Track" from the drop-down menu. Now you will notice that track has been split into left and right channels that you can control.

  4. Step5

    Click the arrow by the top (Left channel) waveform (this will also be to the left of top waveform's 1.0 marking). Select "mono" from the drop-down menu.

  5. Step6

    Click on the lower (Right channel) arrow. This will be located to the left of the lower waveform's 1.0 marking. Select "mono" from the drop-down menu. At this point, the boxes to the left of the top and bottom waveforms should both say "mono." If either still says "right" or "left," ensure that you followed the above steps and switched each channel to mono in the drop-down menu.

  6. Step7

    Export your now mono song by clicking on the File tab and selecting one of the export options. Choose the directory you want to export the file to and you're done.


Your done

Tuesday, May 12, 2009

Consuming XML Iphone SDK



Below is the project to consume XML in Iphone using the NSXMLParser , i will be updating this regularly. Download it here Code



















Friday, April 24, 2009

Mail For Exchange Android

Finally worked go here http://moonrug.com/android/download.html

Thursday, April 23, 2009

Update twitter status ASP.NET C#






Here is a quick and easy way to update twitter via asp.net c#

1. Download and add this .dll to your bin (asp.net 3.0) http://code.google.com/p/twitterizer/


2. Here is your code

Download here

Monday, April 20, 2009

Google MAPS iphone UIWEBVIEW


I had a task to create a web view based on a zip code input via an iphone app here is the result

Download it here

Thursday, April 16, 2009

Replace blank spaces in VI








This is really basic but tons of folks do not know how to do it and it comes in handy for data clean up.

Use the below command in VI
:%s///g

Thursday, April 2, 2009

Monday, March 23, 2009

RSS reader IPHONE SDK 2.1

Change

NSString * path = @"http://rss.cnn.com/rss/money_latest.rss";

With

NSString * path = @"Yours";

download the zip here

Monday, March 16, 2009

Google charts with visualazation via SVG and VML

http://code.google.com/apis/visualization/documentation/gallery/piechart.html

sample here

http://www.mobilegreatness.com/charts.html

Wednesday, March 4, 2009

WAP forms Verizon Open wave devices

I have found one small issue with some veizon phones when it comes to supporting forms in WAP on some verozin phones in the User profile there is a method called "Forms inside of tables" this value is either true or false. If false your forms will NOT be displayed if they are inside of html (tables , tr etc. etc.) it is good proactice for WAP 2.0 to not have forms inside of html tags this will fix your issue.

Tuesday, March 3, 2009

Ad mobs ads iphone sdk

If you are wondering why after 20 minutes of adding your ad mob ads they dont show up , i have found that it takes around 4-5 hours for your ads to show up even on your emulator so dont worry your code is right something is just taking a long time to propagate.

Google Adsense SMS


a.aspx.cs

protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Keep Text Messaging FREE AND SAFE click our ad below.");
Response.Write("
");
// Response.Write("Visit www.mobilegreatness.com From your PC to get your Free SMS widget");
// Response.Write("To support us, please click on below google ad");
//Response.Write("
");
string googleScheme = "http://";
string googleHost = Server.UrlEncode(googleScheme + Request.ServerVariables["HTTP_HOST"]);
double googleTime = (DateTime.Now - new
DateTime(1970, 1, 1)).TotalSeconds;
double googleDt = (1000 * googleTime) + Math.Round(1000 * Timer() -
(int)Timer());

string https = Request.ServerVariables["HTTPS"];
if (https.IndexOf("on") > -1)
{
googleScheme = "https://";
}

string googleAdUrl = "http://pagead2.googlesyndication.com/pagead/ads?ad_type=text_image&channel=" +
"&client=ca-mb-pub-3965045331381248" +
"&color_border="+googleColor("555555", googleTime) +
"&color_bg="+ googleColor("EEEEEE", googleTime) +
"&color_link=" + googleColor("400058", googleTime) +
"&color_text=" + googleColor("000000", googleTime) +
"&color_url=" + googleColor("008000", googleTime) +
"&dt=" +googleDt +
"&format=mobile_single" +
"&host="+googleHost +
"&ip=" + Server.UrlEncode(Request.ServerVariables["REMOTE_ADDR"]) +
"&markup=xhtml&oe=utf8&output=xhtml" +
"&ref=" + Server.UrlEncode(Request.ServerVariables["HTTP_REFERER"])
+"&url=" + googleHost +
Server.UrlEncode(Request.ServerVariables["URL"]) +
"&useragent=" +
Server.UrlEncode(Request.ServerVariables["HTTP_USER_AGENT"]) +
googleScreenRes();

WebClient wc = new WebClient();
string googleAdOutput = wc.DownloadString(googleAdUrl);
Response.Write(googleAdOutput);
HttpWebRequest req = (HttpWebRequest)
WebRequest.Create(googleAdUrl);
HttpWebResponse resp = null;

try
{

req.Timeout =
Int32.Parse(ConfigurationManager.AppSettings["Google_Timeout_Msec"]);
resp = (HttpWebResponse)req.GetResponse();

Stream responseStream = resp.GetResponseStream();
StreamReader streamReader = new StreamReader(responseStream,
Encoding.UTF8);
googleAdOutput = streamReader.ReadToEnd();

}

catch (HttpException htex)
{
}
catch (Exception exception)
{

googleAdOutput = "";

}
finally
{
// According to MS doc. it's only necessary to close either

if (resp != null) {
resp.Close();
}
}
}
string googleColor(string value, double random)
{
string[] colorArray = value.Split(',');
return colorArray[(int)random % colorArray.Length];

}

string googleScreenRes()
{
string screenRes = Request.ServerVariables["HTTP_UA_PIXELS"];
char delimiter = 'x';
if (screenRes == null)
{
screenRes = Request.ServerVariables["HTTP_X_UP_DEVCAP_SCREENPIXELS"];
delimiter = ',';


}
if (screenRes != null)
{
string[] resArray = screenRes.Split(delimiter);
if (resArray.GetUpperBound(0) + 1 == 2)
{
return "&u_w=" + resArray[0] + "&u_h=" + resArray[1];
}
}
return "";

}

double Timer()
{
return (DateTime.Now - DateTime.Now.Date).TotalSeconds;

}

}


a.aspx


<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Web" %>






<% double googleTime = (DateTime.Now - new DateTime(1970,1,1)).TotalSeconds; double googleDt = (1000 * googleTime) + Math.Round(1000 * Timer() -(int)Timer()); string googleScheme = "http://"; string https = Request.ServerVariables["HTTPS"]; if (https.IndexOf("on") > -1)
{
googleScheme = "https://";

}

string googleHost = Server.UrlEncode(googleScheme +Request.ServerVariables["HTTP_HOST"]);
string googleAdOutput = "";
string googleAdUrl = "http://pagead2.googlesyndication.com/pagead/ads?" +
"ad_type=text_image" +
"&channel=" +
"&client=ca-mb-pub-3965045331381248" +
"&color_border=" + googleColor("555555", googleTime) +
"&color_bg=" + googleColor("EEEEEE", googleTime) +
"&color_link=" + googleColor("400058", googleTime) +
"&color_text=" + googleColor("000000", googleTime) +
"&color_url=" + googleColor("008000", googleTime) +
"&dt=" + googleDt +
"&format=mobile_single" +
"&host=" + googleHost +
"&ip=" + Server.UrlEncode(Request.ServerVariables["REMOTE_ADDR"]) +
"&markup=xhtml" +
"&oe=utf8" +
"&output=xhtml" +
"&ref=" + Server.UrlEncode(Request.ServerVariables["HTTP_REFERER"]) +

"&url=" + googleHost +
Server.UrlEncode(Request.ServerVariables["URL"]) +
"&useragent=" +
Server.UrlEncode(Request.ServerVariables["HTTP_USER_AGENT"]) +
googleScreenRes();

HttpWebRequest req = (HttpWebRequest)
WebRequest.Create(googleAdUrl);
HttpWebResponse resp;

try {

req.Timeout =
Int32.Parse(ConfigurationManager.AppSettings["Google_Timeout_Msec"]);
resp = (HttpWebResponse)req.GetResponse();

Stream responseStream = resp.GetResponseStream();
StreamReader streamReader = new StreamReader(responseStream,Encoding.UTF8);
googleAdOutput = streamReader.ReadToEnd();
resp.Close();

} catch (Exception exception) {
// Something went wrong. This is a good place to log theexception.
googleAdOutput = "";
}
%> -->



SPOOF SMS Enjoy

http://www.mobilegreatness.com

AJAX Timer asp.net Datagrid

ajax.aspx.cs

protected void Page_Load(object sender, EventArgs e)
{
GridData.DataSource = getData();
GridData.DataBind();
Page.DataBind();
}


protected void Timer1_Tick(object sender, EventArgs e)
{
//Label1.Text = "Total Messages of " + DateTime.Now.ToLongTimeString();


}

public static DataTable getData()
{
DataSet ds = new DataSet();
try
{
OdbcConnection conn = new OdbcConnection(ConfigurationManager.ConnectionStrings["connection_string"].ConnectionString);
string query = String.Format("Stored Procedure");
OdbcDataAdapter adap = new OdbcDataAdapter(query, conn);

adap.Fill(ds);

}
catch (Exception ex)
{

}
return ds.Tables[0];
}
}

ajax.aspx

Delete ALL mail out of queue SENDMAIL

run this as a cron

0,15,30,45 * * * * find /var/spool/mqueue -type f -print0 | xargs -0 rm -rf


as you can see it will do it every 15 minutes works perfect fedora sendmail

CURL post from asp.net to php

curlpost.aspx.cs

public string HttpPost(string uri, string parameters)
{
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Method = "POST";
byte[] bytes = Encoding.ASCII.GetBytes(parameters);
Stream os = null;
try
{
webRequest.ContentLength = bytes.Length;
os = webRequest.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
}
catch (WebException ex)
{

}
finally
{
if (os != null)
os.Close();
}

try
{
WebResponse webResponse = webRequest.GetResponse();
if (webResponse == null)
{ return null; }
StreamReader sr = new StreamReader(webResponse.GetResponseStream());
return sr.ReadToEnd().Trim();
}
catch (WebException ex)
{

}
return null;
}


objmm.HttpPost("http://phppaghere", "from_number=" + dtVot.Rows[0]["fromphonenumber"].ToString() + "&to_number=" + phonenumber);
Consuming SOAP service (asmx) in php

$this->key,
'phonenumber' => $member_phone_number,
'memberid' => $member_id,
'programid' => $program_id,
'shortcode' => "something_here"
);
try {
logger('info', "Error Message");
$client = new SoapClient($this->WSDL);
$client->SOAPMETHODHERE($params);
} catch (SoapFault $exception) {
mailer('err', "EXCEPTION IN Calling : " . $exception);
}

$this->sendMessage($member_id, $this->confirmMsgID);
}
}

//ELSE NUM_ROWS <= 0 //DONT DO ANYTHING, THIS PHONE IS NEVER SEEN BEFORE //SOMEONE JUST SENDING OUT OF THE BLUE logger('info', " DOING NOTHING"); } private function sendMessage($member_id, $message_id){ logger('info', "SEND MESSAGE function::Sending msg ID=" . $message_id . " To memmberid=" . $member_id); class_exists('Outgoing_Message_Queue') || require('classes/outgoing_message_queue.php'); $outgoing_message_obj = new Outgoing_Message_Queue($message_id); $outgoing_message_obj->sendToMember($member_id);
}

}
?>


Consuming a web SOAP web service (asmx) with iphone (sdk)

here i go

View controller

//
// Hello_SOAPAppDelegate.m
// Hello_SOAP
//
// Created by Dave McAnall on 11/2/08.
// Copyright __MyCompanyName__ 2008. All rights reserved.
//

#import "Hello_SOAPViewController.h"

@implementation Hello_SOAPViewController

@synthesize greeting, tonumber,fromnumber,nameInput, webData, soapResults, xmlParser;

-(IBAction)buttonClick:(id)sender
{
recordResults = FALSE;

NSString *soapMessage = [NSString stringWithFormat:
@"\n"
"\n"
"\n"
"\n"
"%@\n"
"%@\n"
"%@\n"
"keys .net ones\n"
"
\n"
"
\n"
"
\n", tonumber.text,fromnumber.text,nameInput.text,"key"
];
NSLog(soapMessage);

NSURL *url = [NSURL URLWithString:@"http://yourasmx.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];

[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://tempuri.org/SendTextToFriend" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

if( theConnection )
{
webData = [[NSMutableData data] retain];
}
else
{
NSLog(@"theConnection is NULL");
}

[nameInput resignFirstResponder];
[fromnumber resignFirstResponder];
[tonumber resignFirstResponder];

}

-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[webData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[webData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"ERROR with theConenction");
[connection release];
[webData release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"DONE. Received Bytes: %d", [webData length]);
NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
NSLog(theXML);
[theXML release];

if( xmlParser )
{
[xmlParser release];
}

xmlParser = [[NSXMLParser alloc] initWithData: webData];
[xmlParser setDelegate: self];
[xmlParser setShouldResolveExternalEntities: YES];
[xmlParser parse];

[connection release];
[webData release];
}

-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *)qName
attributes: (NSDictionary *)attributeDict
{
if( [elementName isEqualToString:@"SendTextToFriendResult"])
{
if(!soapResults)
{
soapResults = [[NSMutableString alloc] init];
}
recordResults = TRUE;
}
}
-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if( recordResults )
{
[soapResults appendString: string];
}
}
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if( [elementName isEqualToString:@"SendTextToFriendResult"])
{
recordResults = FALSE;
greeting.text = soapResults;
[soapResults release];
soapResults = nil;
}
}


/*
Implement loadView if you want to create a view hierarchy programmatically
- (void)loadView {
}
*/

/*
Implement viewDidLoad if you need to do additional setup after loading the view.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}


- (void)dealloc
{
[xmlParser release];
[super dealloc];
}
@end


Header

//
// Hello_SOAPViewController.h
// Hello_SOAP
//
// Created by Dave McAnall on 11/2/08.
// Copyright __MyCompanyName__ 2008. All rights reserved.
//

#import

@interface Hello_SOAPViewController : UIViewController
{
IBOutlet UITextField *nameInput;
IBOutlet UITextField *tonumber;
IBOutlet UITextField *fromnumber;
IBOutlet UILabel *greeting;
NSMutableData *webData;
NSMutableString *soapResults;
NSXMLParser *xmlParser;
BOOL *recordResults;
}

@property(nonatomic, retain) IBOutlet UITextField *nameInput;
@property(nonatomic, retain) IBOutlet UITextField *tonumber;
@property(nonatomic, retain) IBOutlet UITextField *fromnumber;
@property(nonatomic, retain) IBOutlet UILabel *greeting;
@property(nonatomic, retain) NSMutableData *webData;
@property(nonatomic, retain) NSMutableString *soapResults;
@property(nonatomic, retain) NSXMLParser *xmlParser;

-(IBAction)buttonClick: (id) sender;

@end

XIB