Skip to content

Instantly share code, notes, and snippets.

View scattered-code's full-sized avatar
🏠
Working from home / Living at work

Alexandru Puiu scattered-code

🏠
Working from home / Living at work
View GitHub Profile
POST /upload HTTP/1.1
Host: localhost:8000
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:29.0) Gecko/20100101 Firefox/29.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: __atuvc=34%7C7; permanent=0; _gitlab_session=226ad8a0be43681acf38c2fab9497240; __profilin=p%3Dt; request_method=GET
Connection: keep-alive
Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266
Content-Length: 554
using System;
using System.Linq;
namespace Web.Infrastructure
{
public static class RequestHelpers
{
public static string GetBoundary(string contentType)
{
var elements = contentType.Split(' ');
using System;
using Microsoft.AspNetCore.Mvc.Filters;
namespace Web.Infrastructure
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public sealed class DisableFormValueModelBindingAttribute : Attribute, IResourceFilter
{
public void OnResourceExecuting(ResourceExecutingContext context)
{
public static IEnumerable<Entry> GetDocumentsFromDatabase(IDocumentSession session)
{
var skip = 0;
do
{
var entries = session.Query<Entry>().Where(x => !x.Deleted).OrderByDescending(x => x.DateModified).Skip(skip).Take(1024).ToList();
foreach (var entry in entries)
yield return entry;
skip += 1024;
if (entries.Count < 1024)
MATCH (a:Application)<-[:USES_APPLICATION]-(u:User)-[:USES_APPLICATION]->(b:Application), (u)-[:IN_ORGANIZATION]->(org:Organization)
WHERE org.name<>'My Company' AND a<>b
RETURN org, COUNT(u) ORDER BY COUNT(u) DESC
MATCH (a:Application)<-[:USES_APPLICATION]-(u:User)-[:USES_APPLICATION]->(b:Application), (u)-[:IN_ORGANIZATION]->(org:Organization)
WHERE a.name='Salesforce' AND b.name='Splunk' AND org.name<>'Facebook'
RETURN u.email;
MATCH (a:Application)<-[:USES_APPLICATION]-(u:User)-[:USES_APPLICATION]->(b:Application)
WHERE a.name='Salesforce' AND b.name='Splunk'
RETURN u.email;
CALL apoc.periodic.repeat('importVMs',
'call apoc.es.postRaw(...) yield value with value.aggregations.hosts.buckets as buckets
UNWIND buckets as data
MERGE (vm:VM {hostname: data.key})',
60 * 60)
call apoc.es.postRaw("localhost", "filebeat-*/_search?rest_total_hits_as_int=true&ignore_unavailable=true&ignore_throttled=true", "{\"aggs\":{\"hosts\":{\"terms\":{\"field\":\"agent.hostname\"},\"aggs\":{\"cloud\":{\"terms\":{\"field\":\"cloud.provider\"}}}}},\"size\":0,\"query\":{\"bool\":{\"filter\":[{\"range\":{\"@timestamp\":{\"format\":\"strict_date_optional_time\",\"gte\":\"2019-11-20T13:40:45.890Z\",\"lte\":\"2019-12-05T13:40:45.890Z\"}}}]}}}") yield value with value.aggregations.hosts.buckets as buckets
UNWIND buckets as data
MERGE (vm:VM {hostname: data.key})
{
"aggs": {
"hosts": {
"terms": { "field": "agent.hostname" },
"aggs": {
"cloud": {
"terms": { "field": "cloud.provider" }
}
}
}