Skip to content

Instantly share code, notes, and snippets.

View hussaintamboli's full-sized avatar

Hussain Tamboli hussaintamboli

View GitHub Profile
@hussaintamboli
hussaintamboli / Calendar in PHP
Created March 14, 2014 05:47
A Calendar in PHP. Kind of looks like Github's activity calendar but vertical.
<?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");
@hussaintamboli
hussaintamboli / JQuery : Edit, Save and Cancel scenario
Created April 29, 2014 05:36
The right way of Ajax for Edit, Save and Cancel scenarios for Web
<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 / jQueryBenchmarkingDynamicInputElementCode
Last active August 29, 2015 14:01
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
<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 / Angularjs paginate filter
Last active August 29, 2015 14:23
A paginate filter in angularjs for maintaining pagination window with current page in the middle
.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) {
signature = "234kkkdkfkdfkeekke-32kd-2349kdk3-dk2"
timeStamp = "2013:10:16 16:21:08"
accessToken = "89389kdfk-23499dkkkkjkk23ee"
{ requestedParams }
loginUrl = wp login url to redirect if access token expired
accountId = 1
currency = "USD"
countryId = 2
billingFrequency = 1 # in months. Set only if any recurring item is purchased. recurring items = licenses or incoming numbers
@hussaintamboli
hussaintamboli / urlparse.py
Created June 22, 2016 05:57 — forked from zhenyi2697/urlparse.py
Python: urlparse demo
#!/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 / Python3 Virtualenv Setup.md
Last active February 14, 2018 09:03 — forked from pandafulmanda/Python3 Virtualenv Setup.md
Setting up and using Python3 Virtualenv on Mac

Python3 Virtualenv Setup

Requirements
  • Python 3
  • Pip 3
$ brew install python3
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 / Web Snippet - Basic
Last active September 14, 2018 10:51
Web Snippets for Pinn
<!-- 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>