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
| L = [1,2,3,4,5] | |
| D = {'a':1,'b':2,'c':3} | |
| i = iter(L) | |
| print i | |
| print D.iterkeys() | |
| print D.itervalues() | |
| print D.iteritems() | |
| for elt in i: | |
| print elt | |
| i.next() |
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
| mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); | |
| // In this sample, we'll use the same text for the ticker and the expanded notification | |
| CharSequence text = getText(R.string.local_service_started); | |
| // The PendingIntent to launch our activity if the user selects this notification | |
| PendingIntent contentIntent = PendingIntent.getActivity(this, 0, | |
| new Intent(this, TrackingActivity.class), 0); | |
| builder = new NotificationCompat.Builder(getBaseContext()) | |
| .setContentTitle("You are being tracked...") |
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
| AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
| builder.setMessage("Choose mode for tracking") | |
| .setCancelable(false) | |
| .setPositiveButton("Only GPS", new DialogInterface.OnClickListener() { | |
| public void onClick(DialogInterface dialog, int id) { | |
| LocationData.this.doPositiveClick(); | |
| } | |
| }) | |
| .setNegativeButton("All providers", new DialogInterface.OnClickListener() { | |
| public void onClick(DialogInterface dialog, int id) { |
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
| // register the receiver you created and | |
| // add a filter to only receive the intent you need | |
| LocalBroadcastManager.getInstance(this).registerReceiver( | |
| myReceiver, new IntentFilter("location")); | |
| // create your own receiver from BroadcastReceiver class | |
| private BroadcastReceiver myReceiver = new BroadcastReceiver() { | |
| @Override | |
| public void onReceive(Context context, Intent intent) { | |
| // get the info from the intent we received |
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
| >>> datetime.now() | |
| datetime.datetime(2012, 7, 7, 16, 31, 24, 604514) | |
| >>> datetime.today() | |
| datetime.datetime(2012, 7, 7, 16, 31, 27, 340110) | |
| >>> datetime.utcnow() | |
| datetime.datetime(2012, 7, 7, 20, 31, 58, 227201) | |
| >>> d = datetime.strptime("2012-07-07 16:00", "%Y-%m-%d %H:%M") | |
| >>> d | |
| datetime.datetime(2012, 7, 7, 16, 0) | |
| >>> datetime.utcnow().timetuple() |
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
| CREATE TABLE cities ( | |
| city varchar(80) primary key, | |
| location point | |
| ); | |
| CREATE TABLE weather ( | |
| city varchar(80) references cities(city), | |
| temp_lo int, | |
| temp_hi int, | |
| prcp real, |
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
| {% extends "base.html" %} | |
| {% load url from future %} | |
| {% block content %} | |
| {% if form.errors %} | |
| <p>Your username and password didn't match. Please try again.</p> | |
| {% endif %} | |
| <form method="post" action="{% url 'django.contrib.auth.views.login' %}"> |
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
| from math import sqrt, floor | |
| def euler12(): | |
| D = 0 | |
| n = 1 | |
| step = 2 | |
| while D < 500: | |
| n += step | |
| step += 1 | |
| D = findDivisor(n) |
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
| class List(models.Model): | |
| name = models.CharField(max_length=200, unique=True) | |
| start_date = models.DateTimeField(verbose_name='date started', | |
| default=datetime.now()) | |
| slug = models.SlugField(max_length=200, unique=True) | |
| progress = models.FloatField(default=0.0, | |
| validators=[MaxValueValidator(100.0), | |
| MinValueValidator(0.0)]) | |
| def __unicode__(self): |
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
| Windows/system32/drivers/etc/host | |
| /private/etc/hosts |