Skip to content

Instantly share code, notes, and snippets.

View prakhar1989's full-sized avatar
I may be slow to respond.

Prakhar Srivastav prakhar1989

I may be slow to respond.
View GitHub Profile
@prakhar1989
prakhar1989 / logger.py
Created December 8, 2013 14:43
Sending emails with files as attachments in python 2.4
#!/usr/bin/python
import MySQLdb as mdb
import sys
import csv
import smtplib
from datetime import datetime
from email.MIMEBase import MIMEBase
from email.MIMEMultipart import MIMEMultipart
from email import Encoders
@prakhar1989
prakhar1989 / logger2.py
Created December 8, 2013 14:54
Logger file with mailer for python 2.7
#!/usr/bin/python2.7
import requests
import datetime
import smtplib
import logging
import re
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
sender = "uptimebot@test.com"
@prakhar1989
prakhar1989 / amxremit.py
Created December 24, 2013 16:46
Selenium Script to get currencies from AmxRemit
from selenium import webdriver
from selenium.webdriver.support.select import Select
browser = webdriver.Firefox()
browser.get('http://www.amxremit.com')
# get the currency dropdown
select = Select(browser.find_element_by_id("showrate"))
select.select_by_index(3) #for INR currency
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Test Suite!</title>
<style>
li.pass { background: green;
color: white;}
li.fail { background: red; color: white;}
ul#results ul { margin-bottom: 10px;}
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Test Suite!</title>
<style>
li.pass { background: green;
color: white;}
li.fail { background: red; color: white;}
ul#results ul { margin-bottom: 10px;}
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
files: ['**/*.js', '**/*.html'],
options: {
// Start a live reload server on the default port 35729
livereload: true,
@prakhar1989
prakhar1989 / log_analysis.py
Last active August 29, 2015 14:03
Log Analysis
#!/usr/bin/python2.7
import re
from collections import Counter
import sys
def do_analysis(data):
date_map = dict()
for l in data:
filename=$1
for hour in {0..23}
do
for minute in {0..59}
do
if [ $hour -lt 10 ]
then
h="0$hour"
else
angular.module("xciteServices", [])
.factory('CartService', function() {
// Factory for Cart Items
var cartItems = angular.copy(window.Globals.CartItems);
return {
// private function to find item with itemId
_findItem: function(itemId) {
var index = -1;
for (var i in cartItems) {
if (cartItems[i].id === itemId) {
@prakhar1989
prakhar1989 / delivery.json
Created July 10, 2014 09:05
Delivery Format
{
"status": "success",
"product_delivery_messages": {
"1294420": "Same Day Delivery",
"1294427": "Next Day Delivery"
},
"product_delivery_methods": {
"1294420": [
{
"value": "standard_delivery",