Skip to content

Instantly share code, notes, and snippets.

Avatar

Sid Shetye SidShetye

View GitHub Profile
@SidShetye
SidShetye / update-cloudflare.sh
Last active May 8, 2020
a shell script to update cloudflare's DNS record
View update-cloudflare.sh
#!/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 Apr 22, 2020
script for system info on Rasbperry Pi
View sysinfo.sh
#!/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 Nov 7, 2018 — 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.
View whatFilesHaveIShared.gs
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 Jun 25, 2018
To get application insight emails on a weekly basis. rename to run.csx when moving into azure functions
View run-applicationinsights-weeklyemails.csx
#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 Oct 5, 2017
Modified to pluck tag from end of stream automatically
View BCryptAuthenticatedSymmetricCryptoTransform.cs
// 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 Aug 14, 2020
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.
View ExportAlbumAsFolder.applescript
------------------------------------------------
-- 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 Dec 9, 2016
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
View Get-BuildDateFromVersion.ps1
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 Sep 5, 2020
Powershell script to download files on Windows Server Nano where Invoke-Webrequest/wget are natively missing
View wget.ps1
<#
.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 Jan 15, 2020
Script to harden SSL/TLS on Azure Cloud Service
View HardenSSL.ps1
# 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 = @(
View Entropy.cs
public class Entropy
{
private const long Prime = 179426549;
private const long Prime2 = 46633; // another prime
public static long GetEntropySeed()
{
return Ticks ^ ProcessInfoKey() ^ MemorySizeKey() ^ EnvironmentKey();
}
You can’t perform that action at this time.