Skip to content

Instantly share code, notes, and snippets.

View uditnarayan's full-sized avatar

Udit Narayan uditnarayan

  • Bangalore, India
  • 01:59 (UTC +05:30)
View GitHub Profile
@uditnarayan
uditnarayan / models.java
Created July 16, 2020 13:20 — forked from leefsmp/models.java
Basic RESTful API from a Java servlet
package com.autodesk.adn.viewanddata;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.HashMap;
import java.util.UUID;
import javax.servlet.ServletException;
@uditnarayan
uditnarayan / mysql-docker.sh
Created June 25, 2020 17:21 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@uditnarayan
uditnarayan / GetDomainName.java
Last active July 24, 2018 05:24
Function to get domain name form URL string
/**
* Eamples:
* http://abc.com => abc.com
* https://www.abc.com => abc.com
* http://localhost:8000/some/url/string/ => localhost:8000
*/
import java.net.MalformedURLException;
import java.net.URL;
@uditnarayan
uditnarayan / access_from_web.md
Created March 21, 2018 17:32 — forked from jasperf/access_from_web.md
MySQL Commands to create users, database, password and grant necessary privileges from the command line
mysql> CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON database_name.* TO 'user_name'@'localhost' WITH GRANT OPTION;
mysql> CREATE USER 'user_name'@'%' IDENTIFIED BY 'password';

mysql> GRANT ALL PRIVILEGES ON database_name.* TO 'user_name'@'%' WITH GRANT OPTION;

@uditnarayan
uditnarayan / Hasher.java
Created January 3, 2018 10:48 — forked from lukaszb/Hasher.java
Java implementation of Django PasswordHasher
/* Example implementation of password hasher similar on Django's PasswordHasher
* Requires Java8 (but should be easy to port to older JREs)
* Currently it would work only for pbkdf2_sha256 algorithm
*
* Django code: https://github.com/django/django/blob/1.6.5/django/contrib/auth/hashers.py#L221
*/
import java.nio.charset.Charset;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
@uditnarayan
uditnarayan / server.js
Last active October 31, 2015 18:06
Simple nodejs server for serving static files
/*
Connect is an extensible HTTP server framework for
node using "plugins" known as middleware.
npm install connect
*/
var connect = require('connect');
/*
Create a new middleware function to serve files from