Skip to content

Instantly share code, notes, and snippets.

@umuro
umuro / tclwrust.md
Created November 9, 2023 20:00
Tcl with Rust

Implementing Rust functions and calling them from Tcl scripts involves a multi-step process. Here's a high-level overview of how you can achieve this:

  1. Writing Rust Code: Start by writing the desired functions in Rust. You'll need to compile this Rust code into a shared library (.so on Unix-like systems, .dll on Windows).

  2. Creating a C Interface: Rust functions must be exposed with a C-compatible interface (using extern "C"), because most other languages including Tcl can easily interface with C code.

  3. Building a Shared Library: Compile your Rust project with cargo to create a shared library. Make sure to use the appropriate target for your operating system.

  4. Interfacing with Tcl: Tcl can interface with C code using the Foreign Function Interface (FFI) mechanism. You'll use the load command in Tcl to load the shared library.

@umuro
umuro / tcltest.md
Created November 9, 2023 19:35
tcltest

The tcltest package is a framework for writing and running automated tests in Tcl. It is designed to support tests for core Tcl commands, Tcl library procedures, and Tcl applications. Here's an overview of how tcltest works and some of its key features:

Key Features of tcltest:

  • Test Case Definition: Tests are defined using a specific syntax that outlines what the test will do, the expected result, and any setup or cleanup that's needed.
  • Assertions: tcltest allows you to write assertions to compare expected results against actual results.
  • Test Discovery: It can automatically find and run test cases that are defined in files with a specific naming convention.
  • Test Isolation: Each test is run in isolation to prevent side effects between tests.
  • Result Reporting: The framework provides detailed reports on test outcomes, including passes, failures, and errors.
@umuro
umuro / 000-cot.txt
Last active November 9, 2023 19:24
infinite cot prompt
Imagine three different experts are answering this question. They will brainstorm the answer step by step reasoning carefully and taking all facts into consideration. All experts will write down 1 step of their thinking, then share it with the group. They will each critique their response, and the all the responses of others. They will check their answer based on science and the laws of physics. Then all experts will go on to the next step and write down this step of their thinking. They will keep going through steps until they reach their conclusion taking into account the thoughts of the other experts. If at any time they realise that there is a flaw in their logic they will backtrack to where that flaw occurred . If any expert realizes they're wrong at any point then they acknowledges this and start another train of thought. Each expert will assign a likelihood of their current assertion being correct. Continue until the experts agree on the single most likely answer. Experts A, B, and C, your task is to c
@umuro
umuro / sqlite-w-rust.md
Created October 27, 2023 22:38
Using SQLite with Rust

Here's a step-by-step process of how you can work with SQLite in a Rust project:

  1. Choose a Library:

    • rusqlite: This is a popular choice for working with SQLite in Rust. It provides a safe and comfortable wrapper around the SQLite C API.
    • diesel: While not SQLite-specific, Diesel is a powerful ORM (Object-Relational Mapping) and query builder for Rust that supports SQLite, among other databases.
  2. Install the Library:

    • Add the library to your Cargo.toml file.
@umuro
umuro / Docker Cheatsheet.md
Last active March 24, 2017 23:28
Docker commands

#RUN

docker run hello-world
docker run docker/whalesay cowsay boo
docker run -it ubuntu bash

#LIST

docker images
@umuro
umuro / Phoenix Cheatsheet.md
Last active September 2, 2017 01:44
Elixir Cheatsheets

Keybase proof

I hereby claim:

  • I am umuro on github.
  • I am umur (https://keybase.io/umur) on keybase.
  • I have a public key ASCDmpjT3ec7yNc555RFep9wNlsAQp1XiUthgJ0B63AzuAo

To claim this, I am signing this object:

@umuro
umuro / match_mtd.rb
Created August 29, 2012 12:50
Match a ruby metdhod using regex. To use Thor scripts to replace method definitions in existing source code.
#Match a ruby metdhod using regex. To use Thor scripts to replace method definitions in existing source code.
# github: umuro, Umur Ozkul
def match_mtd(mtd)
/^\s*def (#{mtd})\s+((?!end).)*\s+end\s*$/m
end
@umuro
umuro / post_rvmrc.rb
Created August 21, 2012 11:48
If your old rvmrc is not ensuring a bundle then you can add this bit...
#This bit goes at the end of rvmrc and makes sure that bundle is installed and it installs gems
#If you use bundler, this might be useful to you:
if [[ -s Gemfile ]] && {
! builtin command -v bundle >/dev/null ||
builtin command -v bundle | grep $rvm_path/bin/bundle >/dev/null
}
then
printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
gem install bundler
@umuro
umuro / template_demo_blog_hobo.rb
Created August 20, 2012 15:13
A template to create a blog with hobo. Quickly!
# Creates a demo blog in a new hobo project
# Usage: rake rails:template LOCATION=template_demo_blog_hobo.rb
# Or: rake rails:template LOCATION=https://raw.github.com/gist/3405055/9aaac7c1c9e9571b32c4359fa9fff77c89de82a9/template_demo_blog_hobo.rb
say ("Installing gems so that we can scaffold...")
run 'bundle install'
generate 'hobo:setup_wizard' if yes? "Wanna run hobo:setup_wizard?"
generate 'hobo:resource', 'Post title:string text:text'