Skip to content

Instantly share code, notes, and snippets.

View itrobotics's full-sized avatar

Joseph itrobotics

View GitHub Profile
# -*- coding: UTF-8 -*-
"""
https://blog.ittraining.com.tw/2024/10/normal-distribution.html
"""
import numpy as np
import matplotlib.pyplot as plt
#from matplotlib.mlab import bivariate_normal
import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import statsmodels.api as sm
def process_stock_data(df):
# Copy the DataFrame to avoid modifying the original
import openai
# Replace 'YOUR_API_KEY' with your actual API key from OpenAI
api_key = 'YOUR_API_KEY'
# Initialize the OpenAI API client
openai.api_key = api_key
# Specify the prompt for text generation
prompt = "Once upon a time,"
def ocr_by_goole_vision(input_file='captcha.png',draw_text=False):
with io.open(input_file, 'rb') as image_file:
content = image_file.read()
response = client.text_detection(image=vision.Image(content=content))
if response.error.message:
raise Exception(
c = [[]]*3 #[[], [], []]
print(c)
c[0].append(100)
print(c)
print(id(c[0])) #c[0]==c[1]==c[2]
print(id(c[1]))
from collections import defaultdict
from itertools import chain
from itertools import chain, combinations
'''
Why do we use frozenset ?
Example 1:
count[{'B','C'}]+=1 # TypeError Error : "unhashable type: 'set'"
#include <stdio.h>
#include <string.h>
int main ()
{
char method_str[]="GET /doc/test.html HTTP/1.1 \r\n";
char *url;
char *protocol;
char *end;
#include <stdio.h>
//#define DEBUG 3
#ifdef DEBUG
#define debug(fmt,args...) printf (fmt ,##args)
#define debugX(level,fmt,args...) if (DEBUG>=level) printf(fmt,##args);
#else
#define debug(fmt,args...)
static inline unsigned long __raw_spin_lock_irqsave(raw_spinlock_t *lock)
{
unsigned long flags;
local_irq_save(flags); // local CPU 中斷關閉, 防ISR搶
preempt_disable(); // preemptive 也禁止, 防止process 也來互搶
spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
....
// blink.c
//
// Example program for bcm2835 library
// Blinks a pin on an off every 0.5 secs
//
// After installing bcm2835, you can build this
// with something like:
// gcc -o blink blink.c -l bcm2835
// sudo ./blink
//