Skip to content

Instantly share code, notes, and snippets.

View jptoto's full-sized avatar
😃

JP Toto jptoto

😃
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
namespace My.Infrastructure.Security
{
public class MyPrincipal: IPrincipal
{
public string Name { get; set; }
@lukas-vlcek
lukas-vlcek / gist:1680067
Created January 26, 2012 00:45
Phrase search (out of the box 0.18.7)
#!/bin/sh
curl -X DELETE 'localhost:9200/i/t'
curl -X PUT 'localhost:9200/i/t/1' -d '{"f":"Lorem ipsum Robert E. Anderson dolor sit amet."}'
curl -X PUT 'localhost:9200/i/t/2' -d '{"f":"Lorem ipsum Robert Johnson."}'
curl -X POST 'localhost:9200/_refresh'
echo "\n\nSearch for \"Robert Johnson\"\n"
curl -X GET 'localhost:9200/_search?pretty=true' -d '{"fields":["f"],"query":{"query_string":{"query":"\"Robert Johnson\""}}}'
echo "\n\nSearch for \"Robert E. Anderson\"\n"
curl -X GET 'localhost:9200/_search?pretty=true' -d '{"fields":["f"],"query":{"query_string":{"query":"\"Robert E. Anderson\""}}}'
@rdingwall
rdingwall / DynamicJsonDeserializer.cs
Created February 22, 2012 12:22
RestSharp deserialize JSON to dynamic
// ReSharper disable CheckNamespace
namespace RestSharp.Deserializers
// ReSharper restore CheckNamespace
{
public class DynamicJsonDeserializer : IDeserializer
{
public string RootElement { get; set; }
public string Namespace { get; set; }
public string DateFormat { get; set; }
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 31, 2024 22:29
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@krmcbride
krmcbride / rabbitmq-server
Created December 5, 2012 21:55
RabbitMQ 3.0 Server init.d script
#!/bin/sh
#
# rabbitmq-server RabbitMQ broker
#
# chkconfig: - 80 05
# description: Enable AMQP service provided by RabbitMQ
#
### BEGIN INIT INFO
# Provides: rabbitmq-server
@NoobsArePeople2
NoobsArePeople2 / gist:4490307
Last active August 15, 2018 20:10
Configuration for .bash_profile on OSX to get some Posh-Git features.
  1. Open Terminal move to your home folder: cd ~

  2. Enable git colors: git config --global color.ui true

  3. Make a file called ".colors": touch .colors

  4. Open .colors and paste the following:

@bradwilson
bradwilson / Cacheability.cs
Created January 23, 2014 20:53
Using chaining to create cached results in ASP.NET Web API v2
public enum Cacheability
{
NoCache,
Private,
Public,
}
public interface IEmailSender
{
void Send(string recipient, string subject, string htmlBody);
}
public class EmailSender : IEmailSender
{
private readonly IEmailSettings _settings;
public EmailSender(IEmailSettings settings)
@adamralph
adamralph / notes.csx
Last active August 29, 2015 14:04
Create release notes from GitHub issues with power of scriptcs and Octokit!
var owner = "scriptcs";
var repo = "scriptcs";
var milestone = "v0.10";
var labels = new Dictionary<string, string>{ { "feature", "New" }, { "bug", "Fixed" } };
var username = "adamralph";
var oAuthToken = "secret";
var client = Require<OctokitPack>().CreateWithOAuth("ScriptCs.ReleaseNotesScript", username, oAuthToken);
var issues = client.Issue.GetForRepository(owner, repo, new RepositoryIssueRequest { State = ItemState.Closed, }).Result;
@glennblock
glennblock / contributors.csx
Last active August 29, 2015 14:04
Get contributors for a release via Oktokit
using Octokit;
var client = new GitHubClient(new ProductHeaderValue("scriptcs"))
{
Credentials = new Credentials(user, password)
};
// find all merged PRs
var filter = new PullRequestRequest() { State = ItemState.Closed };