This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- | |
| Binds the JS required to do something when the user pauses typing (when the element "triggers," for the purposes of this comment) | |
| <input submitdelay="300" eventname="body:inputEntry" submitfunction="submit" /"> | |
| * "submitdelay" is the millisecond delay in typing that will trigger. If not included, defaults to 300 milliseconds. | |
| * "submitevent" is the name of the event that will dispatch from the element when the element triggers. | |
| The event will have two properties: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Just put a "data-storage-key" attribute on your form fields: | |
| <input name="authkey" data-storage-key="saved_auth_key"/> | |
| The value can be anything that is a valid key in localStorage (stick with mostly strings and you'll be fine). | |
| When the form submits, whatever is in the field will be saved to local storage under the provided key name. | |
| Next time the page loads, that form field will be populated from local storage. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Doc here: https://deanebarker.net/tech/code/webserver/ | |
| using System; | |
| using System.Collections.Generic; | |
| using System.IO; | |
| using System.Net; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace DeaneBarker.Utils |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var markdown = @" | |
| This is some text. | |
| This is a [link](http://deanebarker.net/) | |
| "; | |
| var builder = new MarkdownPipelineBuilder(); | |
| var pipeline = builder.Build(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Main() | |
| { | |
| var source = "Hi {{ this_is_the_wrong_identifier }}!"; | |
| var template = new FluidParser().Parse(source); | |
| // This replaces "this_is_the_wrong_identifier" with "name" | |
| var visitor = new FixWrongIdentifier(); | |
| template = visitor.VisitTemplate(template); | |
| var context = new TemplateContext(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Example usage | |
| var data = new LiquidScriptData() | |
| { | |
| ["first_name"] = "Annie", | |
| ["last_name"] = "Barker" | |
| }; | |
| var keysThatChanged = data.Evaluate(@" | |
| if first_name == 'Annie' | |
| assign first_name = 'Deane' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Doc here: https://deanebarker.net/tech/code/directory-sync/ | |
| public class FileSystemSyncManager | |
| { | |
| public List<LogEntry> Log { get; private set; } = new(); | |
| public FileRefCollection SourceFiles { get; set; } | |
| public FileRefCollection TargetFiles { get; set; } | |
| // Return false from any of these to cancel the operation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Information on JSONdata: https://jsonata.org/ | |
| // Requires this class also: https://gist.github.com/deanebarker/d9983155603d1adf26197787a9c74ae4 | |
| // in C# | |
| var json = GetABunchOfJson(); | |
| var context = new TemplateContext(); | |
| context.SetValue("json", new JsonataValue(json)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Doc here: https://deanebarker.net/tech/code/tag-builder/ | |
| public class Tag | |
| { | |
| private readonly string[] selfClosing = new[] { "img", "br", "hr", "input", "link", "meta" }; | |
| public List<Tag> Children = new(); | |
| public Tag(string input, string content, params Tag[] children) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Requires Nuget package Jsonata.Net.Native | |
| // Doc here: https://deanebarker.net/tech/code/jsonata-doc/ | |
| public class JsonataDoc | |
| { | |
| // This is public so you can change the options if you want | |
| public JsonSerializerOptions DeserializerOptions = new(); | |
| private string json; |
NewerOlder