Skip to content

Instantly share code, notes, and snippets.

View utsengar's full-sized avatar
🚀
Hustling.

Utkarsh Sengar utsengar

🚀
Hustling.
View GitHub Profile
//
// ProgrammaticalDemo.swift
// PieCharts
//
// Created by Hyun Min Choi on 2017. 1. 23..
// Copyright © 2017년 Ivan Schuetz. All rights reserved.
//
import UIKit
import PieCharts
@utsengar
utsengar / spark2.0 LR load
Last active August 2, 2016 23:54
spark2.0 LR load
16/08/02 23:50:06 INFO TaskSetManager: Finished task 0.0 in stage 2.0 (TID 2) in 7401 ms on mesos-slave9-qa-uswest2.qasql.opentable.com (1/1)
16/08/02 23:50:06 INFO TaskSchedulerImpl: Removed TaskSet 2.0, whose tasks have all completed, from pool
16/08/02 23:50:06 INFO DAGScheduler: ResultStage 2 (parquet at GLMClassificationModel.scala:77) finished in 7.402 s
16/08/02 23:50:06 INFO DAGScheduler: Job 2 finished: parquet at GLMClassificationModel.scala:77, took 7.474796 s
Exception in thread "main" java.lang.IllegalArgumentException: Wrong FS: file://spark-warehouse, expected: file:///
at org.apache.hadoop.fs.FileSystem.checkPath(FileSystem.java:647)
at org.apache.hadoop.fs.FileSystem.makeQualified(FileSystem.java:466)
at org.apache.hadoop.fs.FilterFileSystem.makeQualified(FilterFileSystem.java:119)
at org.apache.spark.sql.catalyst.catalog.SessionCatalog.makeQualifiedPath(SessionCatalog.scala:116)
at org.apache.spark.sql.catalyst.catalog.SessionCatalog.createDatabase(SessionCatalog.scala:145)
@utsengar
utsengar / pom.xml
Created August 20, 2015 23:55
Simple maven assembly example (which works)
<!-- Source: http://www.mkyong.com/maven/create-a-fat-jar-file-maven-assembly-plugin -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mkyong.core.utils</groupId>
<artifactId>dateUtils</artifactId>
<packaging>jar</packaging>
@utsengar
utsengar / check_battery.sh
Created May 5, 2015 04:17
Check Battery health for a Mac (result in %, should be 100% for a brand new mac)
echo $(ioreg -l -n AppleSmartBattery -r | grep MaxCapacity | awk '{print $3}') / $(ioreg -l -n AppleSmartBattery -r | grep DesignCapacity | awk '{print $3}') \* 100 | bc -l
@utsengar
utsengar / validate_routing_number.py
Last active February 24, 2020 18:32
Validate routing number in Python
"""
The function checks correctness of a routing number using the Checksum algorithm.
Checksum algorithm: http://en.wikipedia.org/wiki/Routing_transit_number#Check_digit
"""
def validate(routing_number):
if len(s) != 9:
return False
n = 0
for i in xrange(0, len(s), 3):
@utsengar
utsengar / haversine.py
Created March 23, 2014 07:00
Find distance between two lat/lon
from math import radians, cos, sin, asin, sqrt
def haversine(lon1, lat1, lon2, lat2):
"""
Calculate the great circle distance between two points
on the earth (specified in decimal degrees)
"""
# convert decimal degrees to radians
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
@utsengar
utsengar / wiki_objc_client.m
Last active August 29, 2015 13:56
wiki client in objc
//
// Wikipedia.m
// yoda
//
// Created by Utkarsh Sengar on 2/9/14.
// Copyright (c) 2014 area42. All rights reserved.
//
#import "Wikipedia.h"
#import "AFNetworking.h"
@utsengar
utsengar / schema.xml
Last active December 20, 2015 17:18
Solr's schema.xml
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="prodinfo" version="1.1">
<types>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="string" class="solr.StrField"/>
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<filter class="solr.LowerCaseFilterFactory"/>
@utsengar
utsengar / center_div.js
Created July 29, 2013 04:58
Center any div on page (think google.com's search box)
// $(element).center();
jQuery.fn.center = function ()
{
this.css("position","absolute");
this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
return this;
}
@utsengar
utsengar / CassandraToSolrETL.java
Created June 21, 2013 00:16
DSE wordcount M/R job
package com.rl.hadoopjobs;
import java.io.IOException;
import java.net.URI;
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;