Skip to content

Instantly share code, notes, and snippets.

View darklow's full-sized avatar

Kaspars Sprogis darklow

View GitHub Profile
@darklow
darklow / settings.py
Created March 3, 2014 11:06
DjangoSuit.com whole project settings.py - https://github.com/darklow/django-suit-examples
import os
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__) + '/../')
ENV_ROOT = os.path.abspath(PROJECT_ROOT + '/../')
ADMINS = (
('XX', 'XXX@XXX.com'),
)
MANAGERS = ADMINS
ROOT_DIR="$1"
mkdir "$ROOT_DIR"
cd "$ROOT_DIR"
#setup venv
virtualenv env --distribute
source env/bin/activate
#install django so we can start up an app
@darklow
darklow / custom_view.html
Created October 8, 2014 14:15
Custom view template for Django
<!-- templates/admin/custom_view.html -->
{% extends "admin/base_site.html" %}
{% load i18n %}
{% block breadcrumbs %}
<ul class="breadcrumb">
<li class="active">
<i class="icon-home"></i>
{% trans "Custom view" %}
var selector = 'img' // Replace this with the selector for the element you want to make transformable
jQuery.getScript('//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js', function() {
jQuery.getScript('//cdnjs.cloudflare.com/ajax/libs/numeric/1.2.6/numeric.min.js', function() {
(function() {
var $, applyTransform, getTransform, makeTransformable;
$ = jQuery;
@darklow
darklow / SSDP Code
Last active August 29, 2015 14:12 — forked from anonymous/SSDP Code
SYSTEM_MODE(MANUAL);
//Disables connection to Spark Cloud without additional API query
// UDP Port used for two way communication
unsigned int localPort = 8888;
const char *message = "A";
unsigned int once = 0;
unsigned int ssdpport = 1900;
IPAddress ip( 239, 255, 255, 250 );
SYSTEM_MODE(MANUAL);
// UDP Port used for two way communication
unsigned int localPort = 1900;
unsigned int trigger = D0;
//Creates buffer variable and gives it a size
#define MAX_SIZE 1024
char buffer[MAX_SIZE];
//Creates UDP manipulation variable
SYSTEM_MODE(MANUAL);
//Disables connection to Spark Cloud without additional API query
// UDP Port used for two way communication
unsigned int localPort = 8888;
const char *message = "A";
unsigned int ssdpport = 1900;
IPAddress ip( 239, 255, 255, 250 );
@darklow
darklow / json_encode_pretty.php
Created April 18, 2012 13:53
JSON Encode pretty
<?php
function json_encode_pretty($obj, $indentation = 0)
{
switch (gettype($obj))
{
case 'object':
$obj = get_object_vars($obj);
case 'array':
if (!isset($obj[0]))
@darklow
darklow / gist:2483009
Created April 24, 2012 19:37
Elasticsearch geo search debug
// 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 }
@darklow
darklow / gist:2757570
Created May 20, 2012 10:16
Elasticsearch log mapping
// Index config
{
"number_of_shards": 5,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"log_analyzer": {
"type": "custom",
"tokenizer": "pattern",
"filter": [