Skip to content

Instantly share code, notes, and snippets.

View dragon788's full-sized avatar

dragon788 dragon788

View GitHub Profile
@dragon788
dragon788 / README.md
Created June 27, 2017 15:26 — forked from pdanford/README.md
Applescript to launch iTerm2 Version 3+ from OS X Finder via keyboard shortcut or Toolbar

Description

Based on info from http://peterdowns.com/posts/open-iterm-finder-service.html but with modified behavior and fixed to work with iTerm2 version 3 or later. It will not work with older versions of iTerm. The modified behavior is to open a new terminal window for each invocation instead of reusing an already open window. Update - The original author released a build script for the newer iTerm2 versions at https://github.com/peterldowns/iterm2-finder-tools that keeps the original behavior of reusing an open iTerm2 window.

To open iTerm2 at selected folder with keyboard shortcut

  1. Run Automator, select a new Service
  2. Select Utilities -> Double click ‘Run AppleScript’
  3. Service receives selected 'folders' in 'finder.app'
  4. Paste script:
#!/bin/sh
# i3-get-window-criteria - Get criteria for use with i3 config commands
# To use, run this script, then click on a window.
# Output is in the format: [<name>=<value> <name>=<value> ...]
# Known problem: when WM_NAME is used as fallback for the 'title="<string>"' criterion,
# quotes in "<string>" are not escaped properly. This is a problem with the output of `xprop`,
# reported upstream: https://bugs.freedesktop.org/show_bug.cgi?id=66807
@dragon788
dragon788 / openvpn_gen.py
Created May 31, 2017 20:51 — forked from Justasic/openvpn_gen.py
This is a python script to generate client OpenVPN configuration files. This is based mostly on the easyrsa script and is much simpler to understand.
import os
import socket
from OpenSSL import crypto, SSL
# OpenVPN is fairly simple since it works on OpenSSL. The OpenVPN server contains
# a root certificate authority that can sign sub-certificates. The certificates
# have very little or no information on who they belong to besides a filename
# and any required information. Everything else is omitted or blank.
# The client certificate and private key are inserted into the .ovpn file
# which contains some settins as well and the entire thing is then ready for
@dragon788
dragon788 / invoke-expression-with-args.ps1
Created April 13, 2017 15:08
Invoke Expression against web script AND pass in arguments
$scriptPath = ((new-object net.webclient).DownloadString('https://gist.githubusercontent.com/AndrewSav/c4fb71ae1b379901ad90/raw/23f2d8d5fb8c9c50342ac431cc0360ce44465308/SO33205298'))
Invoke-Command -ScriptBlock ([scriptblock]::Create($scriptPath)) -ArgumentList "coucou"
@dragon788
dragon788 / Get-Ping.ps1
Created April 12, 2017 16:22
Robust PowerShell ping with error checking :P
function Get-Ping ($url) {
$timeout = 500
$ping = new-object system.net.networkinformation.ping
try {
# The @() ensures the return if a single string is still an array
$urlArray = @($url.split(' ') | where { $_ -ne "-" })
#"urlArray = $urlArray"
$url = $urlArray[0]
#$url
$ip = $urlArray[1]
@dragon788
dragon788 / git-get-files-by-size.py
Created March 28, 2017 19:06 — forked from punkdata/git-get-files-by-size.py
Git this script lists the files that are larger than the size you specify. Example use: python git-find-big-files.py fix-remove-files 1000000 (file size in MBs)
#!/usr/bin/python
# run the script: python git-find-big-files.py <the branch> <file size>
# Example use: python git-find-big-files.py fix-remove-files 1000000 (this value equals 1 Megabyte)
# the Fix-remove-files specifies the branch that you are cleaning
import os, sys
def getOutput(cmd):
return os.popen(cmd).read()
#http://askubuntu.com/questions/379123/can-i-zoom-out-windows-or-scale-the-whole-desktop
xrandr --output LVDS1 --mode 1920x1080 --scale 2x2 --fb 3840x2160 --panning 3840x2160
# 3k
# xrandr --output LVDS1 --mode 1920x1080 --scale 1.5x1.5 --fb 2880x1620 --panning 2880x1620
@dragon788
dragon788 / ConvertFrom-JsonToCsv.ps1
Last active March 8, 2017 19:37 — forked from dfinke/ConvertFrom-JsonToCsv.ps1
Using PowerShell to Convert From JSON to CSV format
function ConvertFrom-JsonToCsv {
param(
[Parameter(ValueFromPipeline)]
$json
)
Process {
($json | ConvertFrom-Json) | ConvertTo-Csv -NoTypeInformation
}
}
@dragon788
dragon788 / import-portatour.ps1
Created December 9, 2016 00:56 — forked from weipah/import-portatour.ps1
PowerShell V3 Multipart/formdata example with REST-API (Invoke-RestMethod)
function Import-Portatour {
param (
[parameter(Mandatory=$True,Position=1)] [ValidateScript({ Test-Path -PathType Leaf $_ })] [String] $FilePath,
[parameter(Mandatory=$False,Position=2)] [System.URI] $ResultURL
)
# CONST
$CODEPAGE = "iso-8859-1" # alternatives are ASCII, UTF-8
# We have a REST-Endpoint
$RESTURL = "https://my.portatour.net/a/api/ImportCustomers/"
@dragon788
dragon788 / longwindedname.md
Created November 25, 2016 23:39
Restore rEFInd as default boot manager from Windows after updates

After losing access to rEFInd yet again (Windows 10 Anniversary Edition), I was able to find the proper invocation of BCDEdit thanks to a helpful person on StackOverflow. None of the Microsoft documentation mentions this, but you NEED single quotes around {bootmgr} for sure if you are in the PowerShell shell, but possibly also if you are in the Command Prompt. This allowed me to add a new entry for rEFInd and I've had to do this multiple times so I know it works on Windows 10.

bcdedit /set {bootmgr} path \EFI\refind\refind_x64.efi 

becomes

bcdedit /set '{bootmgr}' path \EFI\refind\refind_x64.efi