Skip to content

Instantly share code, notes, and snippets.

View gdlmx's full-sized avatar

Mingxuan Lin gdlmx

View GitHub Profile
@gdlmx
gdlmx / AdRemover.md
Last active June 24, 2016 18:41
Remove ad in google search results

Save this as a bookmark in browser:

javascript:(function(){adid=['adBlock','tadsb'];g=function(x){css=x.createElement('style');css.type='text/css';css.innerHTML='.gsc-adBlock,#adBlock,#tadsb,iframe[src*="doubleclick.net"]{display:none;}';x.body.appendChild(css);for(i=0;i<adid.length;i++){a=x.getElementById(adid[i]);if(a)a.parentElement.removeChild(a)}};f=function(s){g(s);ifrs=s.getElementsByTagName('iframe');if(ifrs){for(i=0;i<ifrs.length;i++){d=ifrs[i].contentWindow.document;f(d)}}};f(document)})();
#!/bin/sh
# Determine which packages exist in the current MSYS2 environment
# Intended to be used in Git-for-Windows
export OUTDIR=$PWD
wget http://repo.msys2.org/msys/x86_64/msys.files.tar.gz
mkdir -p pacman-local msys-files
tar -xf msys.files.tar.gz -C msys-files
function file2pkg () {
# Find the corresponding package folder and move it to $PWD/pacman-local/
@gdlmx
gdlmx / Sci_workflow_management.md
Last active April 26, 2023 16:55
Scientific workflow management systems
@gdlmx
gdlmx / HTTP_client_UNIX_socket.md
Last active January 20, 2024 13:24
HTTP over UNIX domain sockets
@gdlmx
gdlmx / ANSI_color_demo.py
Created February 5, 2018 19:02
Print ANSI Color in Python
#!/usr/bin/env python
import os,sys
class BCOLOR:
if sys.stdout.isatty():
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
@gdlmx
gdlmx / DisableUWPStartupTask.ps1
Created April 21, 2018 12:41
Disable Startup Task of Windows UWP
# Windows task manager cannot disable some auto startup UWP Apps
# This script provides an alternative method to disable those Apps
# Refs:
# https://docs.microsoft.com/en-us/uwp/api/windows.applicationmodel.startuptask
# Author: Mingxuan Lin
function DisableUWPStartupTask ([String]$Name) {
$p = Get-AppxPackage -Name $Name
$PkgFN=$p.PackageFamilyName
Get-Item -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\$PkgFN\*StartupTask" | foreach {
@gdlmx
gdlmx / check-Alien-Owner.ps1
Last active May 2, 2018 17:33
Powershell recipes
Param(
[string]$containerPath,
[string]$OwnerName
)
gci -recurse $containerPath | ? { $_.PSIsContainer -eq $False } | ? { (Get-ACL -LiteralPath $_.FullName).Owner -ne $OwnerName }
@gdlmx
gdlmx / abaqus_python
Last active May 3, 2018 00:18
Abaqus Python
#!/bin/bash
# module load abaqus #dependencies#
ABQHOME=/opt/abaqus6/2017a
export LD_LIBRARY_PATH="${ABQHOME}/SIMULIA/CAE:${ABQHOME}/SIMULIA/CAE/linux_a64:${ABQHOME}/SIMULIA/CAE/linux_a64/code:${ABQHOME}/SIMULIA/CAE/linux_a64/code/bin:${ABQHOME}/SIMULIA/CAE/linux_a64/code/bin/SMAExternal:${ABQHOME}/SIMULIA/CAE/linux_a64/CAEresources:${ABQHOME}/SIMULIA/CAE/linux_a64/SMA:${ABQHOME}/SIMULIA/CAE/linux_a64/code/bin/SMAExternal/Interop:${ABQHOME}/SIMULIA/CAE/linux_a64/code/bin/SMAExternal/Elysium:${ABQHOME}/SIMULIA/CAE/linux_a64/tools/SMApy/python2.7/lib/python2.7/lib-dynload:${ABQHOME}/SIMULIA/installation:${ABQHOME}/SimulationServices/V6R2017x/linux_a64/code/bin:$LD_LIBRARY_PATH"
export PATH="${ABQHOME}/SIMULIA/CAE/linux_a64/code/bin/:$PATH"
export PYTHONPATH="${ABQHOME}/SIMULIA/CAE:${ABQHOME}/SIMULIA/CAE/linux_a64:${ABQHOME}/SIMULIA/CAE/linux_a64/code:${ABQHOME}/SIMULIA/CAE/linux_a64/code/bin:${ABQHOME}/SIMULIA/CAE/linux_a64/code/bin/SMAExternal:${ABQHOME}/SIMULIA/CAE/linux_a64/CAEresources:${ABQHOME}/SIMULIA/C
@gdlmx
gdlmx / build-DAMASK.sh
Last active July 21, 2023 11:48
Build script for DAMASK v2.0.2
#!/bin/bash
set -e
#INTELROOT=$( which ifort | sed -e 's:bin/\w*/*ifort::' )
#source $INTELROOT/bin/compilervars.sh intel64
function getsrc () {
local filename=$(basename "$1")
local dirname=${filename%%-*}
[ -d ${dirname}*/ ] || ( wget "$1" && tar -xf "$filename" && rm "$filename" )
@gdlmx
gdlmx / mount-net-drive.ps1
Created May 26, 2018 12:55
Mount Network Drive
$cred_file = "${env:\userprofile}\net-drive-cred.xml"
function GetCredentialFromVault([String]$domain ) {
$x = $domain -split "@//"
$UserName = $x[0]
Try{
$vault = Import-CliXml -Path $cred_file
} Catch [System.IO.FileNotFoundException]{
$vault = @{}