Skip to content

Instantly share code, notes, and snippets.

View skynyrd's full-sized avatar
🎯
Focusing

Anıl Selim Sürmeli skynyrd

🎯
Focusing
  • Tiimely
  • Sydney, Australia
  • 16:55 (UTC +10:00)
View GitHub Profile
@skynyrd
skynyrd / jaeger.cs
Created January 23, 2019 04:59
jaeger crossing the apis
// You need to add headers to your ITracer if you are going to call other APIs
var dictionary = new Dictionary<string, string>();
_tracer.Inject(scope.Span.Context, BuiltinFormats.HttpHeaders, new TextMapInjectAdapter(dictionary));
foreach (var entry in dictionary)
{
_httpClient.DefaultRequestHeaders.Add(entry.Key, entry.Value);
}
class Program
{
public static void Main(string[] args) => MainAsync().GetAwaiter().GetResult();
private static async Task MainAsync()
{
// discover endpoints from metadata
var disco = await DiscoveryClient.GetAsync("http://localhost:5000"); //IdentityServer Address
if (disco.IsError)
@skynyrd
skynyrd / clientcredentials1.cs
Last active January 5, 2019 05:38
For medium post about identityserver
public class Config
{
// scopes define the API resources in your system
public static IEnumerable<ApiResource> GetApiResources()
{
return new List<ApiResource>
{
new ApiResource("TheApi", "The Example API")
};
}
@skynyrd
skynyrd / notes.md
Created June 24, 2018 10:45
Entity Framework 2 Notes
  • After Add-Migration:
    • Demo/Test/QA => Update-Databsase (If db doesn't exist, it will be created automatically)
  • Production => Script-Migration
@skynyrd
skynyrd / serial_xunit.md
Last active January 19, 2018 07:20
Disable parallel running in Xunit

In root directory of the test project:

Create xunit.runner.json and write below:

{
  "parallelizeAssembly": false,
  "parallelizeTestCollections": false
}
@skynyrd
skynyrd / consumer_commit.java
Created December 16, 2017 12:47
consumer commit
try {
while (running) {
ConsumerRecords<String, String> records = consumer.poll(1000);
try {
for (ConsumerRecord<String, String> record : records)
// Your work here.
} catch (CommitFailedException e) {
// application specific failure handling
}
@skynyrd
skynyrd / put.java
Created December 16, 2017 12:39
kafka_connect_put
@Override
public void put(Collection<SinkRecord> collection) {
try {
Collection<String> recordsAsString = collection.stream().map(r -> String.valueOf(r.value())).collect(Collectors.toList());
elasticService.process(recordsAsString);
}
catch (Exception e) {
log.error("Error while processing records");
log.error(e.toString());
}
@skynyrd
skynyrd / Query DSL.md
Last active December 8, 2017 16:06
Searching and Analyzing Data - Pluralsight

Query Context: How well does this document match this query?

Filter Context: Does this document match this query clause?

For Query Context

  • Included or not: Determine whether the document should be part of the result
  • Relevance score: Calculated for every search term the document maps to
  • High score, more relevant: More relevant documents, higher in the search rankings.
@skynyrd
skynyrd / ssh.md
Created November 15, 2017 15:10
ssh

ps aux | grep sshd find all ssh connections to the machine that this command applied

@skynyrd
skynyrd / slack.java
Last active November 10, 2017 08:09
Slack webhook in java
// Slack
private void sendSlackNotification(String id, String message) {
MediaType JSON
= MediaType.parse("application/json; charset=utf-8");
RequestBody body = RequestBody.create(JSON,
String.format("{ \"text\": \"Cannot send the product with id <%s>,\n Error: %s\"}", id, message.replaceAll("\"", "'")));
Request request = new Request.Builder()