Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Working as senior backend python develper, and accepting requests

Daniel G. gonvaled

💭
Working as senior backend python develper, and accepting requests
View GitHub Profile
@gonvaled
gonvaled / gist:1688268
Created Jan 27, 2012
Setup an Elastic Search index which will index only one field: "note_text"
View gist:1688268
server="localhost"
printf "\n\nCreate the index\n"
curl -XPUT "$server:9200/index1"
printf "\n\nCreate the mapping\n"
curl -XPUT "$server:9200/index1/mapping1/_mapping" -d '{
"type1" : {
"dynamic" : false,
"properties" : {
@gonvaled
gonvaled / gist:2429165
Created Apr 20, 2012
Setup elasticsearch index with two couchdb rivers
View gist:2429165
#!/bin/bash
server="localhost:9200"
index="my_index"
river1="first_river"
host1="localhost"
port1="5984"
db1="firstdb"
type1="firsttype"
@gonvaled
gonvaled / get_closure.py
Created Oct 5, 2013
Wrapper around Closure Compiler API
View get_closure.py
import httplib
import sys
import urllib
from contextlib import closing
################################################################################################################
# Compilation level
WHITESPACE_ONLY_CL = 'WHITESPACE_ONLY'
SIMPLE_OPTIMIZATIONS_CL = 'SIMPLE_OPTIMIZATIONS'
View data.json
{"nodes":[
{"x":80, "r":40, "label":"Node 1"},
{"x":200, "r":60, "label":"Node 2"},
{"x":380, "r":80, "label":"Node 3"}
]}
@gonvaled
gonvaled / forms.py
Last active Jun 26, 2021
Django widget to replace the file selection standard button by an image preview. Tested with Django 1.8.5
View forms.py
from django.forms import ModelForm, FileField
from .models import Campaign
from .widgets import ImagePreviewWidget
class DesignCampaignForm(ModelForm):
brand_logo = FileField(widget=ImagePreviewWidget)
View pyproject.toml
[tool.poetry]
name = "poetry-demo"
version = "0.1.0"
description = ""
authors = ["gonvaled"]
[tool.poetry.dependencies]
python = "^3.6"
dj-database-url = "^0.5.0"
Django = "^2.0.7"