This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
winpath() { | |
# get the Windows user path, convert to Unix line endings | |
user_path=$(echo "$(/mnt/c/Windows/System32/cmd.exe /C echo %HOMEDRIVE%%HOMEPATH%)" | tr -d "\r") | |
# expand the specified path | |
target_path=$(readlink -f $1) | |
# change ~ to $user_path | |
if grep -q "^/home/" <<< $target_path; then | |
temp_user_path=$(echo "$user_path" | sed -e 's|\\|/|g' -e 's|^\([A-Za-z]\)\:/\(.*\)|/mnt/\L\1\E/\2|' -e 's|^M$||') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Method to detect whether we are running from an elevated command-prompt | |
# under Vista/Win7 or as part of the local Administrators group in WinXP. | |
# | |
def elevated? | |
whoami = `whoami /groups` rescue nil | |
if whoami =~ /S-1-16-12288/ | |
true | |
else | |
admin = `net localgroup administrators | find "%USERNAME%"` rescue "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'uri' | |
# /api/v1/:format/new | |
# /api/v1/:format/gists/:user | |
# /api/v1/:format/:gist_id | |
res = Net::HTTP.post_form(URI.parse('http://gist.github.com/api/v1/xml/new'), | |
{ 'files[file1.ab]' => 'CONTNETS', | |
'files[file2.ab]' => 'contents' }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A Simple HTTP POST/GET Helper Class for Groovy | |
* | |
* @author Tony Landis | |
* @copyright 2007 Tony Landis | |
* @website http://www.tonylandis.com | |
* @license BSD License (http://www.opensource.org/licenses/bsd-license.php) | |
* @example h = new GroovyHTTP('http://www.google.com/search') | |
* h.setMethod('GET') | |
* h.setParam('q', 'groovy') |