This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def category_posts(self, *args): | |
all_posts = self.published_posts() | |
for category in args: | |
all_posts = all_posts.filter( | |
categories__category_name__contains=str(category) | |
) | |
return all_posts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
var dir = $.url(document.URL).attr('directory'); | |
console.log(dir); | |
var list = $(".nav li a"); | |
for (var i = 0; i < list.length; i++) { | |
var obj = $(list[i]); | |
if(dir == obj.attr('href')){ | |
//noinspection JSCheckFunctionSignatures | |
obj.parent().addClass('active'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
__author__ = 'Nafiul Islam' | |
__title__ = 'Summation of primes' | |
# Very slow implementation for some reason | |
# Modelled after the sieve of Eratosthenes | |
def main(limit=1000): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def query(): | |
cursor = db.execute("SELECT * FROM links WHERE submitter_id=62443 ORDER BY submitted_time ASC") | |
assert isinstance(cursor, sqlite3.Cursor) | |
return_links = [Link(*link).id for link in cursor.fetchall()] | |
return return_links |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding=utf-8 | |
__author__ = 'Quazi Nafiul Islam' | |
import sys | |
import pip | |
if __name__ == '__main__': | |
sys.stdout = open('requirements.txt', 'w') | |
pip.main(['freeze']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
OlderNewer