Skip to content

Instantly share code, notes, and snippets.

View ashwanthkumar's full-sized avatar

Ashwanth Kumar ashwanthkumar

View GitHub Profile

Keybase proof

I hereby claim:

  • I am ashwanthkumar on github.
  • I am ashwanthkumar ( on keybase.
  • I have a public key whose fingerprint is 2668 B364 EF04 21C5 5CB0 633A 3C86 C0FB 01EF BF7B

To claim this, I am signing this object:

ashwanthkumar / GroupBy.go
Created February 28, 2022 02:13
GroupBy implementation in Golang for string slices
View GroupBy.go
func GroupBy(slice []string, groupFn func(string) string) map[string][]string {
groups := make(map[string][]string)
for _, elem := range slice {
elementKey := groupFn(elem)
existing, present := groups[elementKey]
if !present {
existing = []string{}
existing = append(existing, elem)
groups[elementKey] = existing
ashwanthkumar / GithubContributors.scala
Last active January 14, 2019 07:27
Get the list of all contributors for all the repos within an organization.
View GithubContributors.scala
import{File, PrintWriter}
import org.kohsuke.github.{GHRepository, GitHub}
import scala.collection.JavaConversions._
// Needs the following in build.sbt
// resolvers += "Sonatype OSS Releases" at ""
// libraryDependencies += "org.kohsuke" % "github-api" % "1.95"
## This script get's the current working directory of an gocd-agent and
## deletes all the directories under pipelines/ except the ${GO_PIPELINE_NAME}.
## Since a stage is running on an agent, we've exclusive access over that agent
## it's safe to perform that delete.
CWD="$( cd "$( dirname "$0" )" && pwd )"
ashwanthkumar /
Created October 24, 2018 04:07
Generate Java Thrift classes for thrift 0.8
docker run -v "$PWD:/data" ashwanthkumar/docker-thrift:0.8 thrift --gen java:private-members --out /data/src/test/java/ /data/src/test/thrift/*.thrift
ashwanthkumar / sumOfN.c
Created June 10, 2018 14:07
Sum of N numbers without mutating any variables.
View sumOfN.c
int sum(int n) {
if (n == 1) return 1;
else return n + sum(n - 1);
int main() {
int input;
scanf("%d", &input);

Python Lists

The following questions were adapted from Prolog Lists, and mostly re-written to remove any prolog references or examples.

  1. Find the last element of a list
  2. Find the last but one element of a list.
  3. Find the K'th element of a list.
  4. Find the number of elements of a list.
  5. Reverse a list.
  6. Find out whether a list is a palindrome.
    A palindrome can be read forward or backward; e.g. [x,a,m,a,x].
  7. Flatten a nested list structure.Transform a list, possibly holding lists as elements into a 'flat' list by replacing each list with its elements (recursively).
View sse-nodejs.d.ts
* Type declaration for npm package
declare module "sse-nodejs" {
import { OutgoingMessage } from "http";
function SSE(response: OutgoingMessage, options?: Object): SSE.ServerSendEvent;
namespace SSE {
* ServerSendEvent wraps a response object from http and exposes
View cloudfront.pem
Subject: *
Issuer: Symantec Class 3 Secure Server CA - G4
Expires on: 18 Dec 2017
Current date: 17 Mar 2017
PEM encoded chain: -----BEGIN CERTIFICATE-----
package chaser.hadoop;
import java.util.Arrays;
import java.util.HashMap;
import java.util.TreeSet;
import java.util.UUID;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;