Skip to content

Instantly share code, notes, and snippets.

View BillBarnhill's full-sized avatar
💭
Learning Rust

=Bill.Barnhill BillBarnhill

💭
Learning Rust
View GitHub Profile
#nop This file is read on startup by WinTin++ by default.
#event {SESSION CONNECTED} {
#showme {CONNECTED: '%0'};
#regex {%0} {^alonzo$} {
CONNECT Alonzo password;
#format {logfile} {C:/Users/wabar/WinTin++/logs/alonzo_%t.html} {%Y-%m-%d};
#log append $logfile;
} {0};
}
@BillBarnhill
BillBarnhill / tide_test.rs
Created September 10, 2020 02:23
An example Tide unit test in Rust, with a Request and checked Response
#[cfg(test)]
mod tests {
#[async_std::test]
async fn index_page() -> tide::Result<()> {
use tide::http::{Url, Method, Request, Response};
let mut app = tide::new();
app.at("/").get(|_| async { Ok("Hello, world!") });
let url = Url::parse("https://example.com").unwrap();
def f(sz):
assert sz, "Input cannot be empty/falsy"
assert "__getitem__" in dir(sz), "Input must be subscribtable"
result = []
current = sz[0]
count = 0;
for c in sz:
if c == current:
count += 1
@BillBarnhill
BillBarnhill / day2_tide.rs
Created September 12, 2020 02:04
Rust snippet showing how to use state with Tide
#[derive(Clone)]
pub struct AppState {
name : String
}
pub struct App {
server : tide::Server<AppState>
}
@BillBarnhill
BillBarnhill / Cargo.toml
Created January 18, 2020 17:52 — forked from jcdyer/Cargo.toml
Updated for v 0.12.0
[package]
name = "edge"
version = "0.1.0"
authors = ["J. Cliff Dyer <jcd@sdf.org>"]
[dependencies]
indradb = "0.12.0"
indradb-lib = "0.12.0"
serde_json = "*"
uuid = "*"

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@BillBarnhill
BillBarnhill / Setting up an SQL Project
Created August 9, 2019 01:58
Setting up an Knex SQLite3 project from scratch
Configuring the setup
1. Setting up the dependices
yarn init -y (Initalises a packag.json with the default values)
yarn add knex sqlite3 (Add knex sqlite module)
yarn add jest --dev (Add jest to dev dependices)
2. Adding scripts to the package.json file
@BillBarnhill
BillBarnhill / haskell-pcap-writing.hs
Created May 29, 2018 20:07 — forked from nh2/haskell-pcap-writing.hs
Haskell PCAP writing / dump (instance Storable PktHdr)
module PktHdrStorableInstance where
import Foreign.Marshal.Utils (with)
import Foreign.Ptr (plusPtr)
import Foreign.Storable
import Network.Pcap
import Network.Pcap.Base (toPktHdr)
#include <pcap.h>
@BillBarnhill
BillBarnhill / phoenix_read_more_helper_snippet.ex
Created October 4, 2015 15:42
Example of a Phoenix view helper (put in your view or in App views) that inserts a read more link
@doc """
Inserts a link to the show path of a resource item. The
item must implement .id.
##Example
<%= read_more_link @conn, @post %>
"""
def read_more_link(conn, item) do
@BillBarnhill
BillBarnhill / gist:2a67c22501e5ed4c8ad69a39c94769fc
Created June 29, 2017 22:35
If you get AbstractMethodError when creating a JMS Session, then this might help (very rough code though)
// Call this, or put in a method and call, where exception is being thrown
URL[] urls = ((URLClassLoader) (Thread.currentThread().getContextClassLoader())).getURLs();
StringBuilder sz = new StringBuilder("Classpath jars [");
sz.append(Integer.toString(urls.length));
sz.append("]...\n");
String searchFor = "jms/Session";
Map<File, String> matches = new HashMap<>();
for (URL url : urls) {
File file = new File(url.getFile());
sz.append(" ").append(file.getAbsolutePath());