Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View binaryPUNCH's full-sized avatar
🐍
few hours of trial & error can save you several minutes of looking at the README

Paul Robert W. binaryPUNCH

🐍
few hours of trial & error can save you several minutes of looking at the README
View GitHub Profile
@binaryPUNCH
binaryPUNCH / allow-powerbi-publicip-firewall-to-azure.ps1
Last active April 27, 2021 07:30
Azure PowerBI public ip allow in network security group firewall
# SEO: azure powerbi public ip allow in network security group firewall
# this code will get the latest Azure public IP's from Azure public cloud for PowerBI, and allow them to connect on port 5432 postgresql
# feel free to copy-paste for your needs.
# MS doesn't have a static URL or API for the latest IP's, so this script will find the right URL
# MS doesn't support Azure CLI from a Powershell Azure Function. I ended up running this as an Azure DevOps pipeline with a cron schedule every day.
# star this if it was useful for you :)
function Throw-WhenError {
param (
[string]
function Get-User($user)
{
# this function should be passed the CN of the user to be returned
$dom = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
$root = [ADSI] "LDAP://$($dom.Name)"
$searcher = New-Object System.DirectoryServices.DirectorySearcher $root
$searcher.filter = "(&(objectCategory=person)(objectClass=user)(cn=$user))"
$user = $searcher.FindOne()
[System.Collections.Arraylist]$names = $user.Properties.PropertyNames
[System.Collections.Arraylist]$props = $user.Properties.Values
@binaryPUNCH
binaryPUNCH / example.ts
Created January 17, 2019 08:08
Angular reconnect for SignalR Core js
import { Component, OnInit, OnDestroy } from "@angular/core";
import { HubConnection, HubConnectionBuilder } from '@aspnet/signalr';
@Component({
selector: "app-my",
templateUrl: "./my.component.html",
styleUrls: ["./my.component.scss"],
})
export class MyComponent implements OnInit, OnDestroy {
private hubConnection: HubConnection;
@binaryPUNCH
binaryPUNCH / db.tf
Last active September 16, 2018 15:15
resource "aws_rds_cluster" "default" {
cluster_identifier = "moulding-cluster-${terraform.workspace}"
availability_zones = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
database_name = "MouldingCloudDb_${terraform.workspace}"
master_username = "${var.rds-user}"
master_password = "${var.rds-password}"
skip_final_snapshot = true
vpc_security_group_ids = ["${aws_default_security_group.default.id}"]
db_subnet_group_name = "${aws_db_subnet_group.default.id}"
}
@binaryPUNCH
binaryPUNCH / aws-config-deleteallrules.ps1
Last active September 29, 2021 11:40
Quick'n'dirty PowerShell script to delete ALL rules for "AWS Config". Yeah, cause that's hella expensive apparently and the Management Console doesn't allow you to delete them all at once... This obviously relies on the AWS CLI.
# DANGER. DON'T RUN UNLESS YOU REALLY WANT TO DELETE ALL YOUR AWS CONFIG RULES.
$deserialized = aws configservice describe-config-rules | ConvertFrom-Json
$arr = $deserialized.ConfigRules | select -ExpandProperty ConfigRuleName
foreach($x in $arr) {
# if your API keys aren't setup you may want to add them in the script
aws configservice delete-config-rule --config-rule-name $x | write-host
}
@binaryPUNCH
binaryPUNCH / cloudSettings
Last active July 18, 2017 10:48
Visual Studio Code Sync Settings Gist
{"lastUpload":"2017-07-18T10:48:01.484Z","extensionVersion":"v2.8.2"}
@binaryPUNCH
binaryPUNCH / Program.cs
Last active January 15, 2017 18:42
Probability Calculations... This can definitely be way simplified
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace StatisticCalculations
{
public class Program
{
// Sending client
private void UpdateServer()
{
string headJSON = JsonConvert.SerializeObject(head); // head is class for the snake's head object
byte[] msg = Encoding.ASCII.GetBytes(headJSON);
int bytesSent = socketSender.Send(msg);
}
// Receiving-end socket listener
byte[] bytes = new byte[1024];
// nu med c# stack
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@binaryPUNCH
binaryPUNCH / RedditComments-LinkScraper.py
Last active November 6, 2015 08:40
Super simple URL/link scraper for any Reddit comment thread, enjoy! Requires PRAW and BeautifulSoup4, only tested on Python 2.7
# Super simple URL/link scraper for any Reddit comment thread, enjoy!
# Requires PRAW and BeautifulSoup4, only tested on Python 2.7
threadID = "3rns3d" # Change threadID to the one you wish to scrape (hint: the ID is in the url)
import praw
import codecs
import pprint
import HTMLParser
from bs4 import BeautifulSoup