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 random import randrange | |
| from datetime import timedelta | |
| from datetime import datetime | |
| import pytz | |
| def random_date(start, end): | |
| """ | |
| This function will return a random datetime between two datetime | |
| objects. | |
| """ |
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
| mkdir ~/.npm-global | |
| npm config set prefix '~/.npm-global' | |
| export PATH=~/.npm-global/bin:$PATH | |
| source ~/.profile | |
| NPM_CONFIG_PREFIX=~/.npm-global | |
| echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p | |
| fs.inotify.max_user_watches=524288 | |
| sysctl --system |
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
| # Hack to cache SELECT statements inside a single Django request. The patch() method replaces | |
| # the Django internal execute_sql method with a stand-in called execute_sql_cache. That method | |
| # looks at the sql to be run, and if it's a select statement, it checks a thread-local cache first. | |
| # Only if it's not found in the cache does it proceed to execute the SQL. On any other type of | |
| # sql statement, it blows away the cache. There is some logic to not cache large result sets, | |
| # meaning anything over 100 records. This is to preserve Django's lazy query set evaluation. | |
| from threading import local |
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
| my_applicants = Model.object.all() | |
| context['next'] = next_in_order(obj, qs=my_applicants) | |
| context['prev'] = prev_in_order(obj, qs=my_applicants, loop=True) |
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 add_q_object(self, keyword, q_object, query_parm): | |
| for key in keyword: | |
| kwargs = {query_parm: key.strip()} | |
| q_object.add(Q(**kwargs), q_object.OR) | |
| def filter_applicants(self, _queryset=None): | |
| my_applicants = _queryset |
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
| <div class="card"> | |
| <div class="card-header"> | |
| <span style="display:block"> | |
| <span data-target="#job-{{ job.ref_number }}" data-toggle="collapse" | |
| class="text-muted pull-right el-collpse" style="cursor: pointer" aria-expanded="false"> | |
| <i class="fa fa-angle-right js-rotate-if-collapsed"></i> | |
| </span> | |
| </span> | |
| <span style="display:block"> | |
| {{ job.title }} |
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 time | |
| from datetime import datetime , timedelta | |
| from dateutil.rrule import rrule, MONTHLY, DAILY | |
| date_start_obj = datetime(2018,05,18) | |
| date_end_obj = datetime(2018,05,30) | |
| # holidays = [datetime(2018,05,21).date(), datetime(2018,05,28).date(), datetime(2018,05,20).date()] | |
| def get_working_days(date_start_obj, date_end_obj, holidays=[]): | |
| many_holidays = 0 |
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 "https://fonts.googleapis.com/css?family=Dosis:300,400,500,600,700"; | |
| #timeline .timeline-item:after, #timeline .timeline-item:before { | |
| content: ''; | |
| display: block; | |
| width: 100%; | |
| clear: both; | |
| } | |
| *, *:before, *:after { | |
| box-sizing: border-box; | |
| -webkit-box-sizing: border-box; |
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
| // Bootstrap datepicker | |
| $('.input-daterange input').each(function() { | |
| $(this).datepicker('clearDates'); | |
| }); | |
| // Set up your table | |
| table = $('#my-table').DataTable({ | |
| paging: false, | |
| info: false | |
| }); |
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 django.contrib.auth import REDIRECT_FIELD_NAME | |
| from django.contrib.auth.decorators import user_passes_test | |
| from account.models import Profile | |
| def client_user_denied(function=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url='account:login'): | |
| actual_decorator = user_passes_test( | |
| lambda u: u.is_active and u.profile.type > 0, | |
| login_url=login_url, redirect_field_name=redirect_field_name | |
| ) |