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 fabric.api import lcd, local, path | |
project_dir = '/www/project/sms/' | |
env_bin_dir = project_dir + '../env/bin' | |
def deploy(): | |
with lcd(project_dir): | |
local('pwd') | |
local('git pull origin') |
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
// in older versions, for getting model from different controller i was using: | |
App.FoodController = Em.ArrayController.extend({ | |
addFood: function (food) { | |
var items = this.controllerFor('table').get('model').get('tab.tabItems'); | |
tabItems.createRecord({ | |
food: food | |
}) | |
} | |
}); |
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
#!/bin/bash | |
# ======================================== | |
# Testing completion suggest in ElasticSearch | |
# ======================================== | |
curl -X DELETE localhost:9200/hotels | |
curl -X PUT localhost:9200/hotels -d ' | |
{ | |
"mappings": { | |
"hotel" : { |
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
// mapping | |
{ | |
"credits": { | |
"properties": { | |
"position": { | |
"type": "integer" | |
}, | |
"person": { | |
"properties": { | |
"id": { |
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
# urls.py | |
urlpatterns = patterns('', | |
# ... | |
# Example for custom view | |
url(r'^admin/custom/$', views.custom_view), | |
# ... | |
# Admin |
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
# urls.py | |
url(r'^admin/dashboard/', staff_member_required(DashboardListView.as_view()), name='dashboard'), | |
# views.py | |
class DashboardListView(ListView): | |
context_object_name = 'task_list' | |
template_name = 'admin/dashboard.html' | |
def get_queryset(self): |
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
# urls.py | |
urlpatterns = patterns('', | |
# Example for custom menu | |
url(r'^admin/custom/$', views.custom_view), | |
# Uncomment the next line to enable the admin: | |
url(r'^admin/', include(admin.site.urls)), |
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
class ReadOnlyWidget(forms.TextInput): | |
def render(self, name, value, attrs=None): | |
if value is None: | |
value = '' | |
final_attrs = self.build_attrs(attrs, type=self.input_type, name=name) | |
if value != '': | |
# Only add the 'value' attribute if a value is non-empty. | |
final_attrs['value'] = force_unicode(self._format_value(value)) | |
return mark_safe(u'<span%s />%s</span>' % (flatatt(final_attrs), value)) |
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
# auto source virtual envs if it can find one | |
has_virtualenv() { | |
path="../env/bin/activate" | |
if [ -e $path ]; then | |
path=$(readlink -f $path) | |
if [ -z "$CURRENT_VENV_PATH" -o -z "$_OLD_VIRTUAL_PATH" -o "$CURRENT_VENV_PATH" != "$path" ] ; then | |
source $path | |
export CURRENT_VENV_PATH="$path" | |
echo -e "\e[01;30mvirtualenv $path activated\e[00m" | |
fi |
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
<?php | |
class GearmanClient extends \GearmanClient | |
{ | |
const PRIORITY_LOW = 'low'; | |
const PRIORITY_HIGH = 'high'; | |
const PRIORITY_NORMAL = 'normal'; | |
public function getUniqueId($function_name, $workload, $priority = null) | |
{ |