Skip to content

Instantly share code, notes, and snippets.

@serkanh
serkanh / csvimporter.py
Created September 16, 2012 15:08
Simple CSV importer
from django.core.management import setup_environ
import settings, csv
setup_environ(settings)
from companies.models import Lead
file = csv.reader(open('florida.csv', 'rU'), delimiter = ',', quotechar='|')
for row in file:
#Name the Django field with corresponding row in your csv.
lead = Lead(cname=row[0], crep=row[1], cnumber=row[2], cemail=row[3], caddress=row[4], ccity=row[5],czip=row[6],submissiondate=row[7], businesstype = row[8], comment = row[9])
lead.save()
@serkanh
serkanh / geojson_serializer.py
Created November 20, 2012 21:07 — forked from danielsokolowski/geojson_serializer.py
GeoJSON Serializer for GeoDjango (gis)
'''
Created on 2011-05-12
@author: Daniel Sokolowski
Extends django's built in JSON serializer to support GEOJSON encoding
Requirements:
Install and setup geodjango (django.contrib.gis)
@serkanh
serkanh / geojson_serializer.py
Created November 20, 2012 21:18 — forked from glenrobertson/geojson_serializer.py
GeoJSON serializer for Geodjango
"""
Modified from: https://gist.github.com/967274
CHANGES:
* Serialize pk in feature.id and remove from feature.properties
* Added default date format and time format for encoder
* Allow geometryfield option, which doesn't have to be a field, e.g. a @property
USAGE:
#!/bin/bash
#
# Install Postgres 9.1, PostGIS and create PostGIS template on a clean Ubuntu 11.10 Oneiric Ocelot box
# http://wildfish.com
# add the ubuntu gis ppa
sudo apt-get -y install python-software-properties
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
@serkanh
serkanh / gist:2c5fbb53c47c703add14
Created November 4, 2014 21:09
Manually run chef on Opsworks instance
echo cookbook_path ["/opt/aws/opsworks/current/site-cookbooks"] > solo.rb
opsworks-agent-cli get_json > attributes.json
sudo /opt/aws/opsworks/current/bin/chef-solo -c solo.rb -j ~ubuntu/attributes.json -o recipe[map-proxy::config]
FROM ubuntu:12.10
MAINTAINER Ken Cochrane "kencochrane@gmail.com"
RUN apt-get -qq update
RUN apt-get install -y python-dev python-setuptools supervisor git-core
RUN easy_install pip
RUN pip install virtualenv
RUN pip install uwsgi
RUN virtualenv --no-site-packages /opt/ve/djdocker
ADD . /opt/apps/djdocker
ADD .docker/supervisor.conf /opt/supervisor.conf
@serkanh
serkanh / gist:1bc420e2ac585c8cd162
Created June 8, 2015 15:40
jira-https-nginx-wildcard-cert-configuration
# mkdir -p /etc/nginx/ssl
# sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt
# redirect HTTP to HTTPS - /etc/nginx/sites-available/default
server {
listen 80;
server_name jira.example.com;
access_log off;
@serkanh
serkanh / gist:54fe57a7a826da6105b4
Created June 8, 2015 16:02
jira-stash-nginx-https
index index.html index.htm;
server {
root /usr/share/nginx/html;
listen 443;
server_name git.example.com;
access_log off;
# serkan haytac
#!/usr/bin/python
import boto.opsworks.layer1 as opsworks
##########################################################################################
# Simple class to manage opsworks provisioning #
# It can be useful to integrate CI servers and issue #
# lifecycle events such as deployment through aws boto library #
# Make sure to add your access credentials in .boto file in #
# home directory. #
# http://boto.readthedocs.org/en/latest/getting_started.html#configuring-boto-credentials#
@serkanh
serkanh / gist:f8a4b2e95f518a01a1f2
Last active August 29, 2015 14:25
vim-go vimrc setup
" serkan haytac
call pathogen#infect()
call pathogen#helptags()
syntax on
set background=light
filetype plugin indent on
set number
set nowrap
set hlsearch
let g:go_disable_autoinstall = 0