Skip to content

Instantly share code, notes, and snippets.

View divyanshu013's full-sized avatar
:shipit:
Ship it

Divyanshu Maithani divyanshu013

:shipit:
Ship it
View GitHub Profile
@divyanshu013
divyanshu013 / simple_client.py
Last active September 30, 2015 20:41
A simple server-client application in Python
#!/usr/bin/python # This is client.py file
import socket # Import socket module
s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 12345 # Reserve a port for your service.
s.connect((host, port))
print s.recv(1024)
@divyanshu013
divyanshu013 / file_client.py
Last active September 10, 2015 05:20
A simple server-client application to send and receive a file in Python
import socket # Import socket module
s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 6969 # Reserve a port for your service.
s.connect((host, port))
s.send("Hello server!")
with open('received_file', 'wb') as f:
@divyanshu013
divyanshu013 / multi_file_client.py
Created September 10, 2015 05:37
A simple multithreaded server-client application in Python
#!/usr/bin/env python
import socket
TCP_IP = 'localhost'
TCP_PORT = 6969
BUFFER_SIZE = 1024
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
@divyanshu013
divyanshu013 / encrypt_pydes.py
Created September 27, 2015 19:17
A simple program to show DES encryption in python using pyDes
from pyDes import *
from binascii import unhexlify as unhex
key = des(unhex("4C1122171220F74E"))
data = "0001010011010111010010010001001001111100100111100001101110000010"
encrypted = key.encrypt(data)
print ("Encrypted: %r" % encrypted)
decrypted = key.decrypt(encrypted)
@divyanshu013
divyanshu013 / rsa.c
Created October 12, 2015 04:50
Simple RSA implementation in C
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
/* Refer to http://www.coders-hub.com/2013/04/c-code-to-encrypt-and-decrypt-message.html#.Vhs81MryNC1 */
long int p,q,n,t,flag,e[100],d[100],temp[100],j,m[100],en[100],i;
char msg[100];
int prime(long int);
@divyanshu013
divyanshu013 / index.html
Created April 7, 2016 10:09
Map webapp
<html>
<head>
<title>CA Map</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
<style>
body {
background-color: linen;
}
<!DOCTYPE html>
<html>
<head>
<title>Assignment on HTML</title>
</head>
<body>
<p>
<h2>Hi I'm Divyanshu</h2>
<img src="div.jpg" alt="User image" width="180px">
<br>
<!DOCTYPE html>
<html>
<head>
<title>Learning CSS3</title>
<style type="text/css">
body {
font-family: "Helvetica", sans-serif;
}
fieldset {
@divyanshu013
divyanshu013 / App.js
Last active September 20, 2017 11:19
Adding reactivesearch sample app
import React, { Component } from 'react';
import {
ReactiveBase,
CategorySearch,
RatingsFilter,
ResultCard
} from '@appbaseio/reactivesearch';
class App extends Component {
onData(res) {
@divyanshu013
divyanshu013 / auth.js
Last active September 22, 2017 13:55
Auth0 authentication service
import auth0 from 'auth0-js';
import history from './history';
export default class Auth {
// Please use your own credentials here
auth0 = new auth0.WebAuth({
domain: 'divyanshu.auth0.com',
clientID: 'TJyKPI6aRiRwgr6SxlT7ExW10NEHW4Vy',
redirectUri: process.env.NODE_ENV === 'development' ? 'http://localhost:3000/callback' : 'https://appbaseio-apps.github.io/reactivesearch-auth0-example/callback',