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
open Core.Std
let rec sum l =
match l with
| [] -> 0
| hd :: tl -> hd + sum tl
let divide x y =
if y = 0 then None else Some (x/y)
@prakhar1989
prakhar1989 / sparkfun.js
Last active August 29, 2015 14:03
Sparkfun
var casper = require('casper').create();
var home_url = "https://applications2.almullagroup.com/onlineremit/faces/infrastructure/EXLogin.jspx";
var rate;
var sparkfun_url = "https://data.sparkfun.com/input/XCVB?private_key=ABCD&INR="
casper.start(home_url);
casper.waitForSelector("form#form1");
import java.sql.*;
public class FirstExample {
// JDBC driver name and database URL
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://172.22.32.201/site";
// Database credentials
static final String USER = "db_user";
static final String PASS = "db_pass";
@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",
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) {
filename=$1
for hour in {0..23}
do
for minute in {0..59}
do
if [ $hour -lt 10 ]
then
h="0$hour"
else
@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:
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,
<!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;}