Skip to content

Instantly share code, notes, and snippets.

@tazjel
tazjel / w2p-bb-install.sh
Created June 23, 2017 14:45 — forked from manuelep/w2p-bb-install.sh
get a brand new minimalist version of web2py
#!/bin/bash
git clone --recursive https://github.com/web2py/web2py.git web2py_temp
cd web2py_temp
git checkout tags/R-2.11.2
git submodule update --init --recursive
python scripts/make_min_web2py.py ../web2py
mv applications/admin ../web2py/applications/
cd ../
rm -rf web2py_temp
Add a new user to the www-data group
In this example, add a new user called vivek to the www-data group, enter:
sudo useradd -g www-data vivek
### set the password for vivek user ###
sudo passwd vivek

#Understanding MVC And MVP (For JavaScript & Backbone Developers)

Before exploring any JavaScript frameworks that assist in structuring applications, it can be useful to gain a basic understanding of architectural design patterns. Design patterns are proven solutions to common development problems and can suggest structural paradigms to help guide us in adding some organization to our application.

I think patterns are exciting as they're effectively a grass roots effort that build upon the collective experience of skilled developers who have previously faced similar problems as we do now. Although developers 10 or 20 years ago may not have been using the same programming languages for implementing patterns, there are many lessons we can learn from their efforts.

In this section, we're going to review two popular patterns - MVC and MVP. The context of our exploration will be how these patterns are related to the popular JavaScript framework Backbone.js, which will be explored in greater detail later on.

@tazjel
tazjel / gist:6958b2072b241dd189676a4b5a4c647c
Created December 9, 2016 11:53 — forked from liamcurry/gist:2597326
Vanilla JS vs jQuery

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})

Moving from jQuery to Vanilla

Events

// jQuery
$(document).ready(function() {
  // code
})

// Vanilla
@tazjel
tazjel / linkinput.py
Created August 1, 2016 13:54 — forked from MaxMorais/linkinput.py
Web2Py Link Widget [UNDER DEVELOPMENT] This widget adds 3 new features to AutoCompleteWidget` ```      - Search: Allows the user to easily locate a record.      - Preview: Allows the user to view the records referenced.      - Add: Allows the user to add and self-references a record. ```
#-*- coding: utf-8 -*-
from gluon.sqlhtml import AutoCompleteWidget
from gluon.contrib.simplejson import loads
class LinkWidget(AutoCompleteWidget):
AGGREGATION = 'agg'
CONDITION = 'condition'
FIELD = 'fieldname'
QUERY = 'query'
@tazjel
tazjel / screenrecord.sh
Created August 1, 2016 13:44 — forked from PaulKinlan/getdeviceart.sh
Screen Record for Android
if [ -z "$1" ]; then
shot_path=$(date +%Y-%m-%d-%H-%M-%S).mp4
else
shot_path="$*"
fi
ffmpeg="ffmpeg"
n6_frame="n6-background.png"
trap ctrl_c INT
@tazjel
tazjel / gist:6b3d96f871150d458cc9f6b0924fba2c
Created June 5, 2016 12:47 — forked from mdeous/gist:823821
example: parsing html with lxml and xpath
import lxml.html
html = lxml.html.parse("http://pypi.python.org/pypi") # can take an url, a filename or an object with a .read() method
packages = html.xpath('//tr/td/a/text()') # get the text inside all "<tr><td><a ...>text</a></td></tr>"
print packages
Out[7]:
[u'celery\xa02.2.3',
u'django-celery\xa02.2.3',
u'kombu\xa01.0.3',
@tazjel
tazjel / autocomplete.vim
Created April 27, 2016 13:56 — forked from lencioni/autocomplete.vim
UltiSnips and YouCompleteMe configuration
" YouCompleteMe and UltiSnips compatibility, with the helper of supertab
" (via http://stackoverflow.com/a/22253548/1626737)
let g:SuperTabDefaultCompletionType = '<C-n>'
let g:SuperTabCrMapping = 0
let g:UltiSnipsExpandTrigger = '<tab>'
let g:UltiSnipsJumpForwardTrigger = '<tab>'
let g:UltiSnipsJumpBackwardTrigger = '<s-tab>'
let g:ycm_key_list_select_completion = ['<C-j>', '<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-k>', '<C-p>', '<Up>']
# install dependencies
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y cmake
sudo apt-get install -y libgtk2.0-dev
sudo apt-get install -y pkg-config
sudo apt-get install -y python-numpy python-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y libjpeg-dev libpng-dev libtiff-dev libjasper-dev