Skip to content

Instantly share code, notes, and snippets.

View AnimeshShaw's full-sized avatar
🏠
Working from home

Animesh Shaw AnimeshShaw

🏠
Working from home
View GitHub Profile
@AnimeshShaw
AnimeshShaw / BinarySearch.java
Created September 19, 2013 20:20
Binary Search Algorithm implemented in Java. This code can be used to search for integers or characters or Strings or a combination of all. Binary search assumes that the input array or elements are sorted but this code with sort them after you enter the array. Get the sorting code from here :- https://gist.github.com/PsychoCoderHC/6541791
import Sorts.InsertionSort;
import java.util.Scanner;
public class BinarySearch {
public int binarySearch(Comparable[] a, Comparable key) {
int low = 0, high = a.length - 1,mid;
while (low <= high) {
mid = low + (high - low) / 2;
if(key.compareTo(a[mid])< 0 ) high = mid -1;
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<script language="javascript" type="text/javascript" >
function jumpto(x){
if (document.form1.jumpmenu.value != "null") {
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<input type="button" value="Reload Page" onClick="document.location.reload(true)">
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<script type="text/javascript">
// Popup window code
function newPopup(url) {
popupWindow = window.open(
url,'popUpWindow','height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<script language="javascript">
var popupWindow = null;
function centeredPopup(url,winName,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
@AnimeshShaw
AnimeshShaw / L_Systems_Tree.java
Last active June 13, 2017 12:35
Tree fractal in Java.
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
/**
* @author psychocoder
clc
clear all
[x, y, z] = meshgrid(-10:0.05:10,-10:0.05:10,-10:0.05:10);
r = power((power(x,2) + ((9/4).*power(y,2)) + power(z,2) - 1),3) - (power(x,2).*power(z,3)) - ((9/80).*(power(y,2).*power(z,3)));
p = patch(isosurface(x,y,z,r,0));
set(p,'facecolor','red','EdgeColor','none');
daspect([1,1,1]);
view(3);
axis off;
camlight('right')
@AnimeshShaw
AnimeshShaw / MergeSort.py
Created February 18, 2014 12:46
Merge Sort implementation in python
def merge(left, right):
result = []
n, m = 0, 0
while n < len(left) and m < len(right):
if left[n] <= right[m]:
result.append(left[n])
n += 1
else:
result.append(right[m])
m += 1
import socket
import random
sent=0
socket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
ip=raw_input('Target IP Address: ')
port=input("Please enter a port: ")
num_bytes=input('Please enter data size in bytes: ')
bytes=random._urandom(num_bytes)
addr=(ip,port)
import hashlib
"""
Encrypts given string
Method: md5, sha1, sha224, sha256, sha384, sha512
Supports: Salts
How to use: encrypt('password', 'sha512', '04/16/2010')
"""