Skip to content

Instantly share code, notes, and snippets.

View nachivpn's full-sized avatar

Nachi Valliappan nachivpn

View GitHub Profile
@nachivpn
nachivpn / unzip.ps1
Created February 25, 2016 05:01
Unzip a file in powershell by overwriting existing files
function Unzip($zipfile, $outdir)
{
Add-Type -AssemblyName System.IO.Compression.FileSystem
$archive = [System.IO.Compression.ZipFile]::OpenRead($zipfile)
foreach ($entry in $archive.Entries)
{
$entryTargetFilePath = [System.IO.Path]::Combine($outdir, $entry.FullName)
$entryDir = [System.IO.Path]::GetDirectoryName($entryTargetFilePath)
#Ensure the directory of the archive entry exists
#
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
@nachivpn
nachivpn / pga_missing_gatewayId
Created January 4, 2016 06:20
Missing gateway Id for fresh PGA installation
Thrift\Exception\TApplicationException thrown with message "Required field 'gatewayId' was not present! Struct: getAllApplicationDeployments_args(gatewayId:null)"
Stacktrace:
#22 Thrift\Exception\TApplicationException in /var/www/airavata-php-gateway/app/libraries/Airavata/API/Airavata.php:6673
#21 Airavata\API\AiravataClient:recv_getAllApplicationDeployments in /var/www/airavata-php-gateway/app/libraries/Airavata/API/Airavata.php:6639
#20 Airavata\API\AiravataClient:getAllApplicationDeployments in /var/www/airavata-php-gateway/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:211
#19 Illuminate\Support\Facades\Facade:__callStatic in /var/www/airavata-php-gateway/app/libraries/CRUtilities.php:346
#18 Airavata\Facades\Airavata:getAllApplicationDeployments in /var/www/airavata-php-gateway/app/libraries/CRUtilities.php:346
#17 CRUtilities:getBrowseCRData in /var/www/airavata-php-gateway/app/controllers/ComputeResourceController.php:239
#16 ComputeResourceController:browseView in <#unknown>:0
function loadIp($host){
$filepath = "/dev/shm/ipcache";
$ip = gethostbyname($host);
$wfile = fopen($filepath, "w");
fwrite($wfile, $ip);
fclose($wfile);
return $ip;
}
function getIp($host)
@nachivpn
nachivpn / useragent.g4
Last active August 29, 2015 14:17
Grammar for user agent
grammar UserAgent;
useragent : body;
body : bunit
| body bunit
;
bunit : product
| COMMENT
@nachivpn
nachivpn / ip2hex.java
Created January 21, 2015 13:20
Convert IP to Hexadecimal
public String shieldsquare_IP2Hex(String reqIpAddr) {
String hex = "";
String[] part = reqIpAddr.split("[\\.,]");
if (part.length < 4) {
return "00000000";
}
for (int i = 0; i < 4; i++) {
int decimal = Integer.parseInt(part[i]);
if (decimal < 16) // Append a 0 to maintian 2 digits for every
// number
@nachivpn
nachivpn / honeypot.html
Created December 2, 2014 06:45
Honey pot example
<!--honeypot example-->
<a href="http://trappyfakelink.com"></a>
@nachivpn
nachivpn / autossh&.sh
Last active August 9, 2023 23:03
Running an expect script in the background
#!/usr/bin/expect -f
set host "host"
set password "password"
spawn ssh $host
expect {
"(yes/no)?" {
send -- "yes\r"
@nachivpn
nachivpn / noscpcopy.sh
Created July 16, 2014 07:15
Copy a file via ssh
cat file | ssh -p [port] user@host "cat > remotefile"
@nachivpn
nachivpn / autossh.sh
Created July 13, 2014 07:23
Script to automate ssh connections (for mac as brew won't let you install sshpass -.-)
#!/usr/bin/expect -f
#
#credits: http://casual-effects.blogspot.in/2013/05/ssh-with-command-line-password-on-os-x.html
set host "host"
set password "password"
spawn ssh $host
expect {