Skip to content

Instantly share code, notes, and snippets.

View jeremychone's full-sized avatar

Jeremy Chone jeremychone

View GitHub Profile
@jeremychone
jeremychone / rust-xp-02-postgresql-sqlx.rs
Created May 11, 2021 05:48
Rust to PostgreSQL with SQLX | Rust By Example
#![allow(unused)] // silence unused warnings while exploring (to comment out)
use sqlx::postgres::{PgPoolOptions, PgRow};
use sqlx::{FromRow, Row};
// Youtube episode: https://youtu.be/VuVOyUbFSI0
// region: Section
// Start postgresql server docker image:
@jeremychone
jeremychone / rust-xp-01-s3.rs
Last active April 13, 2024 16:39
Rust Quick Example to connect to S3 and Minio bucket server
#![allow(unused)] // silence unused warnings while exploring (to comment out)
use std::{error::Error, str};
use s3::bucket::Bucket;
use s3::creds::Credentials;
use s3::region::Region;
use s3::BucketConfiguration;
// Youtube Walkthrough - https://youtu.be/uQKBW8ZgYB8
@jeremychone
jeremychone / rust-xp-03-redis.rs
Last active September 9, 2023 06:33
Rust Redis with Async/Await (single threaded concurrency) | RustLang by example
#![allow(unused)] // silence unused warnings while exploring (to comment out)
use std::{error::Error, time::Duration};
use tokio::time::sleep;
use redis::{
from_redis_value,
streams::{StreamRangeReply, StreamReadOptions, StreamReadReply},
AsyncCommands, Client,
};
@jeremychone
jeremychone / rust-let-else.rs
Last active August 28, 2023 19:55
Rust 1.65 - let-else statements - new language feature!!! For youtube video: https://www.youtube.com/watch?v=U-5_bumwH9w&list=PL7r-PXl6ZPcCIOFaL7nVHXZvBmHNhrh_Q)
//! For youtube video: https://www.youtube.com/watch?v=U-5_bumwH9w&list=PL7r-PXl6ZPcCIOFaL7nVHXZvBmHNhrh_Q
/// Guard pattern with let-else
/// e.g., "my_key: 123"
pub fn key_num_guard_1(item: &str) -> Result<(&str, i32), &'static str> {
let Some((key, val)) = item.split_once(':') else {
return Err("Invalid item");
};
let Ok(val) = val.trim().parse::<i32>() else {
return Err("Invalid item");
{
"pair_lgt": {
"prefix": "<",
"body": [
"<$1>"
],
"description": "<> pair"
},
"pair_bars": {
"prefix": "|",
@jeremychone
jeremychone / handlebars-render.js
Last active October 31, 2022 05:44
Simple HTML and js templates
// Just a little indirection to render a template using handlebars.
// This simple indirection allows much flexibility later one,
// when using pre-compiling or other templating engine are needed.
Handlebars.templates = Handlebars.templates || {};
function render(templateName,data){
var tmpl = Handlebars.templates[templateName];
if (!tmpl){
tmpl = Handlebars.compile($("#" + templateName).html());
Handlebars.templates[templateName] = tmpl;
}
## Tutorial >> https://www.tensorflow.org/get_started/mnist/beginners
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
## https://github.com/tensorflow/tensorflow/issues/7778
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
{
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"workbench.activityBar.visible": false,
// "editor.glyphMargin": false,
"editor.suggest.showIcons": false,
"editor.lightbulb.enabled": false,
// "editor.hover.enabled": false,
// "typescript.suggestionActions.enabled": false,
// Place your settings in this file to overwrite the default settings
{
"http.proxySupport": "off", // by default we use tabs
"files.associations": {
"*.pcss": "scss",
"*.tmpl": "html",
"*.hmd": "markdown",
"*.sketchscript": "javascript",
"*.hmt": "markdown"
},