Skip to content

Instantly share code, notes, and snippets.

View mkropat's full-sized avatar
📚
Learning

Michael Kropat mkropat

📚
Learning
View GitHub Profile
@grantcarthew
grantcarthew / Test-SSD.ps1
Last active November 5, 2019 05:13
PowerShell script to test if a hard disk is an Solid State Disk (SSD) or not.
<#
.SYNOPSIS
Detects if the passed Physical Disk Id is a Solid State Disk (SSD) or a
spindle disk. Returns true for an SSD and false for anything else.
.DESCRIPTION
Use Get-PhysicalDisk to get the Physical Disk Ids for the system you wish
to test. This script supports values being passed throught the pipeline.
The methods used for detecting are by reading the Nominal Media Rotation
@ChaseFlorell
ChaseFlorell / Deploy-TeamCityBuildToOctopus.ps1
Last active September 5, 2020 08:48
a script for TeamCity to get git commits and pass them along to Octopus Deploy
# credit for getting me going in the right direction
# http://blogs.lessthandot.com/index.php/uncategorized/access-git-commits-during-a-teamcity-build-using-powershell/
# these properties should be entered into your configuration parameters section
$project = "%Octopus.Project%"
$deployTo = "%Octopus.DefaultEnvironment%"
$buildVersion = "%BuildVersion%"
$octopusApiKey = "%Octopus.BuildDeployBot.APIKey%"
$octopusServer = "%Octopus.Server.Url%"
@CodesInChaos
CodesInChaos / Hkdf.cs
Created January 30, 2014 14:57
HKDF in C#
class Hkdf
{
Func<byte[],byte[],byte[]> keyedHash;
public Hkdf()
{
var hmac = new HMACSHA256();
keyedHash = (key, message)=>
{
hmac.Key=key;
@elijahmanor
elijahmanor / pros-cons-npmscripts-vs-gulp.md
Last active February 20, 2022 12:46
Pros and Cons of `npm scripts` vs Gulp

Comparison of npm scripts vs Gulp

npm scripts

Pros

  • npm scripts are low-level and leverage the actual library you want to use (example: "lint": "eslint ./")
  • package.json is a central place to see what scripts are available (also npm run will list all scripts)
  • When things get too complicated you can always defer to another file (example: "complex-script": "babel-node tools/complex-script.js")
  • npm scripts are more powerful than one might first think (pre/post hooks, passing arguments, config variables, chaining, piping, etc...)
@bhcleek
bhcleek / recover-index.md
Last active November 6, 2022 11:09
recover lost index

to recover files that were added to the index but whose changes were lost (e.g. git reset --hard)

git fsck --unreachable | grep commit | cut -d\  -f3 | xargs git show
  1. git fsck --unreachable to get all the items that are unreachable
  2. grep commit to filter out all entries except for commits (the index will show up as a commit)
  3. cut -d\ -f3 to filter out all but the SHA1s
  4. xargs git show to show all of the contents of the objects.

Once you've identified the SHA1 that contains the changes that were lost, check it out to get the working tree back into the state of the index at the time git reset --hard was run.

@weakish
weakish / README.markdown
Created February 21, 2011 07:02
local and readonly variables in #shell

Local and readonly variables in shells

I've no idea how shells implement them. In this article, I will pretend they use a stack based implementation.

Ksh93 never pops out values. When dash encounteres 'local', it just reuse the outer value. Bash and pdksh/mksh unset values first.

@crazybyte
crazybyte / certs.txt
Created November 25, 2012 09:45
OpenSSL transformations
NOTE: HTTP SSL keys are all in PEM format (base64 encoded)
#From PEM format to DER
openssl x509 -in $1.crt -out $1.der -outform DER
#From DER format to PEM
openssl x509 -in $1.der -inform DER -out $1.pem -outform PEM
#Transforming RSA key to DER format
openssl rsa -in oberon.key -inform PEM -out oberon_key.der -outform DER
@igorgatis
igorgatis / hexdump.js
Created March 15, 2016 16:42
Simple hexdump in Javascript
function hexdump(buffer, blockSize) {
blockSize = blockSize || 16;
var lines = [];
var hex = "0123456789ABCDEF";
for (var b = 0; b < buffer.length; b += blockSize) {
var block = buffer.slice(b, Math.min(b + blockSize, buffer.length));
var addr = ("0000" + b.toString(16)).slice(-4);
var codes = block.split('').map(function (ch) {
var code = ch.charCodeAt(0);
return " " + hex[(0xF0 & code) >> 4] + hex[0x0F & code];
@CMCDragonkai
CMCDragonkai / angularjs_directive_attribute_explanation.md
Last active November 29, 2023 15:35
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@imjasonh
imjasonh / markdown.css
Last active February 12, 2024 17:18
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}