Skip to content

Instantly share code, notes, and snippets.

@soshimozi
soshimozi / StreamTokenizer.cs
Created February 6, 2024 07:40 — forked from riyadparvez/StreamTokenizer.cs
C# port of java's StreamTokenizer class. Everything kept same except some renaming for following C# naming convention. And it also implements IEnumerable for foreach support
/**
* The <code>StreamTokenizer</code> class takes an input stream and
* parses it into "tokens", allowing the tokens to be
* Read one at a time. The parsing process is controlled by a table
* and a number of flags that can be set to various states. The
* stream tokenizer can recognize identifiers, numbers, quoted
* strings, and various comment styles.
* <p>
* Each byte Read from the input stream is regarded as a character
* in the range <code>'&#92;u0000'</code> through <code>'&#92;u00FF'</code>.
@soshimozi
soshimozi / oms-detailed.json
Last active May 20, 2023 22:33
Very detailed Oh My Posh prompt. Not for the faint of heart. Requires Nerd Fonts.
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"newline": true,
"segments": [
{
"background": "#ffffff",
"foreground": "#000000",
@soshimozi
soshimozi / SAML
Created January 11, 2020 01:11 — forked from anonymous/SAML
SAML Parser & Validation
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.Xml;
using System.Web;
@soshimozi
soshimozi / README.md
Created February 26, 2019 08:20 — forked from magnetikonline/README.md
CloudFormation example for an API Gateway endpoint calling a Lambda function using proxy integration.

CloudFormation example for API Gateway integration to Lambda function

Template that will create the following:

  • API Gateway endpoint:
    • A single root method, accepting POST requests only with Lambda proxy integration to a function.
  • In-line Lambda function echoing back requesting users IP address to API Gateway requests:
    • IAM role for Lambda allowing CloudWatch logs access.
    • Permissions for Lambda that allow API Gateway endpoint to successfully invoke function.
  • CloudWatch logs group for Lambda, with 90 day log retention.

After standing up the template, you should be able to curl a POST request to the URL listed as the apiGatewayInvokeURL output value.

@soshimozi
soshimozi / proxy_nginx.sh
Created July 15, 2018 21:05 — forked from rdegges/proxy_nginx.sh
Create a HTTP proxy for jenkins using NGINX.
sudo aptitude -y install nginx
cd /etc/nginx/sites-available
sudo rm default
sudo cat > jenkins
upstream app_server {
server 127.0.0.1:8080 fail_timeout=0;
}
server {
listen 80;
#!/usr/bin/env bash
MYSELF="$(cd "$(dirname "$0")" && pwd)/$(basename "$0")"
if [ -z "${CERTBOT_DOMAIN}" ]; then
mkdir -p "${PWD}/letsencrypt"
certbot certonly \
--non-interactive \
--manual \
namespace DungeonGenerator.Java
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
public class Dungeon
{
public static class SharedStrings
{
public string GetStringFromIndex(int index)
{ ...}
}
public class Column
{
private string _value = "";
@soshimozi
soshimozi / AESGCM.cs
Created December 7, 2017 06:11 — forked from jbtule/AESGCM.cs
I have two code examples that I wrote for best practices encrypting a string in c#. They are both using authenticated encryption. http://stackoverflow.com/a/10366194/637783
/*
* This work (Modern Encryption of a String C#, by James Tuley),
* identified by James Tuley, is free of known copyright restrictions.
* https://gist.github.com/4336842
* http://creativecommons.org/publicdomain/mark/1.0/
*/
using System;
using System.IO;
using System.Text;
@soshimozi
soshimozi / TextToImage.cs
Created April 13, 2017 18:15 — forked from naveedmurtuza/TextToImage.cs
Converting text to image (png) C#
/// <summary>
/// Converting text to image (png).
/// </summary>
/// <param name="text">text to convert</param>
/// <param name="font">Font to use</param>
/// <param name="textColor">text color</param>
/// <param name="maxWidth">max width of the image</param>
/// <param name="path">path to save the image</param>
public static void DrawText(String text, Font font, Color textColor,int maxWidth,String path)
{