Skip to content

Instantly share code, notes, and snippets.

View SidShetye's full-sized avatar

Sid Shetye SidShetye

View GitHub Profile
@SidShetye
SidShetye / update-cloudflare.sh
Last active June 9, 2021 12:04
a shell script to update cloudflare's DNS record
#!/bin/sh
# This is probably better implemented in a real scripting language like powershell script or javascript but
# as a shell script to take minimal dependencies
###### Inputs - change these per your use case
# Go get Zone ID and account ID, log into the CF dashboard -> domain -> overview -> left column, bottom part
zone_identifier=000000000000000000000000000000
# The record we want to update
dns_name=example.com
@SidShetye
SidShetye / sysinfo.sh
Last active April 22, 2020 03:41
script for system info on Rasbperry Pi
#!/bin/sh
echo "Temperature ....: $(vcgencmd measure_temp | sed 's/.*=//')"
echo "Memory .........: $(free -h | grep Mem | awk '{print $4 " free out of " $2}')"
echo "Storage ........: $(df -H | grep "/$" | awk '{print $4 " free out of " $2}')"
echo "Uptime .........: $(uptime -p)"
echo "CPU Frequency ..: $(($(vcgencmd measure_clock arm | sed 's/^.*=//')/1000000)) MHz"
@SidShetye
SidShetye / whatFilesHaveIShared.gs
Created November 7, 2018 19:13 — forked from danjargold/whatFilesHaveIShared.gs
Google script to list (on a Google Sheet) all files shared in your google drive, including all viewers, editors, and sharing permissions. Credit goes to @woodwardtw (https://gist.github.com/woodwardtw/22a199ecca73ff15a0eb) as this is an improvement on his code which only assesses a single folder and one level of sub-folders down.
function listFolders(folder) {
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Name", "Sharing Access", "Sharing Permission", "Get Editors", "Get Viewers", "Date", "Size", "URL", "Download", "Description", "Type"]); //writes the headers
//var folder = DriveApp.getFolderById("INSERT_YOUR_FILE_ID");//that long chunk of random numbers/letters in the URL when you navigate to the folder
//getLooseFiles(folder, sheet);
//getSubFolders(folder, sheet);
//instead of getting folder by ID rather get all folders and cycle through each. Note this will miss loose files in parent directory.
var folder = DriveApp.getFolders()
@SidShetye
SidShetye / run-applicationinsights-weeklyemails.csx
Last active January 5, 2021 17:34
To get application insight emails on a weekly basis. rename to run.csx when moving into azure functions
#r "Newtonsoft.Json"
using System.Configuration;
using System.Net.Mail;
using System.Net.Mime;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
private const string AppInsightsApi = "https://api.applicationinsights.io/beta/apps";
@SidShetye
SidShetye / BCryptAuthenticatedSymmetricCryptoTransform.cs
Created October 5, 2017 23:14
Modified to pluck tag from end of stream automatically
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Originally from CLR Security licensed by Microsoft under MIT License
// Modified by Crypteron under MIT License
//
// changelog
// - Make decrypt symmetrical with encrypt by keeping tag at the end
// of ciphertext. This oddity requires some buffer management
// but better to do internally here than expect all users to
// perform tricky buffer management themselves.
@SidShetye
SidShetye / ExportAlbumAsFolder.applescript
Last active February 1, 2021 14:24
Scan through all albums and export media items (movies, images etc) into a suitable folder. There is custom logic to pick the appropriate destination folder.
------------------------------------------------
-- Settings Start: Change these as needed
global gDest
set gDest to "/Volumes/MacPhotos/Pictures/ExportAlbums/" as POSIX file as text -- the destination folder (use a valid path)
global gLogFile
set gLogFile to gDest & "ExportAlbumToFolders.log"
global gKeywordOnSuccess
set gKeywordOnSuccess to "exported"
@SidShetye
SidShetye / Get-BuildDateFromVersion.ps1
Created December 9, 2016 00:28
In .NET builds auto-increment if your code specified build versions like "1.2.*". This powershell script goes the reverse and helps find the date of release given a version number
Param(
[Version] $Version ="1.2.5678.6432"
)
# Usage as 'Get-BuildDateFromVersion.ps1 -Version 1.2.3.4'
# Intentionally written in verbose mode, line by line
# From https://msdn.microsoft.com/en-us/library/system.reflection.assemblyversionattribute.aspx and
# http://stackoverflow.com/questions/13943456/what-is-the-formula-in-net-for-wildcard-version-numbers
# Build = DateTime.Today.Subtract(new DateTime(2000, 1, 1)).Days;
@SidShetye
SidShetye / wget.ps1
Last active March 27, 2024 15:16
Powershell script to download files on Windows Server Nano where Invoke-Webrequest/wget are natively missing
<#
.SYNOPSIS
Downloads a file
.DESCRIPTION
Downloads a file
.PARAMETER Url
URL to file/resource to download
.PARAMETER Filename
file to save it as locally
.EXAMPLE
@SidShetye
SidShetye / HardenSSL.ps1
Last active August 14, 2023 14:59
Script to harden SSL/TLS on Azure Cloud Service
# Call this from inside a startup task/batch file as shown in the next two lines (minus the '# ')
# PowerShell -ExecutionPolicy Unrestricted .\HardenSsl.ps1 >> log-HardenSsl.txt 2>&1
# EXIT /B 0
# Credits:
# http://azure.microsoft.com/blog/2014/10/19/how-to-disable-ssl-3-0-in-azure-websites-roles-and-virtual-machines/
# http://lukieb.blogspot.com/2014/11/tightening-up-your-azure-cloud-service.html
$nl = [Environment]::NewLine
$regkeys = @(
public class Entropy
{
private const long Prime = 179426549;
private const long Prime2 = 46633; // another prime
public static long GetEntropySeed()
{
return Ticks ^ ProcessInfoKey() ^ MemorySizeKey() ^ EnvironmentKey();
}