Skip to content

Instantly share code, notes, and snippets.

-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFVwoygBEADPrzQqfGJqe0mcyLV86A9qHqZpmAcE7hrnPBHIjrqFL0y5mSWj
sZSnAY49zqBHs1t7SiNGfFE1F8tY+pYLfcJ4/lUxkK+Ti4kNEvSViEtGamiW5T8d
oe/XUz5PwLKrjnqt3F5CVHk+sfNoQY8PxIpfkR/QXBrCOOE7T0+dYzjECP/na26e
TC7fAnjSLbp0tSyU5aNpmk5plXL/tyC7SP/L/bCNihSKmwP3la8kt0JmY4p+OqqA
FM3xbn8vAkpZepa5H1pN7C/uDN2Th7v8nMfYIj9/Frl1WTJ5hhQSE1E93DX9ooJ5
aS3w4U3vbN+YPGsy/kIPnVfSobW40boK/Ad4Tnc/CEjzw3uueLnLg4BgpcMHHGzb
tgOK7MVDt4YcBs0z2Bi2Wd5ai8JGi00V5rIbtctH9cmiNDu/naDfxNduVC/QsPpu
AeaMZ6XXF//1uPF8R5Q0ROrKGzNmcuLO0jyj9tZiwmjEIuadKBviiva6swcReSis
@ProTip
ProTip / mask.cs
Created March 12, 2019 17:25
Mask position conversion
for(int w = 0; w < width; w++) {
for(int h = 0; h < height; h++) {
maskPos = w * height + h;
colorPos = h * width + w;
colorMask[colorPos] = mask[maskPos];
}
}
@ProTip
ProTip / gist:1f10b967e9803a4119d091d0a7ea7aa1
Created March 6, 2019 18:20
Rundeck, Inc. Signing Public PGP
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQGNBFx+qG0BDADE045yW13qvYZKn3nuNwGWcnHTPMbmDpFVOXtyYz2C3wFfQoKB
sEjig4Njxg8L3Uy7Mb3WfHYQjsYmU+WbblSdA0JFdshblbp8KgZWvcxcOQg6rxcG
tfSfLonHxtaf4FEXGJyq1HM8VsS4rhIRWcemQ4pP+8e4ZOJ4SAMEn+2g3xndvOOw
xgHxZGDNWlZN6wvI69qRbzmAaHEitgm1luIY0UIo3Olhakp5WosLT4Z+N5rMsON9
HynjRJAklWAcFesibuyPUdoe775opnbIAUiQt/yA2t2aDK3/w/hDmGpRtNorxl2e
4DLk+jQ5r7mzDaWGw4za3Z7A+aDXHh7j5ufIYZ8okuWF6NYTKgNZfIA8CQ0W4No+
nP7Dcl2RzvsEKPR/EJBrhKypMckrMOLQMVRQSoR1E75aTdFylfbJjYzyuzFZLkXz
v1Nvn0zNFo4sOaQQuXpJ2u30JMDZZRAev/2IClgQjnjrvqKFUUec5BRitTBj/LUI
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import {observer} from "mobx-react";
@observer
class TodoListView extends Component {
render() {
return <div>
<ul>
{this.props.todoList.todos.map(todo =>
Promise = require "bluebird"
async = Promise.coroutine
AsyncError = async ->
throw new Error "AThrower exceptinon."
yield return
NestedAsyncError = async ->
yield do async ->
class Chef
class Recipe
class ProTip
class StreamReader
require 'stringio'
def initialize
@callbacks = Hash.new { |h, k| h[k] = [] }
@buffer = StringIO.new
end
cmd = powershell_out("Get-NetFirewallRule -DisplayName 'Block AWS Metadata'")
case cmd.exitstatus
when 1
powershell_out!("New-NetFirewallRule -DisplayName 'Block AWS Metadata' -Action Block -Direction 'outbound' -RemoteAddress '169.254.169.254' -RemotePort '80' -Protocol 'tcp' | Get-NetFirewallSecurityFilter | Set-NetFirewallSecurityFilter -LocalUser 'O:LSD:(D;;CC;;;SY)(D;;CC;;;LA)'")
when 0
powershell_out!("Set-NetFirewallRule -DisplayName 'Block AWS Metadata' -Action Block -Direction 'outbound' -RemoteAddress '169.254.169.254' -RemotePort '80' -Protocol 'tcp' ")
powershell_out!("Get-NetFirewallRule -DisplayName 'Block AWS Metadata' | Get-NetFirewallSecurityFilter | Set-NetFirewallSecurityFilter -LocalUser 'O:LSD:(D;;CC;;;SY)(D;;CC;;;LA)' ")
end
powershell_script 'firewall_metadata' do
guard_interpreter :powershell_script
code "New-NetFirewallRule -DisplayName 'Block AWS Metadata' -Direction 'outbound' -RemoteAddress '169.254.169.254' -RemotePort '80' -Protocol 'tcp' | Get-NetFirewallSecurityFilter | Set-NetFirewallSecurityFilter -LocalUser 'O:LSD:(D;;CC;;;SY)'"
not_if "Get-NetFirewallRule -DisplayName 'Block AWS Metadata'"
end
var field = "This is an error message about windows"
func main(){
fmt.Println("Hello World")
matcher := regexp.MustCompile(`(windows)|(bob)|(error)`)
matches := matcher.FindAllStringSubmatch(field,-1)
fmt.Println(matches)
#######################################
func ParseBillingPeriodDate(s string, report *BillingReport) interface{} {
var returnTime time.Time
var err error
switch s { case "":
returnTime = report.InvoicePeriod
default:
returnTime, err = time.Parse("2006/01/02 15:04:05", s)
if err != nil { panic(err.Error()) }
}
return returnTime.Format(time.RFC3339)