Skip to content

Instantly share code, notes, and snippets.

View nitincoded's full-sized avatar
💭
Picking a coding challenge every week, while actively on a job-search.

Nitin Reddy nitincoded

💭
Picking a coding challenge every week, while actively on a job-search.
View GitHub Profile
@nitincoded
nitincoded / copy-backups.bat
Created April 10, 2016 11:42
Copy local backups to remote NAS using WinSCP
"C:\Program Files (x86)\WinSCP\WinSCP.exe" /console /command "open scp://root:root@192.168.1.125" "synchronize remote -filemask=>3D D:\Backup /volume1/Backup" exit
#Try one of these to accept the remote signature
#"C:\Program Files (x86)\WinSCP\WinSCP.exe" scp://root:root@192.168.1.125
#"C:\Program Files (x86)\WinSCP\WinSCP.exe" /command "open scp://root:root@192.168.1.125"
@nitincoded
nitincoded / squid.conf.delta
Created April 10, 2016 13:37
Squid configuration for reverse proxy
http_port 86 accel defaultsite=www.computerworld.com no-vhost
cache_peer www.computerworld.com parent 80 0 no-query originserver name=myAccel
acl our_sites dstdomain www.computerworld.com
http_access allow our_sites
cache_peer_access myAccel allow our_sites
#cache_peer_access myAccel deny all
@nitincoded
nitincoded / gen-ssl-key.sh
Created April 11, 2016 14:19
OpenSSL command for generating certificates for Apache
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout privkey -out cert
#req -x509 is to generate X509 certificate
#nodes is for no passphrase
#days is for validity to expiry
#newkey is for generating new key instead of using existing key
#Enable the SSL mod, enable the default-ssl site, modify the default-ssl.conf to set the SSLCertificateFile and SSLCertificateKeyFile
#Apache generates a warning telling us that it's a self-signed certificate; ignore the warning :-P
@nitincoded
nitincoded / rsync-it.sh
Created April 12, 2016 08:32
Setting up RSync script on NAS
#I'm Nitin the DevOps guy and these instructions are for whoever chooses to follow...
#Some NAS require sec=ntlm or sec=ntlmv2 as an option for it to mount
#Get catty with /proc/filesystem to check if cifs has been loaded after first use, them dmesg | tail to look for any other errors
#sudo mount -t cifs -o username=Administrator,password=Password123$ //192.168.1.53/e$ /mnt/53e/
#Take a stab at auto-loading with the following in /etc/fstab and mount -a
#Add the sec option if needed
@nitincoded
nitincoded / xrdp-on-lubuntu-1604.txt
Last active April 24, 2019 14:20
Enable XRDP on Lubuntu 16.04
First open a terminal and enter sudo apt-get install xrdp. When that is installed enter sudo nano /etc/xrdp/startwm.sh in the terminal. Make sure the last line looks like this:
. /etc/X11/Xsession
Then go to your home folder, rightclick and select Show hidden. If there is no file named .xsession, create it. If there is a filed named like that, open it and make sure that it looks like this when your done: lxsession -e LXDE -s Lubuntu
Now type sudo service xrdp restart in the terminal to restart xrdp. Now it should work :)
answered Feb 1 '15 at 9:52
@nitincoded
nitincoded / ssh-without-passwd.txt
Created April 27, 2016 08:53
Setting up SSHd without requiring a password
Run ssh-keygen. This creates the files ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub
Copy this file across to the host on which you want to login.
Run ssh-copy-id -i <filename> user@hostname
The user and hostname are on the destination system - copy this off the bash prompt
Putty uses a different format so use PuttyKeygen to load the private key and convert it to ppk format
@nitincoded
nitincoded / EamPwHasher.java
Created November 27, 2016 12:44
com.nitin.EamPwHasher
package com.nitin;
import java.security.MessageDigest;
import org.apache.commons.codec.binary.Base64;
public class EamPwHasher {
public static String hashedPassword(String aUsername, String aPassword) throws Exception {
MessageDigest hasher = MessageDigest.getInstance("SHA-256");
byte[] salt = (aUsername.toUpperCase()+"@#$ABCDEFGHIJKLMNOPQRSTUVWXYZ/(-").substring(0, 32).getBytes("UTF-8");
hasher.update(salt);
@nitincoded
nitincoded / read_activity.rb
Created December 11, 2016 11:06
Read GitHub Events (Ruby sample code)
require 'open-uri'
require 'zlib'
require 'yajl'
gz = open('http://data.githubarchive.org/2015-01-01-12.json.gz') #Date range 1-12
js = Zlib::GzipReader.new(gz).read
Yajl::Parser.parse(js) do |event|
print event
end
@nitincoded
nitincoded / HelloController.java
Created January 1, 2017 19:36
Spring MVC JSON Example
package com.katkam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.stereotype.Controller;
// import org.springframework.web.servlet.mvc.AbstractController;
// import org.springframework.validation.BindingResult;
// import javax.servlet.http.HttpServletRequest;
// import javax.servlet.http.HttpServletResponse;
@nitincoded
nitincoded / newuser-and-mbox-in-psh.txt
Created January 3, 2017 06:19
PowerShell script for new user and mailbox
$newuserpass=ConvertTo-SecureString "ablublah" -AsPlainText -Force
New-ADUser -Name "fname.lname" -GivenName "fname" -Surname "lname" -DisplayName "fname lname" -AccountPassword $newuserpass -Path "OU=subgroup,DC=dcname,DC=dcupname" -Enabled 1
#On Exchange Server
Enable-Mailbox -Identity fname.lname -Database MBOX01