Skip to content

Instantly share code, notes, and snippets.

@yssharma
yssharma / random.py
Created October 17, 2017 11:46
Get 5 random topics for studying algorithms from geeksforgeeks
"""
For educational purposes.
Do not misuse.
"""
from random import shuffle
import urllib
f = urllib.urlopen('http://www.geeksforgeeks.org/array-data-structure/')
li = [l.split('href="')[1] for l in f.readlines() if '<li>' in l and 'http' in l]
qlist = [l.split(">")[1].split('</a')[0] + '\t' + l.split('">')[0] for l in li]
shuffle(qlist)
@yssharma
yssharma / airflow_dag.py
Last active July 14, 2017 04:04
Airflow dag for range runs
# Here we look if there were any
# _MANUAL_OVERRIDE_START_DATE or _MANUAL_OVERRIDE_END_DATE passed
# in config, else, it falls back to yesterday
# for daily runs.
START = "{{dag_run.conf.get('_MANUAL_OVERRIDE_START_DATE', macros.ds_add(ds, -1)) if dag_run.conf else macros.ds_add(ds, -1)}}"
END = "{{dag_run.conf.get('_MANUAL_OVERRIDE_END_DATE', ds) if dag_run.conf else ds}}"
query = """
select
day,
@yssharma
yssharma / B.java
Last active October 16, 2016 12:09
Codeforces 376 Div 2
package codeforces.x376;
import java.util.Scanner;
/**
* Created by ysharma on 10/16/16.
*/
public class B {
public static void main(String[] args) {
@yssharma
yssharma / A.java
Created October 16, 2016 11:41
Codeforces 376 Div 2
package codeforces.x376;
import java.util.Scanner;
/**
* Created by ysharma on 10/16/16.
*/
public class A {
public static void main(String[] args) {
@yssharma
yssharma / main.go
Created October 15, 2016 02:44
A minimal client script that keeps reading messaged on command line and keeps posting the json requests to the http server
package main
/* Al useful imports */
import (
"bufio"
"bytes"
"encoding/json"
"flag"
"fmt"
"io/ioutil"
@yssharma
yssharma / messages.go
Created October 15, 2016 02:42
Messages is a typical module with all reusable struts. This shows the structs we would be using for exchanging the json messages.
type JsonRequest struct {
JsonRequestString string `json:"jsonRequestString"`
}
type JsonResponse struct {
JsonResponseString string `json:"jsonResponseString"`
}
@yssharma
yssharma / main.go
Created October 15, 2016 02:41
The main module for the http server receiving Json messages and posting Json response back
package main
/* All useful imports */
import (
"flag"
"fmt"
"net/http"
"encoding/json"
"go-going/gone/messages"
)
@yssharma
yssharma / join-cluster.go
Last active November 15, 2021 02:11
Writing a basic distributed system in go lang - part 1 - confused coders
package main
/* Al useful imports */
import (
"flag"
"fmt"
"net"
"strings"
"strconv"
"time"
@yssharma
yssharma / BinSearch.java
Created September 18, 2016 10:40
Binary search intro for Ayush & Pallavi
package practice.search;
/**
* Created by ysharma on 9/18/16.
*/
public class BinSearch {
public static boolean doIt(int[] arr, int elem){
// return type is boolean .. since we dont have index of elements anyways. we are working on values.
int start = arr[0];
package practice.search;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
/**
* Created by ysharma on 8/30/16.
*/