Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀
Hustling.

Utkarsh Sengar utsengar

🚀
Hustling.
View GitHub Profile
View ProgrammaticalDemo.swift
//
// 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 Aug 2, 2016
spark2.0 LR load
View 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 Aug 20, 2015
Simple maven assembly example (which works)
View pom.xml
<!-- 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
Check Battery health for a Mac (result in %, should be 100% for a brand new mac)
View check_battery.sh
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 Feb 24, 2020
Validate routing number in Python
View validate_routing_number.py
"""
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 Mar 23, 2014
Find distance between two lat/lon
View haversine.py
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 Aug 29, 2015
wiki client in objc
View wiki_objc_client.m
//
// 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 Dec 20, 2015
Solr's schema.xml
View 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 Jul 29, 2013
Center any div on page (think google.com's search box)
View center_div.js
// $(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;
}
View CassandraToSolrETL.java
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;
You can’t perform that action at this time.