Skip to content

Instantly share code, notes, and snippets.

## Typically when bootrec /fixboot throws an error
diskpart
select disk 0
list vol
select vol 1
assign letter=v:
v:
md \efi\microsoft\boot
bcdboot c:\windows /l en-us /s V: /f all
bootsect /nt60 sys
@frank-borkin
frank-borkin / google_analytics
Created October 30, 2019 18:50
nginx logs to google analytics
# send logs for all traffic to google analytics
#
# in server block:
# set $google_analytics_id "UA-THECORRECT-ID";
# include /etc/nginx/google_analytics;
#
# in location blocks:
# post_action @ga;
userid on;
@frank-borkin
frank-borkin / RedisWildcardExtension.cs
Created July 29, 2019 14:34
An extension to support wildcard deletes in stackexchange's redis driver
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Net;
using StackExchange.Redis;
namespace MyNamespace
{
/// <summary>Extensions for StackDrivers Redis package</summary>
public static class RedisWildcardExtension
{
@frank-borkin
frank-borkin / set_nickname.js
Created March 19, 2018 09:20
Use one field in Mongo to update another field
//// In this example, if the user's first name is set, but their nickname isn't, we set the nickname to the first name.
db.users.find({$and:[{"firstName":{$ne:null}},{"nickname":null}]}).snapshot().forEach(
function (elem) {
db.users.update(
{
_id: elem._id
},
{
$set: {
nickname: elem.firstName
@frank-borkin
frank-borkin / convert.js
Created March 19, 2018 09:17
Update _id's in Mongo from flat GUID form to hyphenated (bea84cc1e0ec431a9ee03998b8c44436 to bea84cc1-e0ec-431a-9ee0-3998b8c44436)
//// Grab everything with 32 characters, split the id and add hyphens then create a new record with that as the id
db.users.aggregate({$match:{"_id":{$regex:/^.{32}$/}}},{$project:{item: 1,g1: { $substr: [ "$_id", 0, 8 ] },g2: { $substr: [ "$_id", 8, 4 ] },g3: { $substr: [ "$_id", 12, 4 ] },g4: { $substr: [ "$_id", 16, 4 ] },g5: { $substr: [ "$_id", 20, 12 ] }}}).forEach(
function(e) {
var new_guid = e.g1+'-'+e.g2+'-'+e.g3+'-'+e.g4+'-'+e.g5;
doc = db.users.findOne({"_id": e._id})
doc._id = new_guid
db.users.insert(doc)
});
//// You may be asking why? Well, .net uses hypen form, and lots of other things don't, so if you've done a bulk import from several different systems you can use this to normalise them.
@frank-borkin
frank-borkin / caught_errors.sql
Created March 14, 2018 18:08
Catch bad queries in Oracle.
create table caught_errors (
dt date,
username varchar2( 30), -- value from ora_login_user
msg varchar2(2000),
stmt varchar2(2000)
);
create or replace trigger catch_errors
after servererror on database
@frank-borkin
frank-borkin / update-ca.sh
Last active March 14, 2018 18:04
Adding a new root CA to RHEL7
cd /etc/pki/ca-trust/source/anchors/
sudo wget https://something/ca.pem
sudo update-ca-trust extract

Keybase proof

I hereby claim:

  • I am frank-borkin on github.
  • I am frankborkin (https://keybase.io/frankborkin) on keybase.
  • I have a public key whose fingerprint is DF55 28E3 3792 D599 9E73 9D9B 819A DADA 5BEB 8E22

To claim this, I am signing this object: