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
| """ | |
| Some table has two Date fields: expiredate and SALexpiredate | |
| Both fields can be null | |
| when SALexpiredate is not null, overrides expiredate | |
| when ordering: | |
| if SALexpiredate is not null, that field needs to be used | |
| otherwise fallback to use expiredate | |
| """ | |
| from django.db.models import DateField, Case, When, F |
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
| ''' | |
| given a Model with: | |
| category = models.CharField(max_length=32, choices=CATEGORY_CHOICES) | |
| pubdate = models.DateTimeField(default=datetime.now) | |
| <other fields> | |
| Fetch the item from each category with the latest pubdate. | |
| ''' |
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
| import pickle | |
| # Session key | |
| key = 'my_qs' | |
| # Pizza => model example | |
| qs = Pizza.objects.filter(ingredient='tomato') | |
| # Dumping data | |
| request.session[key] = pickle.dumps(qs.query) |
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
| import usb.core | |
| import usb.util | |
| def get_qr_value(lst): | |
| assert len(lst) == 8, 'Invalid data length (needs 8 bytes)' | |
| conv_table = { | |
| 0:['', ''], | |
| 4:['a', 'A'], | |
| 5:['b', 'B'], |
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
| def DjangoModel(models.Model): | |
| @classmethod | |
| def from_db(cls, db, field_names, values): | |
| instance = super().from_db(db, field_names, values) | |
| instance._state.adding = False | |
| instance._state.db = db | |
| instance._old_values = dict(zip(field_names, values)) | |
| return instance |
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
| /* | |
| Created on: 17 Sep, 2014, 4:29:37 PM | |
| Author: senthil | |
| */ | |
| .ti_tx, | |
| .mi_tx, | |
| .mer_tx { | |
| width: 100%; |
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
| /* | |
| * Author: @senthil2rajan | |
| * plugin: timepicker | |
| * website: senthilraj.github.io/Timepicki | |
| */ | |
| (function($) { | |
| $.fn.timepicki = function(options) { | |
| var defaults = { |

