Skip to content

Instantly share code, notes, and snippets.

View ashaffah's full-sized avatar
🎯
Focusing

Ashaffah ashaffah

🎯
Focusing
  • bedroom
  • 11:25 (UTC +07:00)
View GitHub Profile
@ashaffah
ashaffah / helper.ts
Last active March 20, 2025 03:09
object converter to formData
export const objectToFormData = (
obj: Record<string, any>,
form?: FormData,
namespace?: string,
): FormData => {
const formData = form || new FormData();
for (const property in obj) {
if (obj.hasOwnProperty(property)) {
const key = namespace ? `${namespace}[${property}]` : property;
@ashaffah
ashaffah / helper.rs
Created November 27, 2024 03:16
chrono_datetime_option_as_bson_datetime_option
pub mod chrono_datetime_option_as_bson_datetime_option {
use bson::{ Bson, DateTime };
use chrono::{ DateTime as ChronoDateTime, Utc };
use serde::{ Deserialize, Deserializer, Serialize, Serializer };
use std::result::Result;
use serde::de::Error;
pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<ChronoDateTime<Utc>>, D::Error>
where D: Deserializer<'de>
{