Skip to content

Instantly share code, notes, and snippets.

View mohamadiank's full-sized avatar
🎯

MohamadHossein Mohamadian mohamadiank

🎯
View GitHub Profile
def reservation_f(request, year, month, day):
ReservationFormset = modelformset_factory(
Reservation,
extra = 1,
fields = ('order_count', 'order_name', 'order_date'),
form = Reserve,
)
if request.method == "POST":
formset = ReservationFormset(request.POST, queryset=Food.objects.none(),
form_kwargs={'month': month, 'year': year, 'day':day})
@mohamadiank
mohamadiank / django-bootstrap-paginator.html
Created July 12, 2017 12:43 — forked from BenAtWide/django-bootstrap-paginator.html
Simple Bootstrap-styled pagination for Django class-based list view
{% if is_paginated %}
<div class="pagination">
<ul>
{% if page_obj.has_previous %}
<li><a href="?page={{ page_obj.previous_page_number }}">
{% else %}
<li class="disabled"><a href="#">
{% endif %}
Prev</a></li>
{% for p in page_obj.paginator.page_range %}
#!/bin/sh
curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar xzvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin"
make
make install
git clone --depth 1 http://git.videolan.org/git/x264
cd x264
#!/bin/sh
sudo apt update
sudo apt -y install \
autoconf \
automake \
build-essential \
cmake \
git \
libass-dev \
@mohamadiank
mohamadiank / include_post_meta_in_admin_search.php
Created January 13, 2019 10:12
Search WordPress by Custom Fields
<?php
/**
* Include posts meta in admin search
*/
add_filter( 'posts_distinct', 'cf_search_distinct' );
add_filter('posts_join', 'cf_search_join' );
add_filter( 'posts_where', 'cf_search_where' );
function cf_search_join( $join ) {
global $wpdb;
@mohamadiank
mohamadiank / scrapy_bash.sh
Created February 20, 2019 15:51
run scrapy spider in loop
for i in 5196 6020; do scrapy crawl spider_name -a id=$i -a do_action=yes; done
# or
for i in {100..200}; do scrapy crawl spider_name -a id=$i -a do_action=yes; done
@mohamadiank
mohamadiank / update.sh
Created March 30, 2019 12:21
update all packages by python pip
pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
@mohamadiank
mohamadiank / celeryd.sh
Created April 24, 2019 08:04
Celery Daemon worker Queues
# Advanced example starting 10 workers in the background:
# * Three of the workers processes the images and video queue
# * Two of the workers processes the data queue with loglevel DEBUG
# * the rest processes the default' queue.
$ celery multi start 10 -l INFO -Q:1-3 images,video -Q:4,5 data -Q default -L:4,5 DEBUG
$ CELERYD_OPTS="--time-limit=300 --concurrency=8 -l INFO -Q:1-3 images,video -Q:4,5 data -Q default -L:4,5 DEBUG"