Skip to content

Instantly share code, notes, and snippets.

View felixcheruiyot's full-sized avatar

FELIX CHERUIYOT felixcheruiyot

View GitHub Profile
@felixcheruiyot
felixcheruiyot / gist:a46e66beccfcda392f2f
Last active March 25, 2016 08:15
Django Ajax Service Helper File
var App = (function() {
var remotePostProcessing = function(url, data, defaultCallback, failureCallback) {
data['csrfmiddlewaretoken'] = $('[name = "csrfmiddlewaretoken"]').val();
$.ajax({
url: url,
type: 'POST',
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
beforeSend: function(xhr, settings) {
xhr.setRequestHeader("X-CSRFToken", data['csrfmiddlewaretoken']);
@felixcheruiyot
felixcheruiyot / dribbble.css
Created September 30, 2015 06:27
Create social media buttons with CSS3 gradients.
/*
Dribbble
------------------------------------------------------------ */
a.button-dribbble {
background-color: #c93764; /* fallback color */
background: -moz-linear-gradient(top, #ea4c89, #c93764);
background: -ms-linear-gradient(top, #ea4c89, #c93764);
background: -webkit-linear-gradient(top, #ea4c89, #c93764);
border: 1px solid #c93764;
<!DOCTYPE html>
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/knockout/3.0.0/knockout-min.js"></script><script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="http://silviomoreto.github.io/bootstrap-select/javascripts/bootstrap-select.js"></script>
<link href="http://silviomoreto.github.io/bootstrap-select/stylesheets/bootstrap-select.css" rel="stylesheet" type="text/css" />
<meta charset="utf-8">
<title>JS Bin</title>
<!DOCTYPE html>
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/knockout/3.0.0/knockout-min.js"></script><script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="http://silviomoreto.github.io/bootstrap-select/javascripts/bootstrap-select.js"></script>
<link href="http://silviomoreto.github.io/bootstrap-select/stylesheets/bootstrap-select.css" rel="stylesheet" type="text/css" />
<meta charset="utf-8">
<title>JS Bin</title>
# -*- coding: utf-8 -*-
import os
import StringIO
import hashlib
try:
from boto.s3.connection import S3Connection
from boto.s3.key import Key
except ImportError:
raise ImproperlyConfigured, "Could not load Boto's S3 bindings."

Lately, I have been looking into Python CMSs. There are many out there, but for some reason or another Mezzanine stuck out as one I should try. Installing it is easy enough, but getting it up on running on my new favorite host, Heroku, was a bit of a challege.

Below you will find the steps that I took to get Mezzanine up and running on Heroku. Please let me know in the comments below if anything didn't work for you.

Setting up the Database

Heroku is shortly depricating Django's standard DATABASES dictionary in favor for a package which takes OS Environment Variables and builds the required dictionary for you. This is a good thing because it makes setting up a database on Heroku very easy. The package is called dj_database_url and it makes short work of getting a PostgreSQL database up and running with Mezzanine. Below is the code that you want to put in Mezzanine's DATABASES section:

import dj_database_url
DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
@felixcheruiyot
felixcheruiyot / gist:5476764
Created April 28, 2013 12:35
Installing opencv in ubuntu Copy the following script to gedit and save as opencv.sh . Open terminal. chmox +x opencv.sh ./opencv.sh This will complete opencv installation Credit to [http://opencvstart.blogspot.com/2012/12/install-opencv-in-ubuntu-1204.html] and original author
arch=$(uname -m)
if [ "$arch" == "i686" -o "$arch" == "i386" -o "$arch" == "i486" -o "$arch" == "i586" ]; then
flag=1
else
flag=0
fi
echo "Installing OpenCV 2.4.3"
mkdir OpenCV
cd OpenCV
echo "Removing any pre-installed ffmpeg and x264"
<?php
// Resizer and Image Manipulation
// Based on: http://forums.laravel.com/viewtopic.php?id=2648
public function post_edit_logo($id)
{
$rules = array(
'image' => 'image',
);
<?php
class Auth_Controller extends Base_Controller {
public $restful = true;
public function __construct() {
$this->filter( 'before', 'guest' )->except( array( 'logout', 'validate' ) );
// Note: We may not always require CSRF on login for system based logins so ignore it here.
$this->filter( 'before', 'csrf' )->on( 'post' )->except( array( 'login' ) );
}
@felixcheruiyot
felixcheruiyot / gist:4380158
Created December 26, 2012 12:42
Node.js best way to encrypt password
//https://github.com/ncb000gt/node.bcrypt.js/
bcrypt= require('bcrypt')
bcrypt.hash('password', 5, function( err, bcryptedPassword) {
//save to db
});
//to compare password that user supplies in the future
var hash = getFromDB(..);
bcrypt.compare(userSuppliedPassword, hash, function(err, doesMatch){