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', '[email protected]'),
)
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 / celery_tasks_error_handling.py
Last active December 20, 2024 02:44
Celery tasks error handling example
from celery import Task
from celery.task import task
from my_app.models import FailedTask
from django.db import models
@task(base=LogErrorsTask)
def some task():
return result
class LogErrorsTask(Task):
@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 );
Facebook*:
https://api.facebook.com/method/links.getStats?urls=%%URL%%&format=json
+ works, returns shares, likes, comments and total
Twitter:
http://urls.api.twitter.com/1/urls/count.json?url=%%URL%%&callback=twttr.receiveCount
+ v1 API but still works
Reddit:
http://buttons.reddit.com/button_info.json?url=%%URL%%
import Vue from 'vue'
// Event proxy/bus for sharing data across non-parent child components
// https://vuejs.org/v2/guide/components.html#Non-Parent-Child-Communication
const event = {
bus: null,
init() {
if (!this.bus) {