Skip to content

Instantly share code, notes, and snippets.

View harshildarji's full-sized avatar
:octocat:
Learning Machine Learning

Harshil harshildarji

:octocat:
Learning Machine Learning
View GitHub Profile
@harshildarji
harshildarji / Binning.c
Last active April 1, 2017 05:33
This code performs binning by mean and binning by boundary. Language used in this code is 'C'.
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a[100],**b,i,j,r,c,n,temp,k=0,sum,avg[10],l,h;
clrscr();
printf("How many data? ");
scanf("%d",&n);
@harshildarji
harshildarji / Calculator.java
Created November 2, 2015 15:42
This is a simple java program to create a basic calculator.
package calculator;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Calculator extends JFrame implements ActionListener {
JFrame f;
@harshildarji
harshildarji / Shannon-Fano.cs
Last active April 15, 2016 13:01
This code is to implement Shannon Fano compression algorithm. This takes a string from the user and gives appropriate code for each symbol in the string.
using System;
using System.Linq;
namespace DC4
{
class Program
{
class fano
{
public float pro;
@harshildarji
harshildarji / HuffMan.cs
Last active July 17, 2021 21:19
This code is to implement Huffman compression algorithm.
using System;
using System.Collections.Generic;
using System.Linq;
namespace DC5
{
class Huff
{
public int frequency;
public string data;
@harshildarji
harshildarji / activity_facebook.xml
Last active December 5, 2016 19:05
Sign-In with Facebook using Firebase and get user information using Facebook Graph API.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_facebook"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
@harshildarji
harshildarji / QRCode.java
Last active December 19, 2018 14:50
Generating QR code in Android.
...
String QRcode = "...";
new generateQrcode(qrcodeImageview).execute(QRcode);
...
private class generateQrcode extends AsyncTask<String, Void, Bitmap> {
public final static int WIDTH = 400;
ImageView bmImage;
public generateQrcode(ImageView bmImage) {
this.bmImage = bmImage;
@harshildarji
harshildarji / array_rotation.py
Created December 14, 2017 15:35
Array Rotation (Left and Right)
n, d = map(int, input().split()) # n = len(array), d = Number of rotation
values = [i for i in input().split()][:n]
print(" ".join(values[d:] + values[:d])) # left rotation
print(" ".join(values[n-d:] + values[:n-d])) # right rotation
@harshildarji
harshildarji / levenshtein_distance.py
Last active November 24, 2018 23:19
Generating Levenshtein Distance Matrix and finding Minimum Edit Distance
import numpy
s1 = input('input: ').strip().lower(); l1 = len(s1) + 1
s2 = input('target: ').strip().lower(); l2 = len(s2) + 1
m = numpy.empty([l1, l2], dtype = int)
for i in range(l1):
m[i][0] = i
@harshildarji
harshildarji / regex_python.py
Created May 12, 2018 19:25
HackerRank Regex Solutions | Python
# Regex | HackerRank
# https://www.hackerrank.com/domains/regex
# Matching Anything But a Newline
Regex_Pattern = r'...\....\....\....$'
# Matching Specific String
Regex_Pattern = r'hackerrank'
@harshildarji
harshildarji / check_word.py
Created November 24, 2018 23:18
A little script to check whether the alphabets in a word are presented in an alphabetical order or not!
ip = input('Enter a string: ')
op = ip[0]
for i in range(len(ip) - 1):
dist = ord(ip[i].lower()) - ord(ip[i+1].lower())
if dist > 0: op += ' > ' + ip[i+1]
else: op += ' < ' + ip[i+1]
print(op)