I hereby claim:
- I am balavec on github.
- I am balavec (https://keybase.io/balavec) on keybase.
- I have a public key ASBiLhA9bbf-ah1CQFPxtgw5ipIODHN0AjhgV20VEH1I1go
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| #After looking for a way to check if a model instance can be deleted in django , | |
| #i came across many sample, but was not working as expected. Hope this solution can help. | |
| #Let start by creating an Abstract model class which can be inherited by other model | |
| class ModelIsDeletable(models.Model): | |
| name = models.CharField(max_length=200, blank=True, null=True, unique=True) | |
| description = models.CharField(max_length=200, blank=True, null=True) | |
| date_modified = models.DateTimeField(auto_now_add=True) | |
| git fetch --all -p; git branch -vv | grep ": gone]" | awk '{ print $1 }' | xargs -n 1 git branch -D |
| // Returns the value at a given percentile in a sorted numeric array. | |
| // "Linear interpolation between closest ranks" method | |
| function percentile(arr, p) { | |
| if (arr.length === 0) return 0; | |
| if (typeof p !== 'number') throw new TypeError('p must be a number'); | |
| if (p <= 0) return arr[0]; | |
| if (p >= 1) return arr[arr.length - 1]; | |
| var index = arr.length * p, | |
| lower = Math.floor(index), |
| <?php | |
| if (!function_exists('dd')) { | |
| function dd($data) | |
| { | |
| ini_set("highlight.comment", "#969896; font-style: italic"); | |
| ini_set("highlight.default", "#FFFFFF"); | |
| ini_set("highlight.html", "#D16568"); | |
| ini_set("highlight.keyword", "#7FA3BC; font-weight: bold"); | |
| ini_set("highlight.string", "#F2C47E"); |
| # List unique values in a DataFrame column | |
| pd.unique(df.column_name.ravel()) | |
| # Convert Series datatype to numeric, getting rid of any non-numeric values | |
| df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True) | |
| # Grab DataFrame rows where column has certain values | |
| valuelist = ['value1', 'value2', 'value3'] | |
| df = df[df.column.isin(valuelist)] |
| # -*- coding: utf-8 -*- | |
| import Image | |
| def resize_and_crop(img_path, modified_path, size, crop_type='top'): | |
| """ | |
| Resize and crop an image to fit the specified size. | |
| args: | |
| img_path: path for the image to resize. |