Skip to content

Instantly share code, notes, and snippets.

@JohnyWS
JohnyWS / Start-RequiredServices.ps1
Created January 3, 2019 15:06
Helper file to spin up various required services
# Helper method
function StartService($ServiceName) {
$arrService = Get-Service -Name $ServiceName
while ($arrService.Status -ne 'Running')
{
Start-Service $ServiceName
write-host $arrService.status
write-host 'Service starting'
Start-Sleep -seconds 5
@JaykeOps
JaykeOps / Example.cs
Last active September 20, 2022 19:12
Mongo C# Driver CRUD CheatSheet
//Read
//BsonDocument
var collection = db.GetCollection<BsonDocument>("people");
var builder = Builders<BsonDocument>.Filter;
//Note that the '&' '!' '|' operators are overloaded when used in the FilterBuilder
var filter = builder.Lt("Age", 33) & !builder.Eq("Name", "Ericsson");
var list = await collection.Find(filter).ToListAsync();
------------------------------------------------------------------------------------
@billpratt
billpratt / .NETMongoApplicationInsightsExamples.cs
Last active October 21, 2021 08:27
Examples of how to track .NET Mongodb queries in Application Insights
class Program
{
static void Main(string[] args)
{
var telemetryClient = new TelemetryClient(new TelemetryConfiguration("APP_INSIGHTS_KEY"));
var mongoConnectionString = "mongodb://localhost:27017/test";
TrackMongoByEvents(mongoConnectionString, telemetryClient);
TrackMongoManually(mongoConnectionString, telemetryClient);
@tr00st
tr00st / rabbitmq-env.bat.diff
Created October 11, 2016 11:17
Patch for rabbitmq env file to pull cookie manually
--- rabbitmq-env-orig.bat Tue Oct 11 12:16:01 2016
+++ rabbitmq-env.bat Tue Oct 11 12:10:18 2016
@@ -1,10 +1,12 @@
@echo off
REM Scopes the variables to the current batch file
REM setlocal
+set /p COOKIE_VALUE=<%HOMEDRIVE%%HOMEPATH%\.erlang.cookie
+
@brlinton
brlinton / App Insights Availability Query.cs
Last active July 8, 2019 18:38
Application Insights Analytics Query for Availability Percentage by Test Name
availabilityResults
| where timestamp >= ago(30d)
| summarize AvailabilityPercentage=(sum(todouble(success)) / count(success)) * 100, Failures=count(success)-sum(todouble(success)), TotalTests=count(success) by TestName=name
| order by Failures asc
@addyosmani
addyosmani / README.md
Last active July 13, 2024 21:26 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@khilnani
khilnani / chromebook-ubuntu.md
Last active July 22, 2018 07:31
Install Ubuntu on Chromebook. In Ubuntu, to install Lamp, Mongo DB: wget -O - http://goo.gl/YMhdcP | sudo bash

Install Ubuntu on Chromebook

  • Restart using ESC-Refresh-Power
  • At the prompt, CTRL-D to erase and install ChromeOS in Developer mode
  • Launch terminal - CTRL-ALT-t
  • Download and Install Crouton from (https://github.com/dnschneid/crouton)
    • sudo sh -e ~/Downloads/crouton -t cli-extra
    • sudo sh -e crouton -p "/media/removable/USB Drive/" -r trusty -t cli-extra
    • sudo sh -e crouton -p "/media/removable/USB Drive/" -r trusty -t xfce
  • Open up port 80 if needed - sudo /sbin/iptables -A INPUT -p tcp --dport 80 -j ACCEPT
// kills long running ops in MongoDB (taking seconds as an arg to define "long")
// attempts to be a bit safer than killing all by excluding replication related operations
// and only targeting queries as opposed to commands etc.
killLongRunningOps = function(maxSecsRunning) {
currOp = db.currentOp();
for (oper in currOp.inprog) {
op = currOp.inprog[oper-0];
if (op.secs_running > maxSecsRunning && op.op == "query" && !op.ns.startsWith("local")) {
print("Killing opId: " + op.opid
@idosela
idosela / http-response-interceptor.js
Last active February 25, 2024 12:51
Sample code for ng-conf 2014
angular.module('myMdl', []).config(['$httpProvider', function($httpProvider) {
$httpProvider.responseInterceptors.push([
'$q', '$templateCache', 'activeProfile',
function($q, $templateCache, activeProfile) {
// Keep track which HTML templates have already been modified.
var modifiedTemplates = {};
// Tests if there are any keep/omit attributes.
var HAS_FLAGS_EXP = /data-(keep|omit)/;
@mletterle
mletterle / git-tfs rcheckin prepare-commit-msg hook
Last active December 27, 2015 14:39
Handy little hook I think...
#!/bin/bash
branchname=`git symbolic-ref -q --short HEAD`
if [[ $branchname =~ 'tfs-.*' ]]; then
workitems=$(echo $branchname | sed s/tfs-//g | tr ',' ' ' )
for workitem in $workitems;
do
cp $1 $1.old
$(sed '1s/^/#git-tfs-work-item: '$workitem' associate\n/' $1.old > $1)