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
package too_test
import (
"fmt"
"log"
"net"
"github.com/hjr265/too"
)
@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):
@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)

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

@gamesbrainiac
gamesbrainiac / TestPony.py
Last active August 29, 2015 14:10
How to sort comments in Pony
# encoding=utf-8
__author__ = "Quazi Nafiul Islam"
from pony import orm
# orm.sql_debug(True)
db = orm.Database()
db.bind('sqlite', 'todo_api.db', create_db=True)
# encoding=utf-8
__author__ = "Quazi Nafiul Islam"
from bisect import *
from array import array
def find_le(a, x):
"""Find rightmost value less than or equal to x"""
i = bisect_right(a, x)
import heapq
class PriorityQueue(object):
def __init__(self):
self._queue = []
self._index = 0
def push(self, item, priority):
heapq.heappush(self._queue, (-priority, self._index, item))
@gamesbrainiac
gamesbrainiac / graphql_01.py
Last active June 23, 2017 00:40
2017_06_22_graphql-in-the-python-world
import graphene # 1
class Query(graphene.ObjectType): # 2
hello = graphene.String(description='A typical hello world') # 3
def resolve_hello(self, args, context, info): # 4
return 'World'
schema = graphene.Schema(query=Query) # 5
swagger: "2.0"
info:
version: "1.0.0"
title: "Newsletter API"
license:
name: "Copyright Suitsupply BV"
host: "0.0.0.0:5000"
basePath: "/v1"
tags:
- name: "subscription"
@gamesbrainiac
gamesbrainiac / dicts.py
Created July 16, 2020 01:33
What does this package do? Episode 2: Enhanced Dictionaries
# encoding=utf-8
# What does this package do? Episode 2: collections.defaultdict
from collections import defaultdict
from pprint import pprint
events = [
'mouse-click',
'mouse-hover',
'mouse-hover',