Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-8 of 8 total  RSS 

US Area Codes PHP Array


<?php
//This is just a little array filled with all the area codes
//for each state. Useful for verifying phone numbers.
//Apologies for my screen name, I didn't want to bother registering
//for an account... But you guys helped me out alot so I felt
//like I had to give back. :)
$areacodes = array(780 => "AB",
403 => "AB",
907 => "AK",
205 => "AL",
256 => "AL",
334 => "AL",
251 => "AL",
870 => "AR",
501 => "AR",
479 => "AR",
480 => "AZ",
623 => "AZ",
928 => "AZ",
602 => "AZ",
520 => "AZ",
628 => "CA",
341 => "CA",
764 => "CA",
925 => "CA",
909 => "CA",
562 => "CA",
661 => "CA",
657 => "CA",
510 => "CA",
650 => "CA",
949 => "CA",
760 => "CA",
415 => "CA",
951 => "CA",
752 => "CA",
831 => "CA",
209 => "CA",
669 => "CA",
408 => "CA",
559 => "CA",
626 => "CA",
442 => "CA",
530 => "CA",
916 => "CA",
707 => "CA",
627 => "CA",
714 => "CA",
310 => "CA",
323 => "CA",
213 => "CA",
424 => "CA",
747 => "CA",
818 => "CA",
858 => "CA",
935 => "CA",
619 => "CA",
805 => "CA",
369 => "CA",
720 => "CO",
303 => "CO",
970 => "CO",
719 => "CO",
203 => "CT",
959 => "CT",
475 => "CT",
860 => "CT",
202 => "DC",
302 => "DE",
689 => "FL",
407 => "FL",
239 => "FL",
836 => "FL",
727 => "FL",
321 => "FL",
754 => "FL",
954 => "FL",
352 => "FL",
863 => "FL",
904 => "FL",
386 => "FL",
561 => "FL",
772 => "FL",
786 => "FL",
305 => "FL",
861 => "FL",
941 => "FL",
813 => "FL",
850 => "FL",
478 => "GA",
770 => "GA",
470 => "GA",
404 => "GA",
706 => "GA",
678 => "GA",
912 => "GA",
229 => "GA",
671 => "GU",
808 => "HI",
515 => "IA",
319 => "IA",
563 => "IA",
641 => "IA",
712 => "IA",
208 => "ID",
217 => "IL",
282 => "IL",
872 => "IL",
312 => "IL",
773 => "IL",
464 => "IL",
708 => "IL",
815 => "IL",
224 => "IL",
847 => "IL",
618 => "IL",
309 => "IL",
331 => "IL",
630 => "IL",
765 => "IN",
574 => "IN",
260 => "IN",
219 => "IN",
317 => "IN",
812 => "IN",
913 => "KS",
785 => "KS",
316 => "KS",
620 => "KS",
327 => "KY",
502 => "KY",
859 => "KY",
606 => "KY",
270 => "KY",
504 => "LA",
985 => "LA",
225 => "LA",
318 => "LA",
337 => "LA",
774 => "MA",
508 => "MA",
781 => "MA",
339 => "MA",
857 => "MA",
617 => "MA",
978 => "MA",
351 => "MA",
413 => "MA",
443 => "MD",
410 => "MD",
280 => "MD",
249 => "MD",
969 => "MD",
240 => "MD",
301 => "MD",
207 => "ME",
383 => "ME",
517 => "MI",
546 => "MI",
810 => "MI",
278 => "MI",
313 => "MI",
586 => "MI",
248 => "MI",
734 => "MI",
269 => "MI",
906 => "MI",
989 => "MI",
616 => "MI",
231 => "MI",
679 => "MI",
947 => "MI",
612 => "MN",
320 => "MN",
651 => "MN",
763 => "MN",
952 => "MN",
218 => "MN",
507 => "MN",
636 => "MO",
660 => "MO",
975 => "MO",
816 => "MO",
314 => "MO",
557 => "MO",
573 => "MO",
417 => "MO",
670 => "MP",
601 => "MS",
662 => "MS",
228 => "MS",
406 => "MT",
336 => "NC",
252 => "NC",
984 => "NC",
919 => "NC",
980 => "NC",
910 => "NC",
828 => "NC",
704 => "NC",
701 => "ND",
402 => "NE",
308 => "NE",
603 => "NH",
908 => "NJ",
848 => "NJ",
732 => "NJ",
551 => "NJ",
201 => "NJ",
862 => "NJ",
973 => "NJ",
609 => "NJ",
856 => "NJ",
505 => "NM",
957 => "NM",
702 => "NV",
775 => "NV",
315 => "NY",
518 => "NY",
716 => "NY",
585 => "NY",
646 => "NY",
347 => "NY",
718 => "NY",
212 => "NY",
516 => "NY",
917 => "NY",
845 => "NY",
631 => "NY",
607 => "NY",
914 => "NY",
216 => "OH",
330 => "OH",
234 => "OH",
567 => "OH",
419 => "OH",
380 => "OH",
440 => "OH",
740 => "OH",
614 => "OH",
283 => "OH",
513 => "OH",
937 => "OH",
918 => "OK",
580 => "OK",
405 => "OK",
503 => "OR",
971 => "OR",
541 => "OR",
814 => "PA",
717 => "PA",
570 => "PA",
358 => "PA",
878 => "PA",
835 => "PA",
484 => "PA",
610 => "PA",
445 => "PA",
267 => "PA",
215 => "PA",
724 => "PA",
412 => "PA",
939 => "PR",
787 => "PR",
401 => "RI",
843 => "SC",
864 => "SC",
803 => "SC",
605 => "SD",
423 => "TN",
865 => "TN",
931 => "TN",
615 => "TN",
901 => "TN",
731 => "TN",
254 => "TX",
325 => "TX",
713 => "TX",
940 => "TX",
817 => "TX",
430 => "TX",
903 => "TX",
806 => "TX",
737 => "TX",
512 => "TX",
361 => "TX",
210 => "TX",
936 => "TX",
409 => "TX",
979 => "TX",
972 => "TX",
469 => "TX",
214 => "TX",
682 => "TX",
832 => "TX",
281 => "TX",
830 => "TX",
956 => "TX",
432 => "TX",
915 => "TX",
435 => "UT",
801 => "UT",
385 => "UT",
434 => "VA",
804 => "VA",
757 => "VA",
703 => "VA",
571 => "VA",
540 => "VA",
276 => "VA",
381 => "VA",
236 => "VA",
802 => "VT",
509 => "WA",
360 => "WA",
564 => "WA",
206 => "WA",
425 => "WA",
253 => "WA",
715 => "WI",
920 => "WI",
414 => "WI",
262 => "WI",
608 => "WI",
353 => "WI",
420 => "WI",
304 => "WV",
307 => "WY");
?>

Python - SendSMS over BT and AT

// Send SMS over Bluetooth (AT Command)

import bluetooth

sockfd = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
sockfd.connect(('00:00:00:00:00:00', 1)) # BT Address
sockfd.send('ATZ\r')
sockfd.send('AT+CMGF=1\r')
sockfd.send('AT+CSCA="+393359609600"\r') # Client TIM ITA
sockfd.send('AT+CMGS="+39xxxxxxxxxx"\r') # TO PhoneNumber
sockfd.send('Messaggio da mandare...\n')
sockfd.send(chr(26)) # CTRL+Z
sockfd.close()

Mobile Phone Email to Text Message Gateways

AT&T
  number@mobile.att.net
CellularOne
  number@mobile.celloneusa.com    
Cingular
  number@mobile.mycingular.com
Nextel
  number@messaging.nextel.com
Sprint
  number@messaging.sprintpcs.com
T-Mobile
  number@tmomail.net
US Cellular
  number@email.uscc.net
Verizon
  number@vtext.com
Virgin Mobile
  number@vmobl.com

J2ME - System Properties

// System Properties J2ME

package System;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class SystemProperties extends MIDlet implements CommandListener
{
	private Command esci;
	
	private Display display;
	
	private Form form;
	
	protected void startApp() throws MIDletStateChangeException
	{
		display = Display.getDisplay(this);
		
		form = new Form("System Propiertis");
		form.setCommandListener(this);
		
		esci = new Command("Esci", Command.EXIT, 0);
		form.addCommand(esci);
		
		Runtime rt = Runtime.getRuntime();
		rt.gc(); // Garbage Collection
		
		form.append("Free Memory: " + rt.freeMemory() + "\n");
		form.append("Total Memory: " + rt.totalMemory() + "\n");
		form.append(showProp("microedition.configuration"));
		form.append(showProp("microedition.platform"));
		form.append(showProp("microedition.locale"));
		form.append(showProp("microedition.encoding"));
		form.append(showProp("microedition.encodingClass"));
		form.append(showProp("microedition.http_proxy"));
		
		display.setCurrent(form);
	}

	protected void pauseApp()
	{

	}

	protected void destroyApp(boolean unconditional) throws MIDletStateChangeException
	{
		notifyDestroyed();
	}

	public String showProp(String str)
	{
		String value = System.getProperty(str);
		StringBuffer stringbuffer = new StringBuffer(50);
		
		stringbuffer.setLength(0);
		stringbuffer.append(str);
		stringbuffer.append(" = ");
		
		if(value == null)
			stringbuffer.append("<undefined>");
		else
		{
			stringbuffer.append("\"");
			stringbuffer.append(value);
			stringbuffer.append("\"");
		}
		
		stringbuffer.append("\n");
		
		return stringbuffer.toString();
	}
	
	public void commandAction(Command c, Displayable d)
	{
		if(c == esci)
		{
			try
			{
				destroyApp(true);
			}
			catch(MIDletStateChangeException e)
			{
				showException(e);
			}
		}
	}
	
	public void showException(Exception e)
	{
		Alert alert = new Alert("Errore !!!");
		alert.setString(e.getMessage());
		alert.setType(AlertType.ERROR);
		alert.setTimeout(Alert.FOREVER);
		
		display.setCurrent(alert);
	}
}

Getting phone model

I put Korakot snippet (Looking up phone model using firmware code) into an useful module.

You need miso module.
All info can be found at this site

#
# Firmware.py  infos found at http://homepage.mac.com/alvinmok/nokia/firmware.html
#

'''
firmware.prefix_name 
firmware.suffix_name 
firmware.phone_model
firmware.phone_cpu_speed
'''
import sysinfo
import miso

ECPUSpeed = 0x0B

mapping_firmware_model={
  'RM-51': '3230',
  'RM-38': '3250',
  'NHM-10': '3600',
  'NHM-10X': '3620',
  'NHL-8': '3650',
  'NHL-8X': '3660',
  'RM-25': '6260',
  'RM-29': '6260b',
  'NHL-10': '6600',
  'NHL-12': '6620',
  'NHL-12X': '6620',
  'RM-1': '6630',
  'RH-67': '6670',
  'RH-68': '6670b',
  'RM-36': '6680',
  'RM-57': '6681',
  'RM-58': '6682',
  'RH-51': '7610',
  'RH-52': '7610b',
  'NHL-2NA': '7650',
  'RM-49': 'E60-1',
  'RM-89': 'E61-1',
  'RM-10': 'E70-1',
  'RM-24': 'E70-?',
  'NEM-4': 'N-Gage',
  'RH-29': 'N-Gage QD (asia/europe)',
  'RH-47': 'N-Gage QD (americas)',
  'RM-84': 'N70-1',
  'RM-99': 'N70-5',
  'RM-67': 'N71-1',
  'RM-112': 'N71-5',
  'RM-91': 'N80-3',
  'RM-92': 'N80-1',
  'RM-42': 'N90-1',
  'RM-43': 'N91-1',
  'RM-158': 'N91-5' }

mapping_prefix_description ={
 'N':'Mobile Phone',
 'R':'Computing Device',
 'T':'Terminal'}

mapping_suffix_description ={
    'B': 'GSM 900/1900',
    'C': 'DAMPS 800',
    'D': 'CDMA/AMPS 800',
    'E': 'GSM 900/1800',
    'F': 'NMT-450',
    'K': 'GSM 1800',
    'L': 'GSM 900/1800/1900 or GSM 850/1800/1900',
    'M': 'EGSM 900/1800 (may include WCDMA)',
    'N': 'IEEE 802.11b',
    'P': 'CDMA 800',
    'W': 'AMPS/TDMA 800/1900',
    'X': 'ETACS/TACS'}

sw = sysinfo.sw_version()
sw_list = sw.split(' ')

firmware_version = sw_list[1]
firmware_date = sw_list[2]
firmware_code=sw_list[3]

temp = firmware_code.split('-')
firmware_prefix = temp[0][0]
firmware_suffix = temp[0][-1]

prefix_name = mapping_prefix_description[firmware_prefix]
suffix_name = mapping_suffix_description[firmware_suffix]
phone_model = mapping_firmware_model[firmware_code] 
phone_cpu_speed = miso.get_hal_attr(ECPUSpeed) # CPU speed in Hz


usage:
>>>import firmware
>>>firmware.phone_model
>>>'6600'
>>>firmware.phone_cpu_speed
>>>104000

Looking up phone model using firmware code

You can lookup the firmware code by
dial *#0000#

For pys60 you can use
>>> import sysinfo
>>> sysinfo.sw_version()
u'V 3.42.1 16-10-03 NHL-10 (c) NMP'
>>> firmware = _.split(' ')[3]
>>> firmware
u'NHL-10'
>>>

Looking at the table here, a mapping can be made.
>>> mapping = {
  'RM-51': '3230',
  'RM-38': '3250',
  'NHM-10': '3600',
  'NHM-10X': '3620',
  'NHL-8': '3650',
  'NHL-8X': '3660',
  'RM-25': '6260',
  'RM-29': '6260b',
  'NHL-10': '6600',
  'NHL-12': '6620',
  'NHL-12X': '6620',
  'RM-1': '6630',
  'RH-67': '6670',
  'RH-68': '6670b',
  'RM-36': '6680',
  'RM-57': '6681',
  'RM-58': '6682',
  'RH-51': '7610',
  'RH-52': '7610b',
  'NHL-2NA': '7650',
  'RM-49': 'E60-1',
  'RM-89': 'E61-1',
  'RM-10': 'E70-1',
  'RM-24': 'E70-?',
  'NEM-4': 'N-Gage',
  'RH-29': 'N-Gage QD (asia/europe)',
  'RH-47': 'N-Gage QD (americas)',
  'RM-84': 'N70-1',
  'RM-99': 'N70-5',
  'RM-67': 'N71-1',
  'RM-112': 'N71-5',
  'RM-91': 'N80-3',
  'RM-92': 'N80-1',
  'RM-42': 'N90-1',
  'RM-43': 'N91-1',
  'RM-158': 'N91-5' }
>>> mapping[firmware]
'6600'
>>>

Symbian phone list

# S60 3rd Edition (Symbian OS v9.1)
Nokia E60, E61, E70
Nokia 3250
Nokia N71, N80, N91, N92

# S60 2nd Edition FP3 (Symbian OS v8.1)
Nokia N70, N90

# S60 2nd Edition FP2 (Symbian OS v8.0a)
Nokia 6630, 6680, 6681, 6682
Lenovo P930

# S60 2nd Edition FP1 (Symbian OS v7.0s enhanced)
Nokia 3230, 6260, 6620, 6670, 7610
Panasonic X700, X800
Samsung SDH-D720

# S60 2nd Edition (Symbian OS v7.0s)
Nokia 6600

# S60 1st Edition (Symbian OS v6.1)
Nokia 3600, 3620, 3650, 3660, 7650
Nokia N-Gage, N-Gage QD
Sendo X
Siemens SX1

See official list.

make a phone call

py_s60 1.1.3 provide a module to make call
import telephone
telephone.dial('017337330') # so easy

You can hang up by... guess it...
telephone.hang_up()

You can combine this with the contacts module to search and dial
import contacts, telephone
name = 'korakot'
cont = contacts.open().find(name)[0]
number = cont.find('mobile_number')[0].value
telephone.dial(number)
« Newer Snippets
Older Snippets »
Showing 1-8 of 8 total  RSS