Skip to content

Instantly share code, notes, and snippets.

View zypA13510's full-sized avatar

Yuping Zuo zypA13510

  • China
  • 07:18 (UTC +08:00)
View GitHub Profile
@robm82
robm82 / intuneps-x64.ps1
Created October 5, 2020 16:01
Script to run Intune Win32 PowerShell scripts in 64-bit context
# Many thanks to Z-NERD for this, and this script is a copy of the one provided on his website
# Here is a link to the original script: https://z-nerd.com/blog/2020/03/31-intune-win32-apps-powershell-script-installer/
# This is here just in case the post gets removed/lost :)
$argsString = ""
If ($ENV:PROCESSOR_ARCHITEW6432 -eq "AMD64") {
Try {
foreach($k in $MyInvocation.BoundParameters.keys)
{
switch($MyInvocation.BoundParameters[$k].GetType().Name)
#!/bin/bash
sudo bash -c "sync \
&& apt-get update \
&& apt-get -y upgrade \
&& apt-get -y dist-upgrade \
&& sed -i 's/stretch/buster/g' /etc/apt/sources.list \
&& sed -i 's/stretch/buster/g' /etc/apt/sources.list.d/raspi.list \
&& apt-get update \
&& apt-get -y upgrade \
&& apt-get -y dist-upgrade \
@jamesfreeman959
jamesfreeman959 / keepawake.ps1
Last active April 30, 2025 20:49
A very simple PowerShell script to keep a Windows PC awake and make lync think the user is active on the keyboard
# Useful references:
#
# https://superuser.com/questions/992511/emulate-a-keyboard-button-via-the-command-line
# https://ss64.com/vb/sendkeys.html
# https://social.technet.microsoft.com/Forums/windowsserver/en-US/96b339e2-e9da-4802-a66d-be619aeb21ac/execute-function-one-time-in-every-10-mins-in-windows-powershell?forum=winserverpowershell
# https://learn-powershell.net/2013/02/08/powershell-and-events-object-events/
#
# Future enhancements - use events rather than an infinite loop
$wsh = New-Object -ComObject WScript.Shell
while (1) {
@kekru
kekru / add CA cert on CentOS Debian Ubuntu.md
Last active December 30, 2024 09:31
Add CA cert to local trust store on CentOS, Debian or Ubuntu
  • Open a webpage that uses the CA with Firefox
  • Click the lock-icon in the addressbar -> show information -> show certificate
  • the certificate viewer will open
  • click details and choose the certificate of the certificate-chain, you want to import to CentOS
  • click "Export..." and save it as .crt file
  • Copy the .crt file to /etc/pki/ca-trust/source/anchors on your CentOS machine
  • run update-ca-trust extract
  • test it with wget https://thewebsite.org
@kacchan822
kacchan822 / softethervpn_letsencrypt_cert_autoupdate.sh
Last active July 3, 2024 01:26
softethervpn_letsencrypt_cert_autoupdate.sh
#!/bin/bash
#
# Copyright (c) 2016 Katsuya SAITO
# This software is released under the MIT License.
# http://opensource.org/licenses/mit-license.php
#
# @(#) softethervpn_letsencrypt_cert_autoupdate.sh ver.0.1.0 2016.02.20
#
# Usage: softethervpn_letsencrypt_cert_autoupdate.sh CommonName WEBROOT PASSWORD MAIL
#
@scy
scy / opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md
Last active March 27, 2025 04:09
Opening and closing an SSH tunnel in a shell script the smart way

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@jcbozonier
jcbozonier / gist:1692807
Created January 28, 2012 05:17
Using a date reviver in JSON.parse
function dateReviver(key, value) {
if (typeof value === 'string') {
var a = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
if (a) {
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]));
}
}
return value;
};
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@knu
knu / gist:111055
Created May 13, 2009 14:38
How to mass-rename tags and push them with Git
# Rename tags named foo-bar-#.#.# to v#.#.# and push the tag changes
git tag -l | while read t; do n="v${t##*-}"; git tag $n $t; git push --tags ; git tag -d $t; git push origin :refs/tags/$t ; done