Skip to content

Instantly share code, notes, and snippets.

Hussain Tamboli hussaintamboli

Block or report user

Report or block hussaintamboli

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hussaintamboli
hussaintamboli / Web Snippet - Basic
Last active Sep 14, 2018
Web Snippets for Pinn
View Web Snippet - Basic
<!-- START OF USER'S CODE -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
View Fetch instead of XMLHttpRequest
fetch('http://www.mocky.io/v2/5b6137303000007f006a4018').then(function(response) {
return response.json();
}).then(function(data) {
console.log(data);
}).catch(function(err) {
console.log(err.stack);
});
@hussaintamboli
hussaintamboli / Python3 Virtualenv Setup.md
Last active Feb 14, 2018 — forked from pandafulmanda/Python3 Virtualenv Setup.md
Setting up and using Python3 Virtualenv on Mac
View Python3 Virtualenv Setup.md

Python3 Virtualenv Setup

Requirements
  • Python 3
  • Pip 3
$ brew install python3
@hussaintamboli
hussaintamboli / urlparse.py
Created Jun 22, 2016 — forked from zhenyi2697/urlparse.py
Python: urlparse demo
View urlparse.py
#!/usr/bin/python
# The urlparse module provides functions for breaking URLs down into their
# component parts, as defined by the relevant RFCs.
from urlparse import urlparse
# PARSING
parsed = urlparse('http://user:pass@NetLoc:80/path;parameters?query=argument#fragment')
@hussaintamboli
hussaintamboli / Custom response in Flask
Last active Aug 29, 2015
Return a Custom response in flask restful API
View Custom response in Flask
from flask import Response, jsonify
import json
from flask_restful import Resource
class Api(Resource):
def post(self):
response = Response(
response=json.dumps(dict(error='err')),
@hussaintamboli
hussaintamboli / Angularjs paginate filter
Last active Aug 29, 2015
A paginate filter in angularjs for maintaining pagination window with current page in the middle
View Angularjs paginate filter
.filter('paginate', function() {
return function(arr, page, END, START, WINDOW) {
if (typeof(START)==='undefined') START = 0;
if (typeof(WINDOW)==='undefined') WINDOW = 5;
var start = Math.floor(page - WINDOW/2);
var end = Math.floor(page + WINDOW/2);
if (start >= START && end <= END) {
@hussaintamboli
hussaintamboli / Python Pagination
Last active Aug 29, 2015
Code snippet for basic Pagination logic in python
View Python Pagination
START, END, WINDOW = 0, 15, 5
def pages(page):
start = page - WINDOW/2
end = page + WINDOW/2
if start >= START and end <= END:
return range(start, end+1)
if start <= START:
@hussaintamboli
hussaintamboli / jQueryBenchmarkingDynamicInputElementCode
Last active Aug 29, 2015
jQuery: adding <input> elemnts to a div. 1. by adding tags 2. by adding input elements. Which way is faster? Also This code seems to run in lesser time in Google Chrome than Firefox. Why? You can test it in jsbin.com
View jQueryBenchmarkingDynamicInputElementCode
<html><head>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(function ($) {
// code1
var start = +new Date();
var html = '';
for (var i = 0; i < 1000; i++) {
$('#container1').append('<input name="text' + i + '"' + ' value="' + i + '" />');
@hussaintamboli
hussaintamboli / JQuery : Edit, Save and Cancel scenario
Created Apr 29, 2014
The right way of Ajax for Edit, Save and Cancel scenarios for Web
View JQuery : Edit, Save and Cancel scenario
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
</head>
<body>
<span id="spanId" style="float:left;"> Guest </span>&nbsp;
<input type="text" id="inputField" style="display:none;">
<input type="submit" value="Edit" name="editButton" id="editButton" onclick="editIt();" />
<input type="submit" value="Save" id="saveButton" style="display:none;" onclick="saveIt(this);">
<input type="submit" value="Cancel" id="cancelButton" style="display:none;" onclick="$('#saveButton').hide();$('#editButton').show(); $(this).hide();$('#inputField').hide(); $('#spanId').show();">
@hussaintamboli
hussaintamboli / Calendar in PHP
Created Mar 14, 2014
A Calendar in PHP. Kind of looks like Github's activity calendar but vertical.
View Calendar in PHP
<?php
$year = '2014';
$start = date("$year-01-01");
$end = date("$year-12-t");
$week = array();
$month = array();
$i = 0;
print_r("Calendar: $year\n\n");
You can’t perform that action at this time.