Skip to content

Instantly share code, notes, and snippets.

View gatesvp's full-sized avatar

Gaëtan Perrault gatesvp

View GitHub Profile
@gatesvp
gatesvp / step01.php
Created May 17, 2011 23:43
PHP commands for basic MongoDB operations
<?php
try {
$mongo = new Mongo(); // default host:port
$db = $mongo->example;
$collection = $db->test;
$document = array('x' => 1);
$collection->insert($document);
print_r($document);
@gatesvp
gatesvp / test.js
Created June 12, 2011 01:53
Pull with regex
MongoDB shell version: 1.8.1
connecting to: test
> db.test.insert({ _id:3, "items": [ 'appstore.com', 'engineapp.com', 'asp.ca' ] })
> db.test.find()
{ "_id" : 3, "items" : [ "appstore.com", "engineapp.com", "asp.ca" ] }
> db.test.update({}, {$pull : { items: {$regex: 'app' } } })
> db.test.find()
{ "_id" : 3, "items" : [ "asp.ca" ] }
@gatesvp
gatesvp / Get-FolderSizes.ps1
Created July 18, 2012 19:22
PowerShell Get-FolderSizes
### Sample usage: Get-FolderSizes "C:\data" | sort size -Descending | FT -AutoSize
function Get-FolderSizes([string] $StartFolder) {
$results = @();
$colItems = (Get-ChildItem $StartFolder | Measure-Object -property length -sum)
$res = New-Object PSObject | select Folder, Size;
$res.Folder = $startFolder;
$res.Size = [float]("{0:N2}" -f ($colItems.sum / 1MB));
ipfs : 01:02:21.637 INFO  cmd/ipfs: IPFS_PATH C:\Users\gates/.ipfs <autogenerated>:28
At line:1 char:1
+ ipfs daemon --debug *> .\ipfs_fsync_error.log
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (01:02:21...nerated>:28:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
01:02:21.637 DEBUG  cmd/ipfs: looking for running daemon... <autogenerated>:22
01:02:21.637 DEBUG  cmd/ipfs: Calling pre-command hooks... <autogenerated>:22
@gatesvp
gatesvp / DnsLite.cs
Created June 7, 2017 21:18
Lookup MX records in C#
/**
@author Jaimon Mathew
csc /target:library /out:DnsLib.dll /D:DEBUG=1 /debug+ DnsLite.cs
*/
using System;
using System.Net;