Skip to content

Instantly share code, notes, and snippets.

@dseeni
dseeni / main.rs
Created July 2, 2023 00:42 — forked from roosmaa/main.rs
Dynamic method invocation in Rust
#![feature(plugin)]
#![plugin(dynamic_gen)]
extern crate dynamic;
use dynamic::Object;
#[protocol]
trait Pet {
fn speak(&self) -> String;
}

API Design: Coroutines APIs (Janurary-2017)

I am currently dealing with a lot of libraries at work. Both third party as well as libraries written or being currently in process of being written by me. I absolutely love writing and working with libraries. Especially if they present or bring me to either a new or different approach to solve a problem. Or at least provide a different view.

Over time I noticed however that quite regulary we had to decide that we cannot use a third party library. Often it is the usual reason.

@dseeni
dseeni / api.txt
Created June 30, 2023 04:39 — forked from pervognsen/api.txt
This is a brief comment on this article on API design principles:
https://gist.github.com/vurtun/192cac1f1818417d7b4067d60e4fe921
I've called that style of API a coroutine, iterator, state machine, push/pull or client/server API
depending on what seems most appropriate for the context, but they are all variants of the same idea.
It's particularly superior in many cases as an alternative to callback-based APIs, which are the more
common way of providing this kind of fine-grained interleaving between library code and user code.
Callbacks can still be superior in usability for context-free operations like memory allocation,
@dseeni
dseeni / frp.markdown
Created June 29, 2023 01:11 — forked from BriSeven/frp.markdown
links about functional reactive programming

Functional reactive programming links

dataflow languages

dataflow, a paradigm so closely related to FRP it might actually be indistinguishable.

much of this section is plagiarised from This Stackoverflow Answer:

textual languages

@dseeni
dseeni / doStartProcess.lua
Created June 28, 2023 21:34 — forked from talisker77/doStartProcess.lua
start a process in powershell using lua script
function doStartProcess(programWithParams)
local psCmd = '"powershell.exe -Command "Start-Process cmd " -ArgumentList "/c", "\'' .. programWithParams .. '\'" -Verb RunAs -Wait"'
--print (psCmd)
os.execute(psCmd)
end
-- Metatables acts as helpers to tables
-- https://www.lua.org/pil/13.html
-- Meta Methods:
-- __index
-- __newindex
-- Operator examples: __add, __sub, __mul, __concat
local meta = {}

Programming Language Evaluation

A list of simple tasks to perform when learning or evaluating a new language. Each of these should be able to be completed in a few hours, and will help to get the feel of the language and its standard libraries. A well-rounded set of evaluation tasks will help ensure all parts of the language are exercised. You might also write some tests to demonstrate implementation correctness.

Basics

  1. Hello world
  2. Read lines from a text file and output them in sorted order
  3. Read numbers from a text file and output the mean and standard deviation
  4. Given an amount of money and a list of coin denominations provided on the command line, output all the possible ways to make change
@dseeni
dseeni / pair_.md
Created June 28, 2023 08:49 — forked from caotic123/pair_.md
C++ : A functional analysis of immutable pair construction

Abstraction type system

Type system is a construction for guarantees safely in a language, though exist many other aplications like metaprogramming... It's means that i can writes a program but with a safe way, sure it's is perfect why it's solve many problems that programmers has after of compilation. The main idea that i can encode and represent a subset of solutions with a safe type system and better maybe the type can help me represent that.

Data representing

Ok it's mean i have a safe type system and i could represent my types of data..... Ok sure...., but no... limited type system have a weak power of abstraction(no i am not talking about c++ but yes a little part of the language).

The problem of "pair"

Let's go represent a pair: Pair is a tuple of the two values like (P x y), where x and y are values, in this discussion the values x and y can be encode a T type and a Tuple T type.

@dseeni
dseeni / meta-interpolate.lua
Created June 28, 2023 08:26 — forked from davidm/meta-interpolate.lua
Lua metaprogramming using custom searcher with string interpolation example
--[[
The following example illustrates string interpolation [1]
by way of a preprocessor that runs as a customer searcher
function in package.loaders.
Tested in Lua 5.2.0-beta.
Depends on
file_slurp https://gist.github.com/1325400 (for loading files simply)
luabalanced https://github.com/davidm/lua-balanced (for Lua parsing)
@dseeni
dseeni / gzf-git-log.sh
Created May 24, 2023 23:29 — forked from AksAman/gzf-git-log.sh
Alias to view git log in a pretty way with fuzzy search and files preview using fzf
# fzf from https://github.com/junegunn/fzf
# diff-so-fancy from https://github.com/so-fancy/diff-so-fancy
gcop() {
git log \
--reverse \
--color=always \
--format="%C(cyan)%h %C(blue)%ar%C(auto)%d% C(yellow)%s%+b %C(magenta)%ae" "$@" |
fzf -i -e +s \
--reverse \