Skip to content

Instantly share code, notes, and snippets.

View leikahing's full-sized avatar
🧧
Chaining the blocks

William Lee leikahing

🧧
Chaining the blocks
View GitHub Profile
@leikahing
leikahing / remove-things.ps1
Last active August 28, 2015 17:13
Uninstall MS stuff
foreach ($app in (Get-WmiObject -Query "Select * from Win32_Product where name like 'Microsoft Visual Studio Professional %'")) {
Write-Host "Deleting $app.Name"
&"msiexec.exe" /norestart /q/x $app.IdentifyingNumber REMOVE=ALL
#$app.Uninstall()
}
foreach ($app in (Get-WmiObject -Query "Select * from Win32_Product where name like 'Microsoft SQL Server %'")) {
Write-Host "Deleting $app.Name"
&"msiexec.exe" /norestart /q/x $app.IdentifyingNumber REMOVE=ALL
#$app.Uninstall()
@leikahing
leikahing / dictconvert.cs
Created March 12, 2014 20:33
Converting Dictionaries
public class TourYearInfo
{
public int Year { get; set;}
public int TourCode {get; set;}
}
void Main()
{
@leikahing
leikahing / SimilarItems.cxx
Created July 18, 2014 15:22
Finding similar items
std::vector<std::string> findSimilarItems(std::vector<std::string> first, std::vector<std::string> second)
{
std::vector<std::string> rv;
std::sort(first);
std::sort(second);
for (auto iter = first.begin(), auto iter2 = second.begin();;)
{
if (*iter == *iter2) {
@leikahing
leikahing / scope.c
Last active August 29, 2015 14:05
Scope scope scope
void doSomething()
{
int c = 1;
{
int x = 2;
}
printf("%d", x); // x's scope has ended
} // c's scope has ended
@leikahing
leikahing / gist:2e072b0fd047faebd358
Last active August 29, 2015 14:06
Shambler's remote WSUS spy
# Load all computer names from a text file into an array/list
$computers = Get-Content -path C:\users\brynet01\desktop\Computers.txt
# Loop over each computer name in the array/list
foreach ($computer in $computers)
{
# Open a remote registry connection to the current value of $computer. This requires going into the .NET library
# The 'LocalMachine' bit specifies that the remote registry base should be HKLM
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computer)
@leikahing
leikahing / zk.rb
Created February 24, 2015 20:02
Zookeeper discovery hack
zks_hash =
JSON.parse(`aws --region #{node['region']} \
ec2 describe-instances \
--filters "Name=tag:Deploy,Values=zookeeper"`)
# Parse out all the IP addresses for the instances from the dict
# This is hideous due to the AWS JSON return format
zookeeper_urls = []
zks_hash["Reservations"].each do |zk|
zk_ip = zk["Instances"][0]["NetworkInterfaces"][0]["PrivateIpAddress"]
@leikahing
leikahing / renderly-build.fsx
Created May 12, 2015 20:33
Renderly build file
#r @"packages/FAKE/tools/FakeLib.dll" // include the FAKE library
open Fake
// Define our build output
let buildDir = "./build/"
Target "Clean" (fun _ ->
CleanDir buildDir
)
@leikahing
leikahing / .gitignore
Created May 13, 2015 20:07
Python gitignore
*.tar.gz
*/.DS_Store
*.template
*.swp
venv
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*.pem
@leikahing
leikahing / pfa.fs
Last active August 29, 2015 14:23
Gist of my F# partial function application message
open System
open System.IO
open Fake
/// Specifies the parameters for running an Ivy request
type IvyRetrieveParams =
{
JavaPath : string
JarPath : string
Host : string
@leikahing
leikahing / stuff.rb
Created June 17, 2015 19:08
Garbage ruby
def third_party_exists?(repository, sub_package, path)
uri = URI.parse("https://artifactory.vistaprint.net/#{repository}/#{path}")
request = Net::HTTP::Head.new(uri.request_uri)
print 'request URI: ', uri.to_s, "\n" if ENV['DOC_DEVKIT_TRACE']
print 'request hash: ', request.to_hash, "\n" if ENV['DOC_DEVKIT_TRACE']
print "request body:\n", request.body, "\n\n" if ENV['DOC_DEVKIT_TRACE']
response = get_http(uri).request(request)
print "\n" if ENV['DOC_DEVKIT_TRACE']
print 'response hash: ', response.to_hash, "\n" if ENV['DOC_DEVKIT_TRACE']
print 'response code: ', response.code, "\n" if ENV['DOC_DEVKIT_TRACE']