Skip to content

Instantly share code, notes, and snippets.

from pathlib import Path
from hachoir.parser import createParser
from hachoir.metadata import extractMetadata
from datetime import datetime
import os
import time
# dictionary generated by chatGPT
c = {
"Apr 10": 51,
@ixtk
ixtk / books.json
Created March 31, 2024 06:58
Sample MongoDB data
[
{
"title": "Me month black bank.",
"author": "Andrew Terry",
"publisher": {
"$oid": "5deaf6f8eb8f44ffae902cdb"
}
},
{
"title": "Cup feeling fear street.",
import express from "express"
import mongoose from "mongoose"
import { customAlphabet } from "nanoid"
const app = express()
app.use(express.json())
const nanoid = customAlphabet("1234567890abcdef", 8)
import "./App.css"
import { useState } from "react"
function App() {
const [loading, setLoading] = useState(false)
const demoFetch1 = () => {
fetch("https://jsonplaceholder.typicode.com/comments")
.then((response) => {
```
const CustomErrorMessage = (props) => {
// state simulation
const errorMessage = "Fullname is required"
// fun one liner
// return props.children?.(errorMessage) || <span>{errorMessage}</span>
if (props.children) {
return props.children(errorMessage)
@ixtk
ixtk / app.jsx
Created November 15, 2023 12:39
import "./App.css"
import { useState } from "react"
function App() {
const [todoText, setTodoText] = useState("")
const [todoList, setTodoList] = useState([
{ value: "do homework", isChecked: true, id: 0 },
{ value: "watch a movie", isChecked: false, id: 1 },
{ value: "make bed", isChecked: true, id: 2 }
])
import "./App.css"
import { useState } from "react"
function App() {
const [todoText, setTodoText] = useState("")
const [todoList, setTodoList] = useState([
{ value: "do homework", isChecked: false },
{ value: "watch a movie", isChecked: true },
{ value: "make bed", isChecked: true }
])
@ixtk
ixtk / topics.js
Last active November 6, 2023 15:09
const name = "John" // string
// name = "toma"
const age = 11 // number
const isRaining = false // boolean
const fruits = ["apple", "banana", "cherry"] // object (list)
const car = {
color: "red",
model: "Tesla",
[
{
"image": "https://s3.amazonaws.com/thumbnails.thecrimson.com/photos/2020/10/26/232756_1346454.jpg.1500x999_q95_crop-smart_upscale.jpg",
"title": "Inception - amazing movie with complex plot!",
"spoiler": false
},
{
"image": "https://variety.com/wp-content/uploads/2018/04/avengers-infinity-war-19.jpg?w=1000",
"title": "Let's talk about the ending of Avengers: Infinity war!",
"spoiler": true