Skip to content

Instantly share code, notes, and snippets.

View danigosa's full-sized avatar
🎯
24/7 Coding Whore

danius danigosa

🎯
24/7 Coding Whore
  • Robbie AI Inc.
  • Boston
View GitHub Profile
@danigosa
danigosa / sentry_error_handler.py
Created May 4, 2018 11:48
Sentry Logger Event Hook for Python API Star 0.5+ (tested on 0.5.10)
import sys
from os import environ
import logging
from apistar import http
from raven import Client
from apistar import App
from apistar.test import TestClient
from apistar import Route
settings = {
######################################
# INSTALL OPENCV ON UBUNTU OR DEBIAN #
######################################
# 1. KEEP UBUNTU OR DEBIAN UP TO DATE
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo apt-get -y autoremove
@danigosa
danigosa / simple-seo.rb
Created August 8, 2014 09:44
Recipe for Python 3.4 on Ubuntu 14.04
#
# Target OS Ubuntu Server 14.04 Trusty
# Chef 11.8.2
# Author: danigosa
# Date: 17/04/2014
#
#
include_recipe "provision::common"
@danigosa
danigosa / Vagrantfile
Last active May 28, 2020 12:27
Vagrant Configuration
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
  • create a new redis .conf file
$ cp /etc/redis.conf /etc/redis-xxx.conf
  • edit /etc/redis-xxx.conf, illustrated as below
...
@danigosa
danigosa / app-version-check.py
Created July 29, 2014 10:13
Py3K Version of pypi packages check
#!/usr/bin/env python
import xmlrpc.client as client
import pip
pypi = client.ServerProxy('http://pypi.python.org/pypi')
for dist in pip.get_installed_distributions():
available = pypi.package_releases(dist.project_name)
if not available:
# Try to capitalize pkg name
@danigosa
danigosa / gist:3fa853a69d28ffef5453
Created July 23, 2014 12:28
Supervise processes
#!/bin/bash
# Script to supervise processes
# Full supervisord config here: https://www.digitalocean.com/community/tutorials/how-to-install-and-manage-supervisor-on-ubuntu-and-debian-vps
while true
do
SERVICE="$1"
RESULT=`killall -q -0 $1 && echo running`
if [ "${RESULT:-null}" = null ]; then
echo "Not running!, Starting process..."
# Start targeted process here!
@danigosa
danigosa / pyodbc.py
Created April 27, 2013 19:14
Modified sql_server south backend to get South Migrations work with Azure SQL Backend
from datetime import date, datetime, time
from warnings import warn
from django.db import models
from django.db.models import fields
from south.db import generic
from south.db.generic import delete_column_constraints, invalidate_table_constraints, copy_column_constraints
from south.exceptions import ConstraintDropped
from south.utils.py3 import string_types
try:
from django.utils.encoding import smart_text # Django >= 1.5
@danigosa
danigosa / CeleryResource
Last active December 15, 2015 13:49 — forked from akoumjian/gist:1625633
Tastypie Resource as Celery Task
class TempResource(Resource):
class Meta:
resource_name = 'temp_resource'
object_class = temp_resource.delay
authorization = Authorization()
allowed_methods = ['post', 'get']
always_return_data = True
def get_resource_uri(self, bundle_or_obj):
"""
@danigosa
danigosa / mssql_fields.py
Last active December 15, 2015 11:29
MSSQL UUID Field compatible for the django-jsonfield app. It makes migrations from POstgres to MSSQL work :)
from uuidfield.fields import StringUUID
from django.utils.encoding import smart_unicode
__author__ = 'danigosa'
from uuidfield import UUIDField
class MssqlUUIDField(UUIDField):
"""
A field which stores a UUID value in hex format. This may also have