This file contains 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
import ast | |
import pprint | |
import pycparser | |
import pycparser.c_ast as cast | |
# Backus–Naur Form of UAST. | |
# <body> ::= ('body', <stmt1>, <stmt2>, ...) | |
# <stmt> ::= ('func', <str>, <params>, <body>) | |
# | ('if', <expr>, <body>, <body>) | |
# | ('assign', <expr>, <expr>) |
This file contains 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
def topdown(rule, expr): | |
match rule(expr): | |
case (spec, *args): | |
return (spec, *(topdown(rule, arg) for arg in args)) | |
case expr: | |
return expr | |
def rewrite(rule, expr): | |
while (new_expr := topdown(rule, expr)) != expr: | |
expr = new_expr |
This file contains 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
Sub Highlight(Phrase As String) | |
Application.ScreenUpdating = False | |
With ActiveDocument | |
With .Range | |
With .Find | |
.ClearFormatting | |
.replacement.ClearFormatting | |
.Format = False | |
.Forward = True | |
.Wrap = wdFindStop |
This file contains 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
# type: ignore | |
def query(): | |
array = [] | |
for i in range(10000): | |
array.append(i * 2) | |
def tree(): | |
a = 10 | |
nums = [] # A1 |
This file contains 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
import ast | |
def check(rules, env, node, parent): | |
total, names = 0, [] | |
for name, (spec, check, weight) in rules.items(): | |
if isinstance(node, spec) and check(node, parent): | |
if score := weight(env, node) if callable(weight) else weight: | |
total += score | |
names.append(name) | |
return total, '+'.join(names) |
This file contains 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
public sealed class StyleManager | |
{ | |
public enum Theme { Citrus, Sea, Rust, Candy, Magma } | |
private readonly StyleInclude _magmaStyle = CreateStyle("avares://Citrus.Avalonia/Magma.xaml"); | |
private readonly StyleInclude _candyStyle = CreateStyle("avares://Citrus.Avalonia/Candy.xaml"); | |
private readonly StyleInclude _citrusStyle = CreateStyle("avares://Citrus.Avalonia/Citrus.xaml"); | |
private readonly StyleInclude _rustStyle = CreateStyle("avares://Citrus.Avalonia/Rust.xaml"); | |
private readonly StyleInclude _seaStyle = CreateStyle("avares://Citrus.Avalonia/Sea.xaml"); | |
private readonly Window _window; |
This file contains 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
public partial class FeedbackView : Form, IViewFor<FeedbackViewModel> | |
{ | |
public FeedbackView() | |
{ | |
InitializeComponent(); | |
ViewModel = new FeedbackViewModel(new WinFormsSender(), new Clock()); | |
this.WhenActivated(subscriptions => | |
{ | |
this.Bind(ViewModel, x => x.Title, x => x.TitleTextBox.Text) | |
.DisposeWith(subscriptions); |
This file contains 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
public class ReactiveFodyViewModel : ReactiveObject | |
{ | |
private readonly ObservableAsPropertyHelper<string> _greeting; | |
public string Greeting => _greeting.Value; | |
[Reactive] | |
public string Name { get; set; } = string.Empty; | |
public ReactiveCommand<Unit, Unit> Clear { get; } |
This file contains 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
public sealed partial class FeedbackView : Page, IViewFor<FeedbackViewModel> | |
{ | |
public static readonly DependencyProperty ViewModelProperty = DependencyProperty | |
.Register(nameof(ViewModel), typeof(FeedbackViewModel), typeof(FeedbackView), null); | |
public FeedbackView() | |
{ | |
InitializeComponent(); | |
ViewModel = new FeedbackViewModel(new UwpSender(), new Clock()); | |
this.WhenActivated(disposables => { /* handle interactions, etc. */ }); |
This file contains 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
module Program | |
open Funogram.Bot | |
open Funogram.Api | |
open ExtCore.Control | |
open System | |
/// Handler for '/hello'. | |
let onHello context = | |
maybe { |
NewerOlder