Skip to content

Instantly share code, notes, and snippets.

@Tempest1000
Tempest1000 / gist:325b55d744e62509973c08af9ed48ebf
Created August 28, 2017 00:24
Markdown to other formats with pandoc
md () {
pandoc $1 | lynx -stdin
}
md2libre() {
pandoc ~/Desktop/$1.md -V geometry:margin=1in -s -o ~/Desktop/$1.odt
}
md2pdf() {
pandoc ~/Desktop/$1.md -V geometry:margin=1in -s -o ~/Desktop/$1.pdf
# Function definition is here
def printme():
return """
August 2nd 2017, 17:12:01.139 message:CCM4152E Unable to process message Error: InvalidDataException: Unknown Group [043] scope:test st:R instance_name:test-10.244.2.15:8080 level:ERROR app_port:8080 type:syslog log_time:17120100 t_id: 26 app_name:test @timestamp:August 2nd 2017, 17:12:01.139 env_name: DEV u_id: thread_name:Task-1 level_value:40,000 log_code:CCMSS000 @version:1 level_code:E host:10.244.2.15 logger_name:Listener
August 2nd 2017, 17:12:01.139 message:CCM4152E Unable to process message Error: InvalidDataException: Unknown Group [043] scope:test st:R instance_name:test-10.244.2.15:8080 level:ERROR app_port:8080 type:syslog log_time:17120100 t_id: 26 app_name:test @timestamp:August 2nd 2017, 17:12:01.139 env_name: DEV u_id: thread_name:Task-1 level_value:40,000 log_code:CCMSS000 @version:1 level_code:E host:10.244.2.15 logger_name:Listener
"""
# Call function here
for line in printme().splitlines():
line = line.strip()
<Query Kind="Program">
<Reference Relative="bin\Newtonsoft.Json.dll">D:\Data\LINQ\bin\Newtonsoft.Json.dll</Reference>
</Query>
void Main()
{
// -------------------------
// To use this application you must download a copy of Newtonsoft.Json.dll, which by default is not bundled with LINQPad.
// This DLL can be sourced from the NuGet package manager here: https://www.nuget.org/packages/Newtonsoft.Json
// Note the hardcoded path above, this can be changed to the location of the DLL on your hard drive.
#!/bin/bash
# note: use $body$ in template for placement
pandoc readme.md --template=template.html --css=template.css -f markdown -t html -s -o readme.html
string GetStrings()
{
return @"
${log_lines_here}
";
}
void Main()
{
var list = new List<LogItem>();
import groovy.json.JsonSlurper
def inputFile = new File("open-api.json")
def json = new JsonSlurper().parseText(inputFile.text)
println "swagger version: ${json.swagger.value}"
println "description: ${json.info.description.value}"
println "title: ${json.info.title.value}"
println "------------------------------------------"
println ""
void Main()
{
var files = Directory.EnumerateFiles(@"enter-path-to-files-here", "*.cs", SearchOption.TopDirectoryOnly);
foreach (var file in files)
{
// hardcoding is bad
if (file.Contains("Enum.cs")) continue;
ParseFile(File.ReadAllLines(file));
}
<Query Kind="Program" />
void Main()
{
string mailServer = "<mail server>";
int port = 25;
string mailFrom = "<email address>";
string mailTo = "<email address>";
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(mailServer, port);
<Query Kind="Program">
<Reference Relative="bin\Newtonsoft.Json.dll">D:\Data\LINQ\bin\Newtonsoft.Json.dll</Reference>
</Query>
void Main()
{
// Note, the code below comes from https://github.com/auth0/auth0-aspnet/
// This is code I was working through when learning how JSON Web Tokens work.
// JWT's can be tested using Auth0's excellent website here: https://jwt.io/
// Note: for simplicity I have modified sections of the code, for a full implementation use Auth0's library
import groovy.json.JsonSlurper
// this was created to turn a swagger openapi json file into a flat file
// this flat file can be loaded and parsed into columns in Excel (text to columns > split columns on pipe)
// sample json to turn into a file to parse can be found here: http://editor.swagger.io/
def ouput = new File("open-api-output.txt")
def inputFile = new File("D:\\Data\\Groovy\\open-api.json")
def json = new JsonSlurper().parseText(inputFile.text)