Skip to content

Instantly share code, notes, and snippets.

View ads901119's full-sized avatar

Alan Sha ads901119

View GitHub Profile
@pedroburon
pedroburon / form_bootstrap.html
Created January 24, 2012 14:59
bootstrap compatible template for forms in django
{% load i18n %}
<form method="post"
{% if action_url %}action="{{ action_url }}"{%endif %}
{% if form.is_multipart %}enctype="multipart/form-data"{% endif %}>
{% csrf_token %}
<fieldset>
{% if form_legend %}
<legend>{% trans form_legend noop %}</legend>
{% endif %}{# form_legend #}
var application_root = __dirname,
express = require("express"),
path = require("path"),
mongoose = require('mongoose');
var app = express.createServer();
// database
mongoose.connect('mongodb://localhost/ecomm_database');
@agramfort
agramfort / ranking.py
Created March 18, 2012 13:10 — forked from fabianp/ranking.py
Pairwise ranking using scikit-learn LinearSVC
"""
Implementation of pairwise ranking using scikit-learn LinearSVC
Reference: "Large Margin Rank Boundaries for Ordinal Regression", R. Herbrich,
T. Graepel, K. Obermayer.
Authors: Fabian Pedregosa <[email protected]>
Alexandre Gramfort <[email protected]>
"""
@aheckmann
aheckmann / storeImgInMongoWithMongoose.js
Created April 17, 2012 19:14
store/display an image in mongodb using mongoose/express
/**
* Module dependencies
*/
var express = require('express');
var fs = require('fs');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// img path
@berinhard
berinhard / django-social-auth-basic.py
Created May 8, 2012 02:46
django-social-auth-plus
########################################
########## MEU_PIPELINE.PY #############
########################################
def populate_user_profile(*args, **kwargs):
response = kwargs['response']
user = kwargs['user']
month, day, year = [int(x) for x in response['birthday'].split('/')]
kwargs = {
'user': user,
'hometown': response['hometown']['name'],
@chrislkeller
chrislkeller / README.md
Last active December 18, 2020 08:12
SpreadSheet To Fusion Tables

Script to sync a Google SpreadSheet to a Fusion Table

Save for a few legacy projects that still use Fusion Tables I don't actively use this script anymore. This update hopefully solves the OAuth issue that cropped up once Google depcricated the Client Login method used by the prior version.

As always, your mileage may vary, and I welcome someone -- Google or otherwise -- to offer a long-term maintained solution.

The following is largely cribbed from a Google example here. I try to explain some of the API settings that must be enabled in the Developer's Console and elsewhere

Create your spr

@havvg
havvg / ajax-form.js
Created August 1, 2012 13:20
jQuery AJAX form submit with Twitter Bootstrap modal
jQuery(function($) {
$('form[data-async]').live('submit', function(event) {
var $form = $(this);
var $target = $($form.attr('data-target'));
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),
@ads901119
ads901119 / gist:3394795
Created August 19, 2012 13:30 — forked from evildmp/gist:3094281
Set up Django, nginx and uwsgi

Set up Django, nginx and uwsgi

Steps with explanations to set up a server using:

  • virtualenv
  • Django
  • nginx
  • uwsgi
@ccarpenterg
ccarpenterg / customized.py
Created November 2, 2012 22:10
A Tornado decorator to display a customized UI for authenticated users.
def customized(default=None, template=None):
def decorator(method):
@functools.wraps(method)
def wrapper(self, *args, **kargs):
self.template = default
if self.current_user:
self.template = template
return method(self, *args, **kargs)
return wrapper
return decorator
@brutus
brutus / wtf-html5.py
Created November 8, 2012 11:58
HTML5 in WTForms
# -*- coding: UTF-8 -*-
"""
WTForms HTML5 Widgets
~~~~~~~~~~~~~~~~~~~~~
This modul adds HTML5 widgets to WTForms_.
It supports the new INPUT types for fields and also sets some of the
new INPUT attributes automatically (based on widget type and what kind of