Skip to content

Instantly share code, notes, and snippets.

View johnwesonga's full-sized avatar

johnwesonga

  • Bay Area
View GitHub Profile
@johnwesonga
johnwesonga / shitty.py
Created January 20, 2015 11:11
Shitty Python Code
if view == 'student_details':
reg_no = self.request.get('regno',None)
period = self.request.get('period',None)
#Verify Email address and registration number
email = users.get_current_user().email()
if ops.verifyUser(email, reg_no) or ops.isSuperAdmin(users.get_current_user().email()):
pass
else:
self.redirect('/unauthorized')
@johnwesonga
johnwesonga / server.py
Created November 2, 2014 14:41
Google OAuth2 using Tornado Web Framework
#!/usr/bin/env python
# encoding: utf-8
"""
server.py
Created by John Wesonga on 2011-12-12.
Copyright (c) 2011 __MyCompanyName__. All rights reserved.
"""
import tornado.auth
@johnwesonga
johnwesonga / AppDispatcher.js
Created October 27, 2014 18:26
React+Flux App
/**
*
*
* AppDispatcher
**/
var Dispatcher = require('flux').Dispatcher;
var copyProperties = require('react/lib/copyProperties');
var AppDispatcher = copyProperties(new Dispatcher(), {
@johnwesonga
johnwesonga / fabfile
Last active August 29, 2015 14:06
Basic fabfile
# globals
from fabric.api import env, local, run, sudo, put, cd, runs_once, prompt, require, settings
from fabric.contrib.files import exists, upload_template
from fabric.contrib.console import confirm
from fabric.context_managers import hide
env.project_name = 'project_name'
env.project_domain = 'mydomain.co.ke' # Project domain
# environments
@johnwesonga
johnwesonga / cloudstorage.go
Created August 13, 2014 15:29
Access Google Cloud storage buckets and objects using Go
package main
import (
gs "camlistore.org/pkg/googlestorage"
"code.google.com/p/goauth2/oauth"
"fmt"
"log"
)
const (
@johnwesonga
johnwesonga / copyData
Created June 16, 2014 13:09
Apps Script to copy data from one column to multiple columns
function copyData() {
var mySheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var range = mySheet.getDataRange();
var firstNameCell = mySheet.getRange('A1');
var lastNameCell = mySheet.getRange('B1');
var row = 1;
//skip the header column
var dataRange = range.offset(1, 0, range.getNumRows()-1).getValues();
for (i = 0; i < dataRange.length; i++){
@johnwesonga
johnwesonga / remove-dup.go
Created May 27, 2014 11:58
Remove duplicate values from a slice
package main
import "fmt"
//O(n^2) time
func RemoveDuplicates(data []string) []string {
length := len(data) - 1
for i := 0; i < length; i++ {
for j := i + 1; j <= length; j++ {
if data[i] == data[j] {
@johnwesonga
johnwesonga / add_profile.js
Last active August 29, 2015 13:57
Very Simple FlightJS app
// components/ui/add_profile.js
define(function (require) {
'use strict';
/**
* Module dependencies
*/
var defineComponent = require('flight/lib/component');
@johnwesonga
johnwesonga / csvread.go
Last active August 29, 2015 13:56
Read a CSV file, skipping the headers
package main
import (
"encoding/csv"
"fmt"
_ "io"
"os"
)
func checkCsv() {
@johnwesonga
johnwesonga / checker.go
Last active August 29, 2015 13:56
URL Checker
package main
import (
"bufio"
"fmt"
"io"
"log"
"net/http"
"os"
"sync"