Skip to content

Instantly share code, notes, and snippets.

View gamesbrainiac's full-sized avatar
💭
Gone Fishing.

Nafiul Islam gamesbrainiac

💭
Gone Fishing.
View GitHub Profile

var counter = 0 function nextClick(){ (...) if (...) { (...) } else if (...) { qArraycounter; counter++; } }

@gamesbrainiac
gamesbrainiac / ModelTutorial.py
Created November 1, 2014 05:56
An example based tutorial on how to create different types of relationships in SQLAlchemy
from datetime import datetime
import sqlalchemy as sa
import sqlalchemy.orm as orm
from sqlalchemy.engine import create_engine
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('sqlite:///test.db')
Base = declarative_base(bind=engine)
@gamesbrainiac
gamesbrainiac / morepath_qs.md
Last active August 29, 2015 14:06
Questions about Morepath

I've been trying to understand how morepath works with the quickstart guide in the documentation.I have a couple of questions regarding the design, and my understanding of what's happening.

So, a model is a resources, pretty much a representation of an object stored in a databse. Atleast, this is how I understand it, if this is so, why can't we have a path assigned to it, inside the classbody itself. So, right now:

# We declare the object
class User(object):
 def __init__(self, username, fullname, email):
package too_test
import (
"fmt"
"log"
"net"
"github.com/hjr265/too"
)
@gamesbrainiac
gamesbrainiac / pipreq.py
Created April 27, 2014 18:11
Pip requirements generator
# encoding=utf-8
# FILE INFO #####################################################
# Title : pip requirements generator
# By : Quazi Nafiul Islam <[email protected]>
# Date : 28 Apr 2014
# Made to be used with pycharm Macros
#################################################################
import pip
function goinit {
export GOROOT=/usr/local/Cellar/go/1.2.1/libexec
if [ $# -lt 1 ]
then
echo "No directories were created."
export GOPATH=$(pwd -P)
export PATH=$PATH:$GOPATH:$GOPATH/bin
else
echo "$1 being created"
mkdir $1
@gamesbrainiac
gamesbrainiac / Auto generate requirements
Created February 5, 2014 15:49
Automatically generates the requirements of your interpreter through a pip freeze.
# encoding=utf-8
__author__ = 'Quazi Nafiul Islam'
import sys
import pip
if __name__ == '__main__':
sys.stdout = open('requirements.txt', 'w')
pip.main(['freeze'])
from collections import defaultdict
from heapq import *
def prim( nodes, edges ):
conn = defaultdict( list )
for n1,n2,c in edges:
conn[ n1 ].append( (c, n1, n2) )
conn[ n2 ].append( (c, n2, n1) )
mst = []
@gamesbrainiac
gamesbrainiac / info_getter.py
Created July 22, 2013 20:17
Super awesome python code.
import requests
def get_raw_repo_data(username):
"""
Creates a connection to api.github.com through HTTPS
"""
print('starting')
CONNECTION_DETAILS = {
"host": "https://api.github.com",
"path": "/users/" + username + "/repos",
@gamesbrainiac
gamesbrainiac / ajax.js
Created June 29, 2013 19:42
Awesome getCookie Function from djangoproject
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;