This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (* ::Package:: *) | |
| (* ::Input:: *) | |
| (*a={0,0,0}*) | |
| (*b={1,0,0}*) | |
| (*c={1,1,0}*) | |
| (*d={0,1,0}*) | |
| (*e={0,0,1}*) | |
| (*f={1,0,1}*) | |
| (*g={1,1,1}*) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-XKCDComic { param ($n,$file); $h="https:"; iwr "$h$(((iwr "$h//xkcd.com/$n").images)[1].src)" -out $file } # Saves XKCD #n to a file | |
| function Get-XKCDCurrentIssueNo { (iwr "https://xkcd.com").RawContent -match "Permanent link to this comic: https://xkcd.com/(?<N>\d+)" | Out-Null; return [int]$matches["N"] } | |
| # Running Project Oxford APIs | |
| # Inspired by https://jamessdixon.wordpress.com/2016/12/25/age-and-sex-analysis-of-microsoft-usa-mvps/ | |
| # In Powershell | |
| # Get Subscription key at https://www.microsoft.com/cognitive-services/en-US/subscriptions | |
| #Modifying for XKCD recognition |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $jsontemplate = @' | |
| { | |
| "requests":[ | |
| { | |
| "image":{ | |
| "content":"/9j/7QBEUGhvdG9...image contents...eYxxxzj/Coa6Bax//Z" | |
| }, | |
| "features":[ | |
| { | |
| "type":"LABEL_DETECTION", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function Get-GroupChanges { | |
| Param( | |
| $group = "Domain Admins", | |
| $server = (Get-ADDomainController).HostName, | |
| $hours = 4 | |
| ) | |
| $adgroupobject = Get-ADGroup $group | |
| $memberchanges = Get-ADReplicationAttributeMetadata -Object $adgroupobject.DistinguishedName -Server $server -ShowAllLinkedValues | ? AttributeName -eq "Member" | ? LastOriginatingChangeTime -gt (Get-Date).AddHours(-1 * $Hours) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This code relies on gcloud present in the path and authenticated with permissions to read folders | |
| # The output is Terraform HCL code in the .tf file and shell code to import the discovered resources in the .sh file | |
| # Similar approach can be used to survey other type of resources | |
| gcloud organizations list --format='json' | ConvertFrom-JSON -OutVariable org | |
| if (!$?) { throw "Error invoking gcloud" } # Rudimentary error handling - throw terminating error if gcloud errors out in any way | |
| $seed = $org.name.split("/")[1] | |
| $folders = @() # Starting with empty array, to be populated with org-level folders |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Runs in Julia 0.6.2. For Julia 1.0 code, refer to my Julia-Playground repo | |
| # Also, implementation of the bracket matching code isawful. What was I thinking about? | |
| bfcode = ", [ > + < - ] > ." | |
| cells = [0 for i=1:30000] | |
| bfcode = replace(bfcode, r"[^\+\-\<\>\.\,\[\]]", "") # Eliminating all extranious characters in the code | |
| # Initial processing: identifying pairs of [ and ], and populating two arrays with indexes (positions of the brackets in the bf code) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (* ::Package:: *) | |
| (* ::Text:: *) | |
| (*First, let's take a look at the data for the Hertzsprung-Russell diagram. Following example from https://mathematica.stackexchange.com/questions/125681/how-can-i-plot-the-h-r-diagram-of-stars*) | |
| (**) | |
| (* ::Input:: *) | |
| (*stardata=SemanticImport["/home/pi/g3.csv"]*) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $project = "your-gcp-project" | |
| $accesstoken = gcloud auth print-access-token # Lazy way. Can also get access token using service account and 2LO - ref. https://gist.github.com/SP3269/da43b00692de5b3f591b3068d76df577 | |
| # Using Google BigQuery REST API per https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query | |
| # Example query using public dataset available to anyone in BQ | |
| $query = 'SELECT * FROM `bigquery-public-data.san_francisco_trees.street_trees` WHERE plant_date >= "1969-01-01 00:00:00 UTC" AND plant_date < "1970-01-01 00:00:00 UTC"' | |
| $body = @{ | |
| useLegacySql = "false" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $game20200305 = @' | |
| 44 | |
| 61 | |
| 65 | |
| 63 | |
| 41 | |
| 45 | |
| 22 | |
| 63 | |
| 23 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // A Web server with two endpoints - /stable (returning 200) and /unstable (going into failing state with defined probability every tick and returning 500 while in it) | |
| // Based on Googles slo-burn code https://github.com/google/prometheus-slo-burn-example/tree/master/server | |
| package main | |
| import ( | |
| "fmt" | |
| "math/rand" | |
| "net/http" | |
| "os" |
OlderNewer