Skip to content

Instantly share code, notes, and snippets.

View ferrata's full-sized avatar
<crinking doffee>

Sasha Goloshchapov ferrata

<crinking doffee>
View GitHub Profile
function FindProxyForURL(url, host) {
if (shExpMatch(host, "*localhost")) {
return "PROXY localhost";
}
return "DIRECT";
}
stateDiagram-v2
  state "wake up" as wakeUp
  state "grab a brush" as grabBrush
  state "put a little makeup" as makeUp
  state "hide the scars" as hideScars
  state "fade away the shakeup" as fadeShakeup
  state "leave the keys upon the table" as leaveKeys
 
  [*] --> wakeUp
stateDiagram-v2
    state "wake up" as wakeUp 
    state "make ☕" as make
    state "drink ☕" as drink
    state outOfCoffee <<choice>>

    [*] --> wakeUp
    wakeUp --> check
 check --&gt; outOfCoffee: out of coffee?
sequenceDiagram
    participant User
    participant Builder
    participant Database
    participant Host

    User->>Builder: Get iframe URL (usePreviewUrl)
 Builder-&gt;&gt;Database: Get pageId from URL
@ferrata
ferrata / ferrata-v2.json
Last active May 6, 2022 17:16
oh-my-posh template
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"foreground": "#ffff00",
"background": "transparent",
"style": "diamond",
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
function Main() {
# ...
}
try {
Main
}
@ferrata
ferrata / hl7-buffer-example.cs
Created May 17, 2018 21:41
Hl7Handler example buffer
private static IMessage readMessage(StreamReader reader, Encoding encoding, int bufferSize)
{
var messageData = new StringBuilder();
if (!readStartMarker(reader))
return null; //throw ??
var buffer = new char[bufferSize];
while (true)
{
var bytesRec = reader.Read(buffer, 0, bufferSize);
internal class Hl7Handler : SimpleChannelInboundHandler<IByteBuffer>
{
private class Markers
{
public static readonly byte[] start = { 0x0b };
public static readonly byte[] end = { 0x1c, 0x0d };
}
protected override void ChannelRead0(IChannelHandlerContext cx, IByteBuffer data)
{
ops = {
"+": (lambda a, b: a + b),
"-": (lambda a, b: a - b)
}
def eval(tokens):
stack = []
for token in tokens:
#print token, stack
if token in ops:
@ferrata
ferrata / traverse.py
Last active October 20, 2017 19:23
bfs
import Queue
class node( object ):
def __init__( self, value, children = None ):
self.value = value
self.children = children or []
def traverse( root ):
# seen = set()
q = Queue.Queue() # stack - Breadth-First