This file contains 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 | |
function json_encode_pretty($obj, $indentation = 0) | |
{ | |
switch (gettype($obj)) | |
{ | |
case 'object': | |
$obj = get_object_vars($obj); | |
case 'array': | |
if (!isset($obj[0])) |
This file contains 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
// Create index with mapping | |
curl -XPUT http://192.168.0.10:9200/geotest/ -d '{ | |
"settings" : { | |
"number_of_shards" : 1 | |
}, | |
"mappings" : { | |
"places" : { | |
"properties" : { | |
"name" : { "type" : "string" }, | |
"location" : { "type" : "geo_point", "lat_lon": true } |
This file contains 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
// Index config | |
{ | |
"number_of_shards": 5, | |
"number_of_replicas": 1, | |
"analysis": { | |
"analyzer": { | |
"log_analyzer": { | |
"type": "custom", | |
"tokenizer": "pattern", | |
"filter": [ |
This file contains 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 | |
namespace Acme\AcmeBundle\Dbal; | |
use Doctrine\DBAL\Types\Type; | |
use Doctrine\DBAL\Platforms\AbstractPlatform; | |
class TsvectorType extends Type | |
{ | |
public function getName() | |
{ |
This file contains 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) | |
{ |
This file contains 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 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 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 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 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 |
OlderNewer