This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Whenever you are writing React/Next.js code, make sure to | |
- Follow Next.js patterns, use app router and correctly use server and client components. | |
- Use Tailwind CSS for styling. | |
- Use Shadcn UI for components. | |
- Use React Hook Form for form handling. | |
- Use Zod for validation. | |
- Use React Context for state management. | |
- Use Drizzle for database access. | |
- Use kebab-case, not PascalCase, when creating new React files. Use user-card, not UserCard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// just see the logic, some class and annotation is project related just ignore it. | |
@RestController | |
@Slf4j | |
@RequestMapping("/api/chat") | |
public class ChatController { | |
... ... | |
@LoginCheck | |
@PostMapping(value = "/stream-sse", produces = "text/event-stream") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{ | |
sync::mpsc::{channel, Receiver, Sender}, | |
thread::{self, JoinHandle}, time::Duration, | |
}; | |
#[derive(Debug)] | |
enum Request { | |
PrepareRequest { | |
rnd: i32, | |
reply_to: Sender<Response>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! need regex = "1.5" | |
use regex::Regex; | |
use std::env; | |
use std::fs; | |
use std::path::PathBuf; | |
fn main() { | |
// default is to remove header(better reading for some htmls exported by singleFile, like oreilly, etc) | |
let mut reg_str= r"<header.*>(.|\n)*?</header>"; | |
let args :Vec<String> = env::args().collect(); | |
let dir; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// https://leetcode.com/problems/two-sum/ | |
impl Solution { | |
fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> { | |
let mut nums2 = nums.clone(); | |
nums2.sort(); | |
let mut begin = 0; | |
let mut end = nums.len() - 1; | |
while begin < end { | |
let r = nums2[begin] + nums2[end]; | |
if r == target { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
camelcase = fn a -> Regex.replace(~r/_([a-z]+)/,a, fn _,<<w::utf8, b::binary>> -> String.upcase(<<w>>) <> b end) end | |
upcaseFirst = fn | |
"" -> "" | |
<<a::utf8, b::binary>> -> String.upcase(<<a>>) <> b | |
end | |
# md5 see https://gist.github.com/10nin/5713366 | |
def md5(data) do | |
Base.encode16(:erlang.md5(data), case: :lower) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
code = """ | |
`name` varchar(10) DEFAULT NULL', | |
`age` int NOT NULL DEFAULT '' | |
""" | |
def parse_field_name(s): | |
return re.sub(r"_(.)", lambda x: x.group(1).upper(), s.replace("`","")) | |
def parse_field_type(t): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cc.imageio.controller; | |
import java.awt.AlphaComposite; | |
import java.awt.Color; | |
import java.awt.Font; | |
import java.awt.Graphics2D; | |
import java.awt.Image; | |
import java.awt.image.BufferedImage; | |
import java.io.ByteArrayOutputStream; | |
import java.io.File; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.Net.Http | |
open System.Net.Mime | |
open System.Text | |
///get fileName by ContentDisposition or random file name if null | |
let getFileName (msg: HttpResponseMessage) = | |
let value = Option.ofObj msg.Content.Headers.ContentDisposition | |
let result = | |
value | |
|> Option.map (fun e -> e.FileName) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open MySql.Data.MySqlClient | |
open FSharp.Interop.Dynamic | |
open Dapper | |
open System | |
open System.Dynamic | |
type GList<'a> = System.Collections.Generic.List<'a> | |
type Ask() = | |
member val AskId = 0 with get,set |
NewerOlder