Skip to content

Instantly share code, notes, and snippets.

@xtman
xtman / example.tcl
Created March 6, 2013 02:39
The examples demonstrates how to replace a string in TCL
# replace apple with orange
puts [string map {"apple" "orange"} "I like apple."]
# remove . in the string 3.8.001, prints 38001
puts [string map {. ""} 3.8.001]
# more about string map, see http://wiki.tcl.tk/10170
@xtman
xtman / rm-ms-office-2011.sh
Created April 17, 2013 01:17
The script to remove MS office for Mac 2011
#!/bin/sh
osascript -e 'tell application "Microsoft Database Daemon" to quit'
rm -R '/Applications/Microsoft Communicator.app/'
rm -R '/Applications/Microsoft Messenger.app/'
rm -R '/Applications/Microsoft Office 2011/'
rm -R '/Applications/Remote Desktop Connection.app/'
rm -R '/Library/Application Support/Microsoft/'
rm -R '/Library/Automator/*Excel*'
rm -R '/Library/Automator/*Office*'
rm -R '/Library/Automator/*Outlook*'
@xtman
xtman / ssh-tunnel-start
Created September 6, 2013 17:11
A shell script to establish a ssh tunnel using ssh command.
#!/bin/sh
LOCAL_HOST="localhost"
LOCAL_PORT=""
GATEWAY_USER=""
GATEWAY_HOST=""
GATEWAY_PORT=22
TARGET_HOST=""
@xtman
xtman / update-java-alternatives.sh
Created September 19, 2013 01:00
A script to detect the installed Oracle JDK 7 and set alternatives to use the ones from the latest Oracle JDK 7. Tested on CentOS 6.4.
#!/bin/bash
## locate the JDK
JDK=$(basename $(ls -l -d /usr/java/jdk1.* | awk '{print $NF}' | tail -n 1))
[[ -z $JDK ]] && echo "No Oracle JDK 7 installed in /usr/java" 1>&2 && exit 1
## java
alternatives --install /usr/bin/java java /usr/java/${JDK}/jre/bin/java 20000
alternatives --set java /usr/java/${JDK}/jre/bin/java
#!/bin/bash
ARC=`uname -m`
if [[ `echo $ARC | egrep 'i[3456]86'` ]]; then
ARC=i386
else
ARC=x86_64
fi
# NOMACHINE NX binary packages
@xtman
xtman / Google_App_Script_Upload_Multi_Files_To_GoogleDrive_Code.gs
Last active September 19, 2023 08:31
Google App Script: Upload Multiple Files to Google Drive (Code.gs)
function doGet() {
return HtmlService.createHtmlOutputFromFile('Form').setSandboxMode(
HtmlService.SandboxMode.IFRAME);
}
function createFolder(parentFolderId, folderName) {
try {
var parentFolder = DriveApp.getFolderById(parentFolderId);
var folders = parentFolder.getFoldersByName(folderName);
var folder;
@xtman
xtman / Google_App_Script_Upload_Multi_Files_To_GoogleDrive_Form.html
Created December 6, 2016 04:36
Google App Script: Upload Multiple Files to Google Drive (Form.html)
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<form id="uploaderForm">
<label for="uploaderForm">Upload multiple Files</label>
<div>
<input type="text" name="applicantName" id="applicantName"
@xtman
xtman / ScanForBadNames.java
Created October 7, 2019 01:23
Java app to search for illegal or problematic file names. The results are saved to a CSV file.
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.concurrent.atomic.AtomicLong;
@xtman
xtman / build-jre.ps1
Created October 22, 2019 05:28
A PowerShell Script to build Java Runtime from JDK 11+
if (-Not (Test-Path Env:JAVA_HOME)) {
Write-Output "JAVA_HOME environment variable is not set."
Exit 1
}
$Env:PATH = $Env:JAVA_HOME + "\bin;" + $Env:PATH
$VERSION_LINE = (java -version 2>&1 | Select-String version)
$NAME = ($VERSION_LINE | %{$_.Line.Split(' ')[0];})
$VERSION = ($VERSION_LINE | %{$_.Line.Split(' ')[2].Replace("`"", "");})
@xtman
xtman / fix-and-install-parallel-tools.sh
Created December 15, 2021 00:39
Patch and install Parallel tools on Rocky Linux or CentOS Linux
#!/usr/bin/env bash
if [[ ! -d "/media/$(whoami)/Parallels Tools" ]]; then
echo "Please mount parallels tools disk before install"
exit
fi
echo "Copy install files to /tmp/parallels_fixed"
cp -rf "/media/$(whoami)/Parallels Tools" /tmp/parallels_fixed
chmod -R 755 /tmp/parallels_fixed
cd /tmp/parallels_fixed/kmods
echo "Unpack prl_mod.tar.gz"