Skip to content

Instantly share code, notes, and snippets.

@wwgist
wwgist / jq_deferreds.js
Created June 18, 2013 09:18
JQUERY: ajax.deferred
$.customMethod = function(){
return $.ajax({
url: '/targetUrl/',
// data: {param1: 'value1'},
dataType: 'jsonp',
}).promise();
};
var outer = $.customMethod();
@wwgist
wwgist / switch.js
Created June 18, 2013 06:36
JS: switch
switch(n)
{
case 1:
execute code block 1
break;
case 2:
execute code block 2
break;
default:
code to be executed if n is different from case 1 and 2
@wwgist
wwgist / jquery_custom_selector.js
Created June 11, 2013 16:45
JQUERY: custom selector example
$.extend($.expr[':'], {
over100pixels: function(a) {
return $(a).height() > 100;
}
});
$('.box:over100pixels').click(function() {
alert('Элемент, который вы потревожили своим кликом, в высоту более 100 пикселов');
});
@wwgist
wwgist / project.sublime-project
Created April 16, 2013 12:27
SUBLIME: sublime-project(settings)
{
"folders":
[
{
"path": "/home/wowkalucky/dev/asnportal_project/_asnportal/",
"folder_exclude_patterns": ["venv","run"]
}
]
}
@wwgist
wwgist / .gitignore
Created April 12, 2013 14:51
GIT: .gitignore
*.py~
*.py[cod]
local_settings.py
*.db
*sublime*
wsgi.py
@wwgist
wwgist / SMTP_DebuggingServer.py
Created March 27, 2013 08:31
TOOLS: run SMTP DebuggingServer (email)
DebuggingServer
@wwgist
wwgist / formsForm_snippet.py
Created March 27, 2013 08:14
DJANGO: forms.Form snippet
# forms.py ====================================================================
from django import forms
class NAMEForm(forms.Form):
FIELDNAME1 = forms.CharField(required=True,)
FIELDNAME2 = forms.CharField(
widget=forms.Textarea(attrs={'class': 'input-second'}),)
# views.py ====================================================================
from project.apps.APPNAME.forms import NAMEForm
from django.http import HttpResponseRedirect
@wwgist
wwgist / multiwidget_double_textinput.py
Created March 26, 2013 17:27
DJANGO: multiwidget - doubleTextInput
class SplitTextMultiWidget(forms.MultiWidget):
def __init__(self, attrs=None):
_widgets = (
forms.TextInput(attrs={'class': 'input-second'}),
forms.TextInput(attrs={'class': 'input-second'}),
)
super(SplitTextMultiWidget, self).__init__(_widgets, attrs)
def decompress(self, values):
#!/usr/bin/env bash
# file: ~/.virtualenvs/postmkvirtualenv
# This hook is run after a new virtualenv is activated.
# setup python interpretor and sitepackages
# for Sublime Text's SublimeCodeIntel plugin.
# codeintel looks in the root of any folder opened via `subl foldername`
# for foldername/.codeintel/config
# it also looks in ~/.codeintel/config
@wwgist
wwgist / recursive.py
Created March 13, 2013 13:02
PYTHON: recursive pattern
def reverseString(aStr):
# base case:
if len(aStr) == 0:
return ''
# recursive case:
else:
return aStr[-1:] + reverseString(aStr[:-1])