Skip to content

Instantly share code, notes, and snippets.

View tugberkugurlu's full-sized avatar
:shipit:
💥 shakalaka

Tugberk Ugurlu tugberkugurlu

:shipit:
💥 shakalaka
View GitHub Profile
## TODO: Execute the necessary javascript code on mongo servers for setting up the sharding and replications
## TODO: Take a param for type (e.g. All, Config, Shard, Mongos).
## TODO: Take a param fof installing as a service or firing up the exes.
param(
[string]$startDir
)
function get-cnfgServerObj($port, $path) {
$firstCnfgSrv = New-Object PSObject
configuration MongoDB {
param (
[string[]]$ComputerName = $env:ComputerName
)
node $ComputerName {
File SetupFolder {
Type = 'Directory'
DestinationPath = "C:\setup"
Ensure = 'Present'
}
@tugberkugurlu
tugberkugurlu / sample.txt
Created May 16, 2014 12:05
MongoDB $unwind sample
db.contents.aggregate(
{ $match: { $and: [{ Type: "Api" }, { $text: { $search: "configuration" } }] } },
{ $sort: { score: { $meta: "textScore" } } },
{ $project: { _id: 1, Tags: 1 } },
{ $unwind: "$Tags" },
{ $group: { _id: "$Tags", count: { $sum : 1 } }}
)
GET http://localhost:25135/api/cars HTTP/1.1
User-Agent: Fiddler
Accept: application/json
Host: localhost:25135
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Wed, 25 Jun 2014 12:36:48 GMT
Content-Length: 68
const string num = "648634";
if (num.All(ch => char.IsDigit(ch)))
{
int parsedVal = 0;
for (var i = 0; i < num.Length; i++)
{
int foo = 10 ^ (num.Length - i);
// ??
}
}
@tugberkugurlu
tugberkugurlu / program.cs
Last active August 29, 2015 14:06
JSON.NET (Newtonsoft.Json) Custom converter
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Runtime.Serialization;
namespace ConsoleApplication11
{
[DataContract]
public enum JsonPatchOperationType
public static class ClaimsIdentityExtensions
{
public static string GetUserEmail(this ClaimsIdentity identity)
{
Claim emailClaim = identity.Claims.FirstOrDefault(claim => claim.Type == ClaimTypes.Email);
return emailClaim != null
? emailClaim.Value
: null;
}
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 3,
powershell -NoProfile -ExecutionPolicy unrestricted -windowstyle hidden -Command "cd 'c:\dev';dir"
@tugberkugurlu
tugberkugurlu / program.cs
Created November 4, 2014 12:16
ClaimsPrincipal construction over multiple ClaimsIdentity instances
using System.Collections.Generic;
using System.Security.Claims;
namespace MultipleClaimsSample
{
class Program
{
static void Main(string[] args)
{
// NOTE: The below is a sample of how we may construct a ClaimsPrincipal instance over two ClaimsIdentity instances: