Skip to content

Instantly share code, notes, and snippets.

View staybox's full-sized avatar

Andrey Vanik staybox

  • Moscow
View GitHub Profile
@staybox
staybox / powershell-non-domain-remoting.md
Created June 26, 2020 20:44 — forked from cmcginty/powershell-non-domain-remoting.md
Windows Powershell Remoting into Non-Domain Joined System

Powershell Remoting to a Non-Domain Host

  1. From an admin shell, enable PS remoting on the machine you wish to access:
New-ItemProperty -Name LocalAccountTokenFilterPolicy `
  -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System `
  -PropertyType DWord -Value 1

Enable-PsRemoting -Force
<?php
/**
* Class for interacting with an SMB server using the system command "smbclient".
* Of course this assumes that you have the smbclient executable installed and
* in your path.
*
* It is not the most efficient way of interacting with an SMB server -- for instance,
* putting multiple files involves running the executable multiple times and
* establishing a connection for each file. However, if performance is not an
* issue, this is a quick-and-dirty way to move files to and from the SMB
@staybox
staybox / ks.cfg.trusty
Created December 20, 2018 19:16 — forked from chusiang/ks.cfg.trusty
Kickstart script for Ubuntu 14.04
# ====================================================================
# Author: 凍仁翔 / chusiang.lai (at) gmail.com
# Blog: http://note.drx.tw
# Filename: ks.cfg.
# Modified: 2015-02-25 10:20
# Description: Kickstart Configurator for Ubuntu 14.04.1 LTS server (amd64)
# Reference:
#
# 1. 作業系統自動安裝應答 CD 製作 - kickstart | iThome Download
# - http://download.ithome.com.tw/article/index/id/1792
#!/usr/bin/env php
<?php
/////////////////////
// slack2html
// by @levelsio
/////////////////////
//
/////////////////////
// WHAT DOES THIS DO?
/////////////////////
<?
/////////////////////
// slack2html
// by @levelsio
/////////////////////
//
/////////////////////
// WHAT DOES THIS DO?
/////////////////////
//
@staybox
staybox / ParensParser.php
Created December 26, 2017 02:17 — forked from xeoncross/ParensParser.php
PHP: Nested Parenthesis Parser
<?php
// @rodneyrehm
// http://stackoverflow.com/a/7917979/99923
class ParensParser
{
// something to keep track of parens nesting
protected $stack = null;
// current level
protected $current = null;
@staybox
staybox / compress-pdf-with-gs.md
Created February 14, 2017 13:49 — forked from vibegui/compress-pdf-with-gs.md
Compress PDF files with ghostscript

This can reduce files to ~15% of their size (2.3M to 345K, in one case) with no obvious degradation of quality.

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Other options for PDFSETTINGS:

  • /screen selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting.
  • /ebook selects medium-resolution output similar to the Acrobat Distiller "eBook" setting.
  • /printer selects output similar to the Acrobat Distiller "Print Optimized" setting.
  • /prepress selects output similar to Acrobat Distiller "Prepress Optimized" setting.
@staybox
staybox / Timeout.ps1
Created December 12, 2016 11:46 — forked from lazywinadmin/Timeout.ps1
Timeout in powershell
#requires -Version 2
$maximumRuntimeSeconds = 3
$process = Start-Process -FilePath powershell.exe -ArgumentList '-Command Start-Sleep -Seconds 4' -PassThru
try
{
$process | Wait-Process -Timeout $maximumRuntimeSeconds -ErrorAction Stop
Write-Warning -Message 'Process successfully completed within timeout.'