Skip to content

Instantly share code, notes, and snippets.

View itrobotics's full-sized avatar

Joseph itrobotics

View GitHub Profile
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
//
@itrobotics
itrobotics / Systimer.c
Last active February 7, 2022 15:43
Systimer
void My_Main(void)
{
GPIO_GPFSEL4 |= (0x1 << 21);
GPIO_GPFSEL4 &= ~(0x6 << 21);
// set bit 21~23 to 0b001, so GPIO 47 is an output pin
GPIO_GPCLR1 |= (0x1 << 15); // set GPIO 47 output low (LED off)
INT_DISIRQ1 = 0xFFFFFFFF;
INT_DISIRQ2 = 0xFFFFFFFF;
INT_DISBIRQ = 0xFF;
void SendByte( uint8 byte_value )
{
uint16 i;
uint8 cycle_cnt;
cycle_cnt = 8;
for( i= 0; i < cycle_cnt; i++ )
{
if ( (byte_value & IO_MASK) == 0x80 ){
SI = 1;
}