Skip to content

Instantly share code, notes, and snippets.

@creativepsyco
creativepsyco / update.sh
Created November 10, 2012 07:47
[Bash Script Rails] Run migrations if necessary
#!/bin/bash
set -x
ENV=${3:-development}
git pull origin master
git merge master | grep 'Already up-to-date'
#git pull $1 $2
#git merge $1/$2 | grep 'Already up-to-date'
CHANGES=$?
def unzip_file (file, destination)
Zip::ZipFile.open(file) { |zip_file|
zip_file.each { |f|
f_path=File.join(destination, f.name)
FileUtils.mkdir_p(File.dirname(f_path))
if File.exist?(f_path)
FileUtils.rm_rf(f_path)
end
zip_file.extract(f, f_path) unless File.exist?(f_path)
@creativepsyco
creativepsyco / client_server.c
Created November 14, 2012 12:20
Parallel Programming: Client-Server via TAGS
#include "mpi.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define TAG_SEND_CHAR 1
#define TAG_SEND_NUM 2
#define TAG_ASK_CHAR 3
@creativepsyco
creativepsyco / upload.cpp
Created December 1, 2012 18:03
File Upload in CPP
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
int main(int argc, char *argv[])
{
struct curl_httppost *post = NULL;
struct curl_httppost *last = NULL;
CURLcode res;
@creativepsyco
creativepsyco / index.html
Created December 2, 2012 07:59 — forked from mbostock/.block
World Countries
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.country {
fill: #b8b8b8;
stroke: #fff;
stroke-width: .5px;
stroke-linejoin: round;
}
@creativepsyco
creativepsyco / gist:4189215
Created December 2, 2012 15:00 — forked from olistik/gist:2627011
Ubuntu 12.10 setup (rbenv/rvm, janus, postgres)

Basic pre-requisites

  • Some utilities:
sudo apt-get install vim tmux git
  • Copy/paste from the command line:
sudo apt-get install xclip
@creativepsyco
creativepsyco / upload.cpp
Created December 3, 2012 18:04
Upload File + Callback
#include <stdio.h>
#include <iostream>
#include <string>
#include <curl/curl.h>
using namespace std;
static string data;
size_t writeCallback(char *buf, size_t size, size_t nmemb, void *up)
{
@creativepsyco
creativepsyco / .travis.yml
Created February 2, 2013 09:34
Travis Config for Django Projects
language: python
python:
# - "2.6"
- "2.7"
services: mysql
env:
# - DJANGO=1.2.7
# - DJANGO=1.3.1
- DJANGO=1.4.3 DJANGO_SETTINGS_MODULE="mysite.travis_settings"
install:
@creativepsyco
creativepsyco / forms.py
Created February 2, 2013 12:17
Dynamic forms in Django
class ServiceStartForm(forms.Form):
serviceList = service.models.Service.objects.all()
print serviceList.count()
b = {}
for aService in serviceList:
b[aService.id] = aService.name
c = b.items()
print "Within the form, ", serviceList.count()
serviceChoice = forms.ChoiceField(choices=c, widget=forms.Select())
input_directory = forms.CharField(max_length=200)
@creativepsyco
creativepsyco / settings.py
Created February 8, 2013 01:50
Making local Template Dir in Django
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.realpath(os.path.dirname(__file__))+'/templates/',
# Sample Template
)