Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -14,819 +14,305 @@ app.logger = logging.getLogger("CodeSearchAPI")
|
|
14 |
# 预定义代码片段
|
15 |
CODE_SNIPPETS = [
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
"
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
}"
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
}"
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
}"
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
"""
|
223 |
-
|
224 |
-
|
225 |
-
"
|
226 |
-
|
227 |
-
|
228 |
-
"
|
229 |
-
|
230 |
-
|
231 |
-
"
|
232 |
-
|
233 |
-
|
234 |
-
"
|
235 |
-
|
236 |
-
|
237 |
-
"
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
"
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
"
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
}
|
257 |
-
}"
|
258 |
-
"
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
"
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
"
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
"
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
"
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
}
|
298 |
-
}"
|
299 |
-
"
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
"""
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
"
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
fmt.Println(dict)
|
315 |
-
}""",
|
316 |
-
"""func compareLists() {
|
317 |
-
fmt.Println(reflect.DeepEqual([]int{1, 2}, []int{1, 2}))
|
318 |
-
}""",
|
319 |
-
"""func compareDicts() {
|
320 |
-
fmt.Println(reflect.DeepEqual(map[string]int{"a": 1}, map[string]int{"a": 1}))
|
321 |
-
}""",
|
322 |
-
"""func compareSets() {
|
323 |
-
fmt.Println(reflect.DeepEqual(map[int]bool{1: true}, map[int]bool{1: true}))
|
324 |
-
}""",
|
325 |
-
"""func removeDuplicates() {
|
326 |
-
set := make(map[int]bool)
|
327 |
-
for _, v := range []int{1, 2, 2, 3} {
|
328 |
-
set[v] = true
|
329 |
-
}
|
330 |
-
fmt.Println(set)
|
331 |
-
}""",
|
332 |
-
"""func clearSet() {
|
333 |
-
set := map[int]bool{1: true, 2: true}
|
334 |
-
for k := range set {
|
335 |
-
delete(set, k)
|
336 |
-
}
|
337 |
-
fmt.Println(set)
|
338 |
-
}""",
|
339 |
-
"func isEmptySet(s map[interface{}]struct{}) bool { return len(s) == 0 }", "func addToSet(s map[interface{}]struct{}, element interface{}) { s[element] = struct{}{} }", "func removeFromSet(s map[interface{}]struct{}, element interface{}) { delete(s, element) }", "func containsInSet(s map[interface{}]struct{}, element interface{}) bool { _, exists := s[element]; return exists }", "func getSetLength(s map[interface{}]struct{}) int { return len(s) }", "func hasIntersection(s1, s2 map[interface{}]struct{}) bool { for k := range s1 { if _, exists := s2[k]; exists { return true } } return false }", "func isSubset(s1, s2 map[interface{}]struct{}) bool { for k := range s1 { if _, exists := s2[k]; !exists { return false } } return true }", "func isSubstring(s, substr string) bool { return strings.Contains(s, substr) }", "func getFirstChar(s string) string { return string(s[0]) }", "func getLastChar(s string) string { return string(s[len(s)-1]) }", "func isTextFile(filename string) bool { return strings.HasSuffix(filename, \".txt\") }", "func isImageFile(filename string) bool { ext := strings.ToLower(filepath.Ext(filename)); return ext == \".jpg\" || ext == \".png\" || ext == \".gif\" }", "func roundNumber(num float64) float64 { return math.Round(num) }", "func ceilNumber(num float64) float64 { return math.Ceil(num) }", "func floorNumber(num float64) float64 { return math.Floor(num) }", "func formatDecimal(num float64, precision int) string { return fmt.Sprintf(\"%.*f\", precision, num) }", "func generateRandomString(length int) string { rand.Seed(time.Now().UnixNano()); b := make([]byte, length); rand.Read(b); return fmt.Sprintf(\"%x\", b)[:length] }", "func pathExists(path string) bool { _, err := os.Stat(path); return !os.IsNotExist(err) }", """func listFilesInDir(dir string) []string {
|
340 |
-
var files []string
|
341 |
-
filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
|
342 |
-
if !info.IsDir() {
|
343 |
-
files = append(files, path)
|
344 |
-
}
|
345 |
-
return nil
|
346 |
-
})
|
347 |
-
return files
|
348 |
-
}""", "func getFileExtension(filename string) string { return filepath.Ext(filename) }", "func getFileName(filename string) string { return filepath.Base(filename) }", "func getFullPath(filename string) string { absPath, _ := filepath.Abs(filename); return absPath }", "func getPythonVersion() string { return runtime.Version() }", "func getPlatformInfo() string { return runtime.GOOS }", "func getCPUCores() int { return runtime.NumCPU() }", "func getMemorySize() uint64 { var mem runtime.MemStats; runtime.ReadMemStats(&mem); return mem.Sys }", """func getDiskUsage() string {
|
349 |
-
var stat syscall.Statfs_t
|
350 |
-
syscall.Statfs("/", &stat)
|
351 |
-
return fmt.Sprintf("Total: %d, Free: %d", stat.Blocks*uint64(stat.Bsize), stat.Bavail*uint64(stat.Bsize))
|
352 |
-
}""", "func getIPAddress() string { conn, _ := net.Dial(\"udp\", \"8.8.8.8:80\"); defer conn.Close(); return conn.LocalAddr().(*net.UDPAddr).IP.String() }", "func isConnected() bool { _, err := net.LookupIP(\"google.com\"); return err == nil }", """func downloadFile(url, filename string) error {
|
353 |
-
resp, err := http.Get(url)
|
354 |
-
if err != nil {
|
355 |
-
return err
|
356 |
-
}
|
357 |
-
defer resp.Body.Close()
|
358 |
-
out, err := os.Create(filename)
|
359 |
-
if err != nil {
|
360 |
-
return err
|
361 |
-
}
|
362 |
-
defer out.Close()
|
363 |
-
_, err = io.Copy(out, resp.Body)
|
364 |
-
return err
|
365 |
-
}""", """func uploadFile(filename string) string {
|
366 |
-
return fmt.Sprintf("File %s uploaded", filename)
|
367 |
-
}""", """func sendPostRequest(url string, data map[string]string) (string, error) {
|
368 |
-
jsonData, _ := json.Marshal(data)
|
369 |
-
resp, err := http.Post(url, "application/json", bytes.NewBuffer(jsonData))
|
370 |
-
if err != nil {
|
371 |
-
return "", err
|
372 |
-
}
|
373 |
-
defer resp.Body.Close()
|
374 |
-
body, _ := io.ReadAll(resp.Body)
|
375 |
-
return string(body), nil
|
376 |
-
}""", """func sendRequestWithParams(url string, params map[string]string) (string, error) {
|
377 |
-
req, err := http.NewRequest("GET", url, nil)
|
378 |
-
if err != nil {
|
379 |
-
return "", err
|
380 |
-
}
|
381 |
-
q := req.URL.Query()
|
382 |
-
for key, value := range params {
|
383 |
-
q.Add(key, value)
|
384 |
-
}
|
385 |
-
req.URL.RawQuery = q.Encode()
|
386 |
-
resp, err := http.DefaultClient.Do(req)
|
387 |
-
if err != nil {
|
388 |
-
return "", err
|
389 |
-
}
|
390 |
-
defer resp.Body.Close()
|
391 |
-
body, _ := io.ReadAll(resp.Body)
|
392 |
-
return string(body), nil
|
393 |
-
}""", """func setRequestHeader(req *http.Request, headers map[string]string) {
|
394 |
-
for key, value := range headers {
|
395 |
-
req.Header.Set(key, value)
|
396 |
-
}
|
397 |
-
}""", """func parseHTML(htmlContent string) (*goquery.Document, error) {
|
398 |
-
return goquery.NewDocumentFromReader(strings.NewReader(htmlContent))
|
399 |
-
}""", """func extractTitle(doc *goquery.Document) string {
|
400 |
-
return doc.Find("title").Text()
|
401 |
-
}""", """func extractLinks(doc *goquery.Document) []string {
|
402 |
-
var links []string
|
403 |
-
doc.Find("a").Each(func(i int, s *goquery.Selection) {
|
404 |
-
href, exists := s.Attr("href")
|
405 |
-
if exists {
|
406 |
-
links = append(links, href)
|
407 |
-
}
|
408 |
-
})
|
409 |
-
return links
|
410 |
-
}""", """func downloadImagesFromPage(url string) error {
|
411 |
-
doc, err := goquery.NewDocument(url)
|
412 |
-
if err != nil {
|
413 |
-
return err
|
414 |
-
}
|
415 |
-
doc.Find("img").Each(func(i int, s *goquery.Selection) {
|
416 |
-
src, exists := s.Attr("src")
|
417 |
-
if exists {
|
418 |
-
downloadFile(src, fmt.Sprintf("image%d.jpg", i))
|
419 |
-
}
|
420 |
-
})
|
421 |
-
return nil
|
422 |
-
}""", """func countWordFrequency(text string) map[string]int {
|
423 |
-
words := strings.Fields(text)
|
424 |
-
freq := make(map[string]int)
|
425 |
-
for _, word := range words {
|
426 |
-
freq[word]++
|
427 |
-
}
|
428 |
-
return freq
|
429 |
-
}""", """func simulateLogin(url, username, password string) (string, error) {
|
430 |
-
form := url.Values{}
|
431 |
-
form.Add("username", username)
|
432 |
-
form.Add("password", password)
|
433 |
-
resp, err := http.PostForm(url, form)
|
434 |
-
if err != nil {
|
435 |
-
return "", err
|
436 |
-
}
|
437 |
-
defer resp.Body.Close()
|
438 |
-
body, _ := io.ReadAll(resp.Body)
|
439 |
-
return string(body), nil
|
440 |
-
}""", """func htmlToText(htmlContent string) string {
|
441 |
-
doc, _ := goquery.NewDocumentFromReader(strings.NewReader(htmlContent))
|
442 |
-
return doc.Text()
|
443 |
-
}""", """func extractEmails(text string) []string {
|
444 |
-
re := regexp.MustCompile(`[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}`)
|
445 |
-
return re.FindAllString(text, -1)
|
446 |
-
}""", """func extractPhoneNumbers(text string) []string {
|
447 |
-
re := regexp.MustCompile(`\d{3}-\d{3}-\d{4}`)
|
448 |
-
return re.FindAllString(text, -1)
|
449 |
-
}""", """func findAllNumbers(text string) []string {
|
450 |
-
re := regexp.MustCompile(`\d+`)
|
451 |
-
return re.FindAllString(text, -1)
|
452 |
-
}""", """func replaceWithRegex(text, pattern, replacement string) string {
|
453 |
-
re := regexp.MustCompile(pattern)
|
454 |
-
return re.ReplaceAllString(text, replacement)
|
455 |
-
}""", """func matchRegex(text, pattern string) bool {
|
456 |
-
re := regexp.MustCompile(pattern)
|
457 |
-
return re.MatchString(text)
|
458 |
-
}""", """func removeHTMLTags(htmlContent string) string {
|
459 |
-
re := regexp.MustCompile(`<[^>]*>`)
|
460 |
-
return re.ReplaceAllString(htmlContent, "")
|
461 |
-
}""", """func encodeHTMLEntities(htmlContent string) string {
|
462 |
-
return html.EscapeString(htmlContent)
|
463 |
-
}""", """func decodeHTMLEntities(htmlContent string) string {
|
464 |
-
return html.UnescapeString(htmlContent)
|
465 |
-
}""", """func createGUIWindow() {
|
466 |
-
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
|
467 |
-
window.SetTitle("Simple GUI Window")
|
468 |
-
window.Connect("destroy", func() {
|
469 |
-
gtk.MainQuit()
|
470 |
-
})
|
471 |
-
window.ShowAll()
|
472 |
-
gtk.Main()
|
473 |
-
}""",
|
474 |
|
475 |
|
476 |
-
"func addButton(w fyne.Window) { w.SetContent(widget.NewButton(\"Button\", nil)) }",
|
477 |
-
"""func handleClick(b *widget.Button) {
|
478 |
-
b.OnTapped = func() { fmt.Println("Clicked") }
|
479 |
-
}""",
|
480 |
-
"""func showDialog(w fyne.Window) {
|
481 |
-
dialog.ShowInformation("Title", "Message", w)
|
482 |
-
}""",
|
483 |
-
"func getText(e *widget.Entry) string { return e.Text }",
|
484 |
-
"func setTitle(w fyne.Window) { w.SetTitle(\"Title\") }",
|
485 |
-
"func resizeWindow(w fyne.Window) { w.Resize(fyne.NewSize(800, 600)) }",
|
486 |
-
"func centerWindow(w fyne.Window) { w.CenterOnScreen() }",
|
487 |
-
"""func addMenu(w fyne.Window) {
|
488 |
-
menu := fyne.NewMainMenu(fyne.NewMenu("File"))
|
489 |
-
w.SetMainMenu(menu)
|
490 |
-
}""",
|
491 |
-
"func createSelect() *widget.Select { return widget.NewSelect([]string{\"a\", \"b\"}, func(s string) {}) }",
|
492 |
-
"func createRadio() *widget.RadioGroup { return widget.NewRadioGroup([]string{\"a\", \"b\"}, func(s string) {}) }",
|
493 |
-
"func createCheck() *widget.Check { return widget.NewCheck(\"Check\", func(b bool) {}) }",
|
494 |
-
"func showImage() *canvas.Image { return canvas.NewImageFromFile(\"image.png\") }",
|
495 |
-
"""func playAudio() {
|
496 |
-
exec.Command("afplay", "audio.mp3").Start()
|
497 |
-
}""",
|
498 |
-
"""func playVideo() {
|
499 |
-
exec.Command("vlc", "video.mp4").Start()
|
500 |
-
}""",
|
501 |
-
"func getTimestamp() int64 { return time.Now().Unix() }",
|
502 |
-
"""func timestampToDate(ts int64) string {
|
503 |
-
return time.Unix(ts, 0).Format("2006-01-02")
|
504 |
-
}""",
|
505 |
-
"""func dateToTimestamp(date string) int64 {
|
506 |
-
t, _ := time.Parse("2006-01-02", date)
|
507 |
-
return t.Unix()
|
508 |
-
}""",
|
509 |
-
"func getWeekday() string { return time.Now().Weekday().String() }",
|
510 |
-
"""func getMonthDays() int {
|
511 |
-
return time.Date(time.Now().Year(), time.Now().Month()+1, 0, 0, 0, 0, 0, time.UTC).Day()
|
512 |
-
}""",
|
513 |
-
"func firstDayOfYear() time.Time { return time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.UTC) }",
|
514 |
-
"func lastDayOfYear() time.Time { return time.Date(time.Now().Year(), 12, 31, 0, 0, 0, 0, time.UTC) }",
|
515 |
-
"""func firstDayOfMonth(year int, month time.Month) time.Time {
|
516 |
-
return time.Date(year, month, 1, 0, 0, 0, 0, time.UTC)
|
517 |
-
}""",
|
518 |
-
"""func lastDayOfMonth(year int, month time.Month) int {
|
519 |
-
return time.Date(year, month+1, 0, 0, 0, 0, 0, time.UTC).Day()
|
520 |
-
}""",
|
521 |
-
"func isWorkday() bool { wd := time.Now().Weekday(); return wd != time.Saturday && wd != time.Sunday }",
|
522 |
-
"func isWeekend() bool { wd := time.Now().Weekday(); return wd == time.Saturday || wd == time.Sunday }",
|
523 |
-
"func currentHour() int { return time.Now().Hour() }",
|
524 |
-
"func currentMinute() int { return time.Now().Minute() }",
|
525 |
-
"func currentSecond() int { return time.Now().Second() }",
|
526 |
-
"func sleep() { time.Sleep(time.Second) }",
|
527 |
-
"func millis() int64 { return time.Now().UnixNano() / int64(time.Millisecond) }",
|
528 |
-
"""func formatTime(t time.Time) string {
|
529 |
-
return t.Format("2006-01-02 15:04:05")
|
530 |
-
}""",
|
531 |
-
"""func parseTime(s string) time.Time {
|
532 |
-
t, _ := time.Parse("2006-01-02", s)
|
533 |
-
return t
|
534 |
-
}""",
|
535 |
-
"""func startThread() {
|
536 |
-
go func() { fmt.Println("Thread") }()
|
537 |
-
}""",
|
538 |
-
"func threadSleep() { time.Sleep(time.Second) }",
|
539 |
-
"""func multiThread() {
|
540 |
-
for i := 0; i < 3; i++ { go func(i int) {}(i) }
|
541 |
-
}""",
|
542 |
-
"func threadName() string { return runtime.Version() }",
|
543 |
-
"func setDaemon() { /* Not applicable in Go */ }",
|
544 |
-
"""func useMutex() {
|
545 |
-
var mu sync.Mutex
|
546 |
-
mu.Lock()
|
547 |
-
defer mu.Unlock()
|
548 |
-
}""",
|
549 |
-
"""func createProcess() {
|
550 |
-
cmd := exec.Command("ls")
|
551 |
-
cmd.Start()
|
552 |
-
}""",
|
553 |
-
"func getPID() int { return os.Getpid() }",
|
554 |
-
"""func isProcessAlive(pid int) bool {
|
555 |
-
err := syscall.Kill(pid, syscall.Signal(0))
|
556 |
-
return err == nil
|
557 |
-
}""",
|
558 |
-
"""func multiProcess() {
|
559 |
-
exec.Command("ls").Start()
|
560 |
-
}""",
|
561 |
-
"""func useQueue() {
|
562 |
-
ch := make(chan int)
|
563 |
-
go func() { ch <- 1 }()
|
564 |
-
<-ch
|
565 |
-
}""",
|
566 |
-
"""func usePipe() {
|
567 |
-
r, w, _ := os.Pipe()
|
568 |
-
w.Write([]byte("data"))
|
569 |
-
var b [4]byte
|
570 |
-
r.Read(b[:])
|
571 |
-
}""",
|
572 |
-
"func limitCPUUsage() { runtime.GOMAXPROCS(1) }",
|
573 |
-
"""func runShellCommand(cmd string) error {
|
574 |
-
return exec.Command("sh", "-c", cmd).Run()
|
575 |
-
}""",
|
576 |
-
"""func getCommandOutput(cmd string) (string, error) {
|
577 |
-
out, err := exec.Command("sh", "-c", cmd).Output()
|
578 |
-
return string(out), err
|
579 |
-
}""",
|
580 |
-
"""func getCommandStatus(cmd string) (int, error) {
|
581 |
-
err := exec.Command("sh", "-c", cmd).Run()
|
582 |
-
if err != nil {
|
583 |
-
if exitError, ok := err.(*exec.ExitError); ok {
|
584 |
-
return exitError.ExitCode(), nil
|
585 |
-
}
|
586 |
-
return -1, err
|
587 |
-
}
|
588 |
-
return 0, nil
|
589 |
-
}""",
|
590 |
-
"""func isCommandSuccess(cmd string) (bool, error) {
|
591 |
-
err := exec.Command("sh", "-c", cmd).Run()
|
592 |
-
return err == nil, err
|
593 |
-
}""",
|
594 |
-
"""func getCurrentScriptPath() string {
|
595 |
-
_, filename, _, _ := runtime.Caller(1)
|
596 |
-
return filepath.Dir(filename)
|
597 |
-
}""",
|
598 |
-
"""func getCommandLineArgs() []string {
|
599 |
-
return os.Args
|
600 |
-
}""",
|
601 |
-
"""func parseArgs() (string, int) {
|
602 |
-
var name string
|
603 |
-
var age int
|
604 |
-
flag.StringVar(&name, "name", "", "Name of the person")
|
605 |
-
flag.IntVar(&age, "age", 0, "Age of the person")
|
606 |
-
flag.Parse()
|
607 |
-
return name, age
|
608 |
-
}""",
|
609 |
-
"""func generateHelp() string {
|
610 |
-
flag.Usage()
|
611 |
-
return ""
|
612 |
-
}""",
|
613 |
-
"""func listPythonModules() {
|
614 |
-
exec.Command("python", "-c", "help('modules')").Run()
|
615 |
-
}""",
|
616 |
-
"""func installPythonPackage(pkg string) error {
|
617 |
-
return exec.Command("pip", "install", pkg).Run()
|
618 |
-
}""",
|
619 |
-
"""func uninstallPythonPackage(pkg string) error {
|
620 |
-
return exec.Command("pip", "uninstall", "-y", pkg).Run()
|
621 |
-
}""",
|
622 |
-
"""func getPackageVersion(pkg string) (string, error) {
|
623 |
-
out, err := exec.Command("pip", "show", pkg).Output()
|
624 |
-
if err != nil {
|
625 |
-
return "", err
|
626 |
-
}
|
627 |
-
return string(out), nil
|
628 |
-
}""",
|
629 |
-
"""func useVirtualEnv(envPath string) error {
|
630 |
-
return exec.Command("source", filepath.Join(envPath, "bin", "activate")).Run()
|
631 |
-
}""",
|
632 |
-
"""func listInstalledPackages() (string, error) {
|
633 |
-
out, err := exec.Command("pip", "list").Output()
|
634 |
-
return string(out), err
|
635 |
-
}""",
|
636 |
-
"""func upgradePythonPackage(pkg string) error {
|
637 |
-
return exec.Command("pip", "install", "--upgrade", pkg).Run()
|
638 |
-
}""",
|
639 |
-
"""func connectLocalDB(dbName string) (*sql.DB, error) {
|
640 |
-
return sql.Open("sqlite3", dbName)
|
641 |
-
}""",
|
642 |
-
"""func executeSQLQuery(db *sql.DB, query string) (*sql.Rows, error) {
|
643 |
-
return db.Query(query)
|
644 |
-
}""",
|
645 |
-
"""func insertRecord(db *sql.DB, query string, args ...interface{}) (sql.Result, error) {
|
646 |
-
return db.Exec(query, args...)
|
647 |
-
}""",
|
648 |
-
"""func deleteRecord(db *sql.DB, query string, args ...interface{}) (sql.Result, error) {
|
649 |
-
return db.Exec(query, args...)
|
650 |
-
}""",
|
651 |
-
"""func updateRecord(db *sql.DB, query string, args ...interface{}) (sql.Result, error) {
|
652 |
-
return db.Exec(query, args...)
|
653 |
-
}""",
|
654 |
-
"""func queryMultipleRecords(db *sql.DB, query string, args ...interface{}) (*sql.Rows, error) {
|
655 |
-
return db.Query(query, args...)
|
656 |
-
}""",
|
657 |
-
"""func useParameterizedQuery(db *sql.DB, query string, args ...interface{}) (*sql.Rows, error) {
|
658 |
-
return db.Query(query, args...)
|
659 |
-
}""",
|
660 |
-
"""func closeDBConnection(db *sql.DB) error {
|
661 |
-
return db.Close()
|
662 |
-
}""",
|
663 |
-
"""func createTable(db *sql.DB, query string) (sql.Result, error) {
|
664 |
-
return db.Exec(query)
|
665 |
-
}""",
|
666 |
-
"""func dropTable(db *sql.DB, query string) (sql.Result, error) {
|
667 |
-
return db.Exec(query)
|
668 |
-
}""",
|
669 |
-
"""func tableExists(db *sql.DB, tableName string) (bool, error) {
|
670 |
-
var exists bool
|
671 |
-
err := db.QueryRow("SELECT EXISTS (SELECT 1 FROM sqlite_master WHERE type='table' AND name=?)", tableName).Scan(&exists)
|
672 |
-
return exists, err
|
673 |
-
}""",
|
674 |
-
"""func listAllTables(db *sql.DB) ([]string, error) {
|
675 |
-
rows, err := db.Query("SELECT name FROM sqlite_master WHERE type='table'")
|
676 |
-
if err != nil {
|
677 |
-
return nil, err
|
678 |
-
}
|
679 |
-
defer rows.Close()
|
680 |
-
var tables []string
|
681 |
-
for rows.Next() {
|
682 |
-
var table string
|
683 |
-
if err := rows.Scan(&table); err != nil {
|
684 |
-
return nil, err
|
685 |
-
}
|
686 |
-
tables = append(tables, table)
|
687 |
-
}
|
688 |
-
return tables, nil
|
689 |
-
}""",
|
690 |
-
"""func exportToCSV(data [][]string, filename string) error {
|
691 |
-
file, err := os.Create(filename)
|
692 |
-
if err != nil {
|
693 |
-
return err
|
694 |
-
}
|
695 |
-
defer file.Close()
|
696 |
-
writer := csv.NewWriter(file)
|
697 |
-
return writer.WriteAll(data)
|
698 |
-
}""",
|
699 |
-
"""func exportToExcel(data [][]string, filename string) error {
|
700 |
-
file := excelize.NewFile()
|
701 |
-
for i, row := range data {
|
702 |
-
for j, cell := range row {
|
703 |
-
file.SetCellValue("Sheet1", fmt.Sprintf("%c%d", 'A'+j, i+1), cell)
|
704 |
-
}
|
705 |
-
}
|
706 |
-
return file.SaveAs(filename)
|
707 |
-
}""",
|
708 |
-
"""func exportToJSON(data interface{}, filename string) error {
|
709 |
-
file, err := os.Create(filename)
|
710 |
-
if err != nil {
|
711 |
-
return err
|
712 |
-
}
|
713 |
-
defer file.Close()
|
714 |
-
encoder := json.NewEncoder(file)
|
715 |
-
return encoder.Encode(data)
|
716 |
-
}""",
|
717 |
-
"""func readExcel(filename string) ([][]string, error) {
|
718 |
-
file, err := excelize.OpenFile(filename)
|
719 |
-
if err != nil {
|
720 |
-
return nil, err
|
721 |
-
}
|
722 |
-
rows, err := file.GetRows("Sheet1")
|
723 |
-
return rows, err
|
724 |
-
}""",
|
725 |
-
"""func mergeExcelFiles(files []string, output string) error {
|
726 |
-
merged := excelize.NewFile()
|
727 |
-
for _, file := range files {
|
728 |
-
f, err := excelize.OpenFile(file)
|
729 |
-
if err != nil {
|
730 |
-
return err
|
731 |
-
}
|
732 |
-
rows, err := f.GetRows("Sheet1")
|
733 |
-
if err != nil {
|
734 |
-
return err
|
735 |
-
}
|
736 |
-
for i, row := range rows {
|
737 |
-
for j, cell := range row {
|
738 |
-
merged.SetCellValue("Sheet1", fmt.Sprintf("%c%d", 'A'+j, i+1), cell)
|
739 |
-
}
|
740 |
-
}
|
741 |
-
}
|
742 |
-
return merged.SaveAs(output)
|
743 |
-
}""",
|
744 |
-
"""func addSheetToExcel(filename, sheetName string) error {
|
745 |
-
file, err := excelize.OpenFile(filename)
|
746 |
-
if err != nil {
|
747 |
-
return err
|
748 |
-
}
|
749 |
-
file.NewSheet(sheetName)
|
750 |
-
return file.Save()
|
751 |
-
}""",
|
752 |
-
"""func copyExcelStyle(src, dst string) error {
|
753 |
-
srcFile, err := excelize.OpenFile(src)
|
754 |
-
if err != nil {
|
755 |
-
return err
|
756 |
-
}
|
757 |
-
dstFile, err := excelize.OpenFile(dst)
|
758 |
-
if err != nil {
|
759 |
-
return err
|
760 |
-
}
|
761 |
-
styleID, err := srcFile.GetCellStyle("Sheet1", "A1")
|
762 |
-
if err != nil {
|
763 |
-
return err
|
764 |
-
}
|
765 |
-
dstFile.SetCellStyle("Sheet1", "A1", "A1", styleID)
|
766 |
-
return dstFile.Save()
|
767 |
-
}""",
|
768 |
-
"""func setExcelCellColor(filename, cell, color string) error {
|
769 |
-
file, err := excelize.OpenFile(filename)
|
770 |
-
if err != nil {
|
771 |
-
return err
|
772 |
-
}
|
773 |
-
styleID, err := file.NewStyle(&excelize.Style{Fill: excelize.Fill{Type: "pattern", Color: []string{color}, Pattern: 1}})
|
774 |
-
if err != nil {
|
775 |
-
return err
|
776 |
-
}
|
777 |
-
file.SetCellStyle("Sheet1", cell, cell, styleID)
|
778 |
-
return file.Save()
|
779 |
-
}""",
|
780 |
-
"""func setExcelFontStyle(filename, cell, fontName string, fontSize int) error {
|
781 |
-
file, err := excelize.OpenFile(filename)
|
782 |
-
if err != nil {
|
783 |
-
return err
|
784 |
-
}
|
785 |
-
styleID, err := file.NewStyle(&excelize.Style{Font: &excelize.Font{Family: fontName, Size: fontSize}})
|
786 |
-
if err != nil {
|
787 |
-
return err
|
788 |
-
}
|
789 |
-
file.SetCellStyle("Sheet1", cell, cell, styleID)
|
790 |
-
return file.Save()
|
791 |
-
}""",
|
792 |
-
"""func readExcelCell(filename, cell string) (string, error) {
|
793 |
-
file, err := excelize.OpenFile(filename)
|
794 |
-
if err != nil {
|
795 |
-
return "", err
|
796 |
-
}
|
797 |
-
return file.GetCellValue("Sheet1", cell)
|
798 |
-
}""",
|
799 |
-
"""func writeExcelCell(filename, cell, value string) error {
|
800 |
-
file, err := excelize.OpenFile(filename)
|
801 |
-
if err != nil {
|
802 |
-
return err
|
803 |
-
}
|
804 |
-
file.SetCellValue("Sheet1", cell, value)
|
805 |
-
return file.Save()
|
806 |
-
}""",
|
807 |
-
"""func getImageDimensions(filename string) (int, int, error) {
|
808 |
-
file, err := os.Open(filename)
|
809 |
-
if err != nil {
|
810 |
-
return 0, 0, err
|
811 |
-
}
|
812 |
-
defer file.Close()
|
813 |
-
img, _, err := image.DecodeConfig(file)
|
814 |
-
return img.Width, img.Height, err
|
815 |
-
}""",
|
816 |
-
"""func resizeImage(filename string, width, height int) error {
|
817 |
-
file, err := os.Open(filename)
|
818 |
-
if err != nil {
|
819 |
-
return err
|
820 |
-
}
|
821 |
-
defer file.Close()
|
822 |
-
img, _, err := image.Decode(file)
|
823 |
-
if err != nil {
|
824 |
-
return err
|
825 |
-
}
|
826 |
-
resized := imaging.Resize(img, width, height, imaging.Lanczos)
|
827 |
-
return imaging.Save(resized, filename)
|
828 |
-
}"""
|
829 |
-
|
830 |
|
831 |
|
832 |
|
|
|
14 |
# 预定义代码片段
|
15 |
CODE_SNIPPETS = [
|
16 |
|
17 |
+
"System.out.println(\"Hello, World!\");",
|
18 |
+
"public static int sum(int a, int b) { return a + b; }",
|
19 |
+
"import java.util.Random; public static int generateRandomNumber() { return new Random().nextInt(); }",
|
20 |
+
"public static boolean isEven(int number) { return number % 2 == 0; }",
|
21 |
+
"public static int stringLength(String str) { return str.length(); }",
|
22 |
+
"import java.time.LocalDate; public static String getCurrentDate() { return LocalDate.now().toString(); }",
|
23 |
+
"import java.io.File; public static boolean fileExists(String path) { return new File(path).exists(); }",
|
24 |
+
"import java.nio.file.Files; import java.nio.file.Paths; public static String readFileContent(String path) throws Exception { return new String(Files.readAllBytes(Paths.get(path))); }",
|
25 |
+
"import java.nio.file.Files; import java.nio.file.Paths; public static void writeToFile(String path, String content) throws Exception { Files.write(Paths.get(path), content.getBytes()); }",
|
26 |
+
"import java.time.LocalTime; public static String getCurrentTime() { return LocalTime.now().toString(); }",
|
27 |
+
"public static String toUpperCase(String str) { return str.toUpperCase(); }",
|
28 |
+
"public static String toLowerCase(String str) { return str.toLowerCase(); }",
|
29 |
+
"public static String reverseString(String str) { return new StringBuilder(str).reverse().toString(); }",
|
30 |
+
"public static int listSize(List<?> list) { return list.size(); }",
|
31 |
+
"public static int maxInList(List<Integer> list) { return Collections.max(list); }",
|
32 |
+
"public static int minInList(List<Integer> list) { return Collections.min(list); }",
|
33 |
+
"public static List<Integer> sortList(List<Integer> list) { Collections.sort(list); return list; }",
|
34 |
+
"public static List<?> mergeLists(List<?> list1, List<?> list2) { List<Object> merged = new ArrayList<>(list1); merged.addAll(list2); return merged; }",
|
35 |
+
"public static List<?> removeElement(List<?> list, Object element) { list.remove(element); return list; }",
|
36 |
+
"public static boolean isListEmpty(List<?> list) { return list.isEmpty(); }",
|
37 |
+
"public static int countCharInString(String str, char ch) { return (int) str.chars().filter(c -> c == ch).count(); }",
|
38 |
+
"public static boolean containsSubstring(String str, String sub) { return str.contains(sub); }",
|
39 |
+
"public static String intToString(int number) { return Integer.toString(number); }",
|
40 |
+
"public static int stringToInt(String str) { return Integer.parseInt(str); }",
|
41 |
+
"public static boolean isNumeric(String str) { return str.matches(\"-?\\\\d+(\\\\.\\\\d+)?\"); }",
|
42 |
+
"public static int indexOfElement(List<?> list, Object element) { return list.indexOf(element); }",
|
43 |
+
"public static void clearList(List<?> list) { list.clear(); }",
|
44 |
+
"public static List<?> reverseList(List<?> list) { Collections.reverse(list); return list; }",
|
45 |
+
"public static List<?> removeDuplicates(List<?> list) { return new ArrayList<>(new LinkedHashSet<>(list)); }",
|
46 |
+
"public static boolean isInList(List<?> list, Object element) { return list.contains(element); }",
|
47 |
+
"public static Map<?, ?> createDictionary() { return new HashMap<>(); }",
|
48 |
+
"public static void addToDictionary(Map<?, ?> map, Object key, Object value) { ((Map<Object, Object>) map).put(key, value); }",
|
49 |
+
"public static void removeFromDictionary(Map<?, ?> map, Object key) { map.remove(key); }",
|
50 |
+
"public static Set<?> getDictionaryKeys(Map<?, ?> map) { return map.keySet(); }",
|
51 |
+
"public static Collection<?> getDictionaryValues(Map<?, ?> map) { return map.values(); }",
|
52 |
+
"public static Map<?, ?> mergeDictionaries(Map<?, ?> map1, Map<?, ?> map2) { Map<Object, Object> merged = new HashMap<>(map1); merged.putAll(map2); return merged; }",
|
53 |
+
"public static boolean isDictionaryEmpty(Map<?, ?> map) { return map.isEmpty(); }",
|
54 |
+
"public static Object getDictionaryValue(Map<?, ?> map, Object key) { return map.get(key); }",
|
55 |
+
"public static boolean keyExistsInDictionary(Map<?, ?> map, Object key) { return map.containsKey(key); }",
|
56 |
+
"public static void clearDictionary(Map<?, ?> map) { map.clear(); }",
|
57 |
+
"public static int countFileLines(String path) throws Exception { return (int) Files.lines(Paths.get(path)).count(); }",
|
58 |
+
"import java.nio.file.Files; import java.nio.file.Paths; public static void writeListToFile(String path, List<?> list) throws Exception { Files.write(Paths.get(path), list.toString().getBytes()); }",
|
59 |
+
"import java.nio.file.Files; import java.nio.file.Paths; public static List<?> readListFromFile(String path) throws Exception { return Arrays.asList(new String(Files.readAllBytes(Paths.get(path))).split(\",\")); }",
|
60 |
+
"public static int countWordsInFile(String path) throws Exception { return (int) Files.lines(Paths.get(path)).flatMap(line -> Arrays.stream(line.split(\"\\\\s+\"))).count(); }",
|
61 |
+
"public static boolean isLeapYear(int year) { return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); }",
|
62 |
+
"import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; public static String formatDateTime(LocalDateTime dateTime, String pattern) { return dateTime.format(DateTimeFormatter.ofPattern(pattern)); }",
|
63 |
+
"import java.time.LocalDate; import java.time.temporal.ChronoUnit; public static long daysBetweenDates(LocalDate date1, LocalDate date2) { return ChronoUnit.DAYS.between(date1, date2); }",
|
64 |
+
"import java.nio.file.Paths; public static String getCurrentWorkingDirectory() { return Paths.get(\"\").toAbsolutePath().toString(); }",
|
65 |
+
"import java.io.File; public static List<String> listFilesInDirectory(String path) { return Arrays.stream(new File(path).listFiles()).map(File::getName).collect(Collectors.toList()); }",
|
66 |
+
"import java.nio.file.Files; import java.nio.file.Paths; public static void createDirectory(String path) throws Exception { Files.createDirectory(Paths.get(path)); }",
|
67 |
+
"import java.nio.file.Files; import java.nio.file.Paths; public static void deleteDirectory(String path) throws Exception { Files.delete(Paths.get(path)); }",
|
68 |
+
"import java.nio.file.Files; import java.nio.file.Paths; public static boolean isFile(String path) { return Files.isRegularFile(Paths.get(path)); }",
|
69 |
+
"import java.nio.file.Files; import java.nio.file.Paths; public static boolean isDirectory(String path) { return Files.isDirectory(Paths.get(path)); }",
|
70 |
+
"import java.nio.file.Files; import java.nio.file.Paths; public static long getFileSize(String path) throws Exception { return Files.size(Paths.get(path)); }",
|
71 |
+
"import java.nio.file.Files; import java.nio.file.Paths; public static void renameFile(String oldPath, String newPath) throws Exception { Files.move(Paths.get(oldPath), Paths.get(newPath)); }",
|
72 |
+
"import java.nio.file.Files; import java.nio.file.Paths; public static void copyFile(String source, String destination) throws Exception { Files.copy(Paths.get(source), Paths.get(destination)); }",
|
73 |
+
"import java.nio.file.Files; import java.nio.file.Paths; public static void moveFile(String source, String destination) throws Exception { Files.move(Paths.get(source), Paths.get(destination)); }",
|
74 |
+
"import java.nio.file.Files; import java.nio.file.Paths; public static void deleteFile(String path) throws Exception { Files.delete(Paths.get(path)); }",
|
75 |
+
"public static String getEnvironmentVariable(String name) { return System.getenv(name); }",
|
76 |
+
"public static void setEnvironmentVariable(String name, String value) { System.setProperty(name, value); }",
|
77 |
+
"import java.awt.Desktop; import java.net.URI; public static void openWebLink(String url) throws Exception { Desktop.getDesktop().browse(new URI(url)); }",
|
78 |
+
"import java.net.HttpURLConnection; import java.net.URL; public static String sendGetRequest(String url) throws Exception { HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection(); con.setRequestMethod(\"GET\"); return new String(con.getInputStream().readAllBytes()); }",
|
79 |
+
"import com.google.gson.JsonObject; import com.google.gson.JsonParser; public static JsonObject parseJson(String json) { return JsonParser.parseString(json).getAsJsonObject(); }",
|
80 |
+
"import com.google.gson.Gson; import java.nio.file.Files; import java.nio.file.Paths; public static void writeJsonToFile(String path, JsonObject json) throws Exception { Files.write(Paths.get(path), new Gson().toJson(json).getBytes()); }",
|
81 |
+
"import com.google.gson.JsonObject; import com.google.gson.JsonParser; import java.nio.file.Files; import java.nio.file.Paths; public static JsonObject readJsonFromFile(String path) throws Exception { return JsonParser.parseString(new String(Files.readAllBytes(Paths.get(path)))).getAsJsonObject(); }",
|
82 |
+
"public static String listToString(List<?> list) { return list.toString(); }",
|
83 |
+
"public static List<String> stringToList(String str) { return Arrays.asList(str.split(\",\")); }",
|
84 |
+
"public static String joinWithComma(List<?> list) { return String.join(\",\", list.stream().map(Object::toString).collect(Collectors.toList())); }",
|
85 |
+
"public static String joinWithNewline(List<?> list) { return String.join(\"\\n\", list.stream().map(Object::toString).collect(Collectors.toList())); }",
|
86 |
+
"public static List<String> splitBySpace(String str) { return Arrays.asList(str.split(\"\\\\s+\")); }",
|
87 |
+
"public static List<String> splitByDelimiter(String str, String delimiter) { return Arrays.asList(str.split(delimiter)); }",
|
88 |
+
"public static List<String> splitIntoCharacters(String str) { return Arrays.asList(str.split(\"\")); }",
|
89 |
+
"public static String replaceInString(String str, String target, String replacement) { return str.replace(target, replacement); }",
|
90 |
+
"public static String removeSpaces(String str) { return str.replaceAll(\"\\\\s\", \"\"); }",
|
91 |
+
"public static String removePunctuation(String str) { return str.replaceAll(\"[^a-zA-Z0-9]\", \"\"); }",
|
92 |
+
"public static boolean isStringEmpty(String str) { return str.isEmpty(); }",
|
93 |
+
"public static boolean isPalindrome(String str) { return str.equals(new StringBuilder(str).reverse().toString()); }",
|
94 |
+
"import java.nio.file.Files; import java.nio.file.Paths; public static void writeTextToCsv(String path, List<String> lines) throws Exception { Files.write(Paths.get(path), lines); }",
|
95 |
+
"import java.nio.file.Files; import java.nio.file.Paths; public static List<String> readCsvFile(String path) throws Exception { return Files.readAllLines(Paths.get(path)); }",
|
96 |
+
"import java.nio.file.Files; import java.nio.file.Paths; public static int countCsvLines(String path) throws Exception { return (int) Files.lines(Paths.get(path)).count(); }",
|
97 |
+
"public static List<?> shuffleList(List<?> list) { Collections.shuffle(list); return list; }",
|
98 |
+
"public static Object pickRandomElement(List<?> list) { return list.get(new Random().nextInt(list.size())); }",
|
99 |
+
"public static List<?> pickRandomElements(List<?> list, int count) { Collections.shuffle(list); return list.subList(0, count); }",
|
100 |
+
"public static int rollDice() { return new Random().nextInt(6) + 1; }",
|
101 |
+
"public static String flipCoin() { return new Random().nextBoolean() ? \"Heads\" : \"Tails\"; }",
|
102 |
+
"import java.util.Random; public static String generateRandomPassword(int length) { String chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\"; StringBuilder sb = new StringBuilder(); for (int i = 0; i < length; i++) { sb.append(chars.charAt(new Random().nextInt(chars.length()))); } return sb.toString(); }",
|
103 |
+
"import java.util.Random; public static String generateRandomColor() { Random rand = new Random(); return String.format(\"#%06x\", rand.nextInt(0xFFFFFF)); }",
|
104 |
+
"import java.util.UUID; public static String generateUniqueId() { return UUID.randomUUID().toString(); }",
|
105 |
+
"public class MyClass {}",
|
106 |
+
"MyClass myObject = new MyClass();",
|
107 |
+
"public class MyClass { public void myMethod() {} }",
|
108 |
+
"public class MyClass { public String myAttribute; }",
|
109 |
+
"public class ChildClass extends ParentClass {}",
|
110 |
+
"public class ChildClass extends ParentClass { @Override public void myMethod() {} }",
|
111 |
+
"public class MyClass { public static void myClassMethod() {} }",
|
112 |
+
"public class MyClass { public static void myStaticMethod() {} }",
|
113 |
+
"public static boolean isInstanceOf(Object obj, Class<?> clazz) { return clazz.isInstance(obj); }",
|
114 |
+
"public static Object getAttribute(Object obj, String attribute) throws Exception { return obj.getClass().getDeclaredField(attribute).get(obj); }",
|
115 |
+
"public static void setAttribute(Object obj, String attribute, Object value) throws Exception { obj.getClass().getDeclaredField(attribute).set(obj, value); }",
|
116 |
+
"public static void deleteAttribute(Object obj, String attribute) throws Exception { obj.getClass().getDeclaredField(attribute).set(obj, null); }",
|
117 |
+
"try { int result = 10 / 0; } catch (Exception e) { System.out.println(e.getMessage()); }",
|
118 |
+
"throw new Exception('Custom exception');",
|
119 |
+
"String message = e.getMessage();",
|
120 |
+
"Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, e);",
|
121 |
+
"long startTime = System.currentTimeMillis();",
|
122 |
+
"long endTime = System.currentTimeMillis(); long duration = endTime - startTime;",
|
123 |
+
"for (int i = 0; i <= 100; i++) { System.out.print('\\rProgress: ' + i + '%'); }",
|
124 |
+
"Thread.sleep(1000);",
|
125 |
+
"Runnable r = () -> System.out.println('Lambda expression');",
|
126 |
+
"List<Integer> squared = Arrays.asList(1, 2, 3).stream().map(x -> x * x).collect(Collectors.toList());",
|
127 |
+
"List<Integer> evenNumbers = Arrays.asList(1, 2, 3, 4).stream().filter(x -> x % 2 == 0).collect(Collectors.toList());",
|
128 |
+
"int sum = Arrays.asList(1, 2, 3).stream().reduce(0, (a, b) -> a + b);",
|
129 |
+
"List<Integer> squares = Arrays.asList(1, 2, 3).stream().map(x -> x * x).collect(Collectors.toList());",
|
130 |
+
"Map<String, Integer> map = Arrays.asList('a', 'b').stream().collect(Collectors.toMap(Function.identity(), String::length));",
|
131 |
+
"Set<Integer> set = Arrays.asList(1, 2, 3).stream().collect(Collectors.toSet());",
|
132 |
+
"Set<Integer> intersection = new HashSet<>(set1); intersection.retainAll(set2);",
|
133 |
+
"Set<Integer> union = new HashSet<>(set1); union.addAll(set2);",
|
134 |
+
"Set<Integer> difference = new HashSet<>(set1); difference.removeAll(set2);",
|
135 |
+
"List<String> listWithoutNull = list.stream().filter(Objects::nonNull).collect(Collectors.toList());",
|
136 |
+
"try (BufferedReader br = new BufferedReader(new FileReader('file.txt'))) { } catch (IOException e) { }",
|
137 |
+
"if (variable instanceof Integer) { }",
|
138 |
+
"boolean bool = Boolean.parseBoolean('true');",
|
139 |
+
"if (condition) { }",
|
140 |
+
"while (condition) { }",
|
141 |
+
"for (String item : list) { }",
|
142 |
+
"for (Map.Entry<String, Integer> entry : map.entrySet()) { }",
|
143 |
+
"for (char c : 'string'.toCharArray()) { }",
|
144 |
+
"break;",
|
145 |
+
"continue;",
|
146 |
+
"void myFunction() { }",
|
147 |
+
"void myFunction(String param = 'default') { }",
|
148 |
+
"return new Object[] { value1, value2 };",
|
149 |
+
"void myFunction(String... args) { }",
|
150 |
+
"void myFunction(Map<String, String> kwargs) { }",
|
151 |
+
"long startTime = System.currentTimeMillis(); myFunction(); long endTime = System.currentTimeMillis(); long duration = endTime - startTime;",
|
152 |
+
"@Decorator public void myFunction() { }",
|
153 |
+
"Map<String, Object> cache = new HashMap<>();",
|
154 |
+
"Stream<Integer> stream = Stream.of(1, 2, 3);",
|
155 |
+
"yield return value;",
|
156 |
+
"int nextValue = generator.next();",
|
157 |
+
"Iterator<Integer> iterator = list.iterator();",
|
158 |
+
"while (iterator.hasNext()) { int next = iterator.next(); }",
|
159 |
+
"for (int i = 0; i < list.size(); i++) { System.out.println(i + ' ' + list.get(i)); }",
|
160 |
+
"List<String> combined = Stream.concat(list1.stream(), list2.stream()).collect(Collectors.toList());",
|
161 |
+
"Map<String, Integer> map = new HashMap<>(); for (int i = 0; i < keys.size(); i++) { map.put(keys.get(i), values.get(i)); }",
|
162 |
+
"boolean equal = list1.equals(list2);",
|
163 |
+
"boolean equal = map1.equals(map2);",
|
164 |
+
"boolean equal = set1.equals(set2);",
|
165 |
+
"Set<Integer> uniqueSet = new HashSet<>(list);",
|
166 |
+
"set.clear();",
|
167 |
+
"boolean isEmpty = set.isEmpty();",
|
168 |
+
"set.add(element);",
|
169 |
+
"set.remove(element);",
|
170 |
+
"boolean contains = set.contains(element);",
|
171 |
+
"int size = set.size();",
|
172 |
+
"boolean hasIntersection = !Collections.disjoint(set1, set2);",
|
173 |
+
"boolean isSubset = set1.containsAll(set2);",
|
174 |
+
"boolean isSubstring = 'hello'.contains('ell');",
|
175 |
+
"char firstChar = 'hello'.charAt(0);",
|
176 |
+
"char lastChar = 'hello'.charAt('hello'.length() - 1);",
|
177 |
+
"boolean isTextFile = fileName.endsWith('.txt');",
|
178 |
+
"boolean isImageFile = fileName.endsWith('.jpg') || fileName.endsWith('.png');",
|
179 |
+
"long rounded = Math.round(3.14);",
|
180 |
+
"long ceil = (long) Math.ceil(3.14);",
|
181 |
+
"long floor = (long) Math.floor(3.14);",
|
182 |
+
"String formatted = String.format('%.2f', 3.14159);",
|
183 |
+
"String randomString = new Random().ints(10, 97, 123).mapToObj(i -> (char) i).collect(StringBuilder::new, StringBuilder::append, StringBuilder::append).toString();",
|
184 |
+
"boolean exists = new File('path').exists();",
|
185 |
+
"File[] files = new File('path').listFiles();",
|
186 |
+
"String extension = fileName.substring(fileName.lastIndexOf('.') + 1);",
|
187 |
+
"String fileName = new File('path').getName();",
|
188 |
+
"String fullPath = new File('path').getAbsolutePath();",
|
189 |
+
"String version = System.getProperty('java.version');",
|
190 |
+
"String os = System.getProperty('os.name');",
|
191 |
+
"int cores = Runtime.getRuntime().availableProcessors();",
|
192 |
+
"long memory = Runtime.getRuntime().totalMemory();",
|
193 |
+
"File file = new File('path'); long freeSpace = file.getFreeSpace();",
|
194 |
+
"String ip = InetAddress.getLocalHost().getHostAddress();",
|
195 |
+
"boolean isConnected = InetAddress.getByName('www.google.com').isReachable(1000);",
|
196 |
+
"URL url = new URL('http://example.com/file.txt'); try (InputStream in = url.openStream()) { Files.copy(in, Paths.get('file.txt'), StandardCopyOption.REPLACE_EXISTING); }",
|
197 |
+
"HttpURLConnection connection = (HttpURLConnection) new URL('http://example.com').openConnection(); connection.setRequestMethod('POST');",
|
198 |
+
"HttpURLConnection connection = (HttpURLConnection) new URL('http://example.com').openConnection(); connection.setRequestMethod('GET'); connection.setRequestProperty('User-Agent', 'Mozilla/5.0');",
|
199 |
+
"Document doc = Jsoup.connect('http://example.com').get();",
|
200 |
+
"String title = doc.title();",
|
201 |
+
"Elements links = doc.select('a[href]');",
|
202 |
+
"Elements images = doc.select('img[src]');",
|
203 |
+
"Map<String, Integer> wordFrequency = new HashMap<>(); for (String word : text.split(' ')) { wordFrequency.put(word, wordFrequency.getOrDefault(word, 0) + 1); }",
|
204 |
+
"Connection.Response loginForm = Jsoup.connect('http://example.com/login').method(Connection.Method.GET).execute(); Map<String, String> cookies = loginForm.cookies(); Document doc = Jsoup.connect('http://example.com/login').data('username', 'user', 'password', 'pass').cookies(cookies).post();",
|
205 |
+
"String text = Jsoup.parse(html).text();",
|
206 |
+
"Pattern pattern = Pattern.compile('[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}'); Matcher matcher = pattern.matcher(text); while (matcher.find()) { System.out.println(matcher.group()); }",
|
207 |
+
"Pattern pattern = Pattern.compile('\\d{3}-\\d{3}-\\d{4}'); Matcher matcher = pattern.matcher(text); while (matcher.find()) { System.out.println(matcher.group()); }",
|
208 |
+
"Pattern pattern = Pattern.compile('\\d+'); Matcher matcher = pattern.matcher(text); while (matcher.find()) { System.out.println(matcher.group()); }",
|
209 |
+
"String replaced = text.replaceAll('pattern', 'replacement');",
|
210 |
+
"boolean matches = Pattern.matches('pattern', text);",
|
211 |
+
"String text = html.replaceAll('<[^>]+>', '');",
|
212 |
+
"String encoded = StringEscapeUtils.escapeHtml4(html);",
|
213 |
+
"String decoded = StringEscapeUtils.unescapeHtml4(html);",
|
214 |
+
"JFrame frame = new JFrame('Simple GUI'); frame.setSize(300, 200); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);",
|
215 |
+
"JFrame frame = new JFrame(); JButton button = new JButton(\"Click Me\"); frame.add(button);",
|
216 |
+
"button.addActionListener(e -> JOptionPane.showMessageDialog(frame, \"Button Clicked!\"));",
|
217 |
+
"String input = JOptionPane.showInputDialog(frame, \"Enter something:\");",
|
218 |
+
"frame.setTitle(\"My Window\");",
|
219 |
+
"frame.setSize(400, 300);",
|
220 |
+
"frame.setLocationRelativeTo(null);",
|
221 |
+
"JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu(\"File\"); menuBar.add(menu); frame.setJMenuBar(menuBar);",
|
222 |
+
"JComboBox<String> comboBox = new JComboBox<>(new String[]{\"Option 1\", \"Option 2\"}); frame.add(comboBox);",
|
223 |
+
"JRadioButton radioButton = new JRadioButton(\"Select Me\"); frame.add(radioButton);",
|
224 |
+
"JCheckBox checkBox = new JCheckBox(\"Check Me\"); frame.add(checkBox);",
|
225 |
+
"JLabel label = new JLabel(new ImageIcon(\"image.jpg\")); frame.add(label);",
|
226 |
+
"Clip clip = AudioSystem.getClip(); clip.open(AudioSystem.getAudioInputStream(new File(\"audio.wav\"))); clip.start();",
|
227 |
+
"JFrame videoFrame = new JFrame(); Player player = Manager.createRealizedPlayer(new File(\"video.mp4\").toURI().toURL()); player.start();",
|
228 |
+
"long currentTime = player.getTimeNanoseconds();",
|
229 |
+
"Robot robot = new Robot(); BufferedImage screenshot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));",
|
230 |
+
"Robot robot = new Robot(); robot.delay(5000); BufferedImage screenRecording = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));",
|
231 |
+
"PointerInfo pointerInfo = MouseInfo.getPointerInfo(); Point point = pointerInfo.getLocation();",
|
232 |
+
"Robot robot = new Robot(); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A);",
|
233 |
+
"Robot robot = new Robot(); robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);",
|
234 |
+
"long timestamp = System.currentTimeMillis();",
|
235 |
+
"Date date = new Date(timestamp);",
|
236 |
+
"long timestamp = date.getTime();",
|
237 |
+
"int dayOfWeek = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);",
|
238 |
+
"int daysInMonth = Calendar.getInstance().getActualMaximum(Calendar.DAY_OF_MONTH);",
|
239 |
+
"Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_YEAR, 1); Date firstDayOfYear = calendar.getTime();",
|
240 |
+
"Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_YEAR, calendar.getActualMaximum(Calendar.DAY_OF_YEAR)); Date lastDayOfYear = calendar.getTime();",
|
241 |
+
"Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_MONTH, 1); Date firstDayOfMonth = calendar.getTime();",
|
242 |
+
"Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); Date lastDayOfMonth = calendar.getTime();",
|
243 |
+
"int dayOfWeek = Calendar.getInstance().get(Calendar.DAY_OF_WEEK); boolean isWeekday = dayOfWeek >= Calendar.MONDAY && dayOfWeek <= Calendar.FRIDAY;",
|
244 |
+
"int dayOfWeek = Calendar.getInstance().get(Calendar.DAY_OF_WEEK); boolean isWeekend = dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY;",
|
245 |
+
"int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);",
|
246 |
+
"int minute = Calendar.getInstance().get(Calendar.MINUTE);",
|
247 |
+
"int second = Calendar.getInstance().get(Calendar.SECOND);",
|
248 |
+
"Thread.sleep(1000);",
|
249 |
+
"long millisTimestamp = System.currentTimeMillis();",
|
250 |
+
"SimpleDateFormat sdf = new SimpleDateFormat(\"yyyy-MM-dd HH:mm:ss\"); String formattedDate = sdf.format(new Date());",
|
251 |
+
"SimpleDateFormat sdf = new SimpleDateFormat(\"yyyy-MM-dd HH:mm:ss\"); Date date = sdf.parse(\"2023-10-01 12:00:00\");",
|
252 |
+
"Thread thread = new Thread(() -> {}); thread.start();",
|
253 |
+
"Thread.sleep(1000);",
|
254 |
+
"ExecutorService executor = Executors.newFixedThreadPool(2); executor.submit(() -> {}); executor.submit(() -> {});",
|
255 |
+
"String threadName = Thread.currentThread().getName();",
|
256 |
+
"Thread thread = new Thread(() -> {}); thread.setDaemon(true); thread.start();",
|
257 |
+
"ReentrantLock lock = new ReentrantLock(); lock.lock(); try {} finally { lock.unlock(); }",
|
258 |
+
"Process process = Runtime.getRuntime().exec(\"notepad.exe\");",
|
259 |
+
"long pid = process.pid();",
|
260 |
+
"boolean isAlive = process.isAlive();",
|
261 |
+
"ExecutorService executor = Executors.newFixedThreadPool(2); executor.submit(() -> {}); executor.submit(() -> {});",
|
262 |
+
"BlockingQueue<Integer> queue = new LinkedBlockingQueue<>(); queue.put(1); int value = queue.take();",
|
263 |
+
"PipedInputStream in = new PipedInputStream(); PipedOutputStream out = new PipedOutputStream(in);",
|
264 |
+
"Thread.sleep(1000);",
|
265 |
+
"Process process = Runtime.getRuntime().exec(\"ls\");",
|
266 |
+
"BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line = reader.readLine();",
|
267 |
+
"int exitCode = process.waitFor();",
|
268 |
+
"boolean isSuccess = exitCode == 0;",
|
269 |
+
"String scriptPath = new File(\"\").getAbsolutePath();",
|
270 |
+
"String[] args = new String[]{\"arg1\", \"arg2\"};",
|
271 |
+
"Parser parser = new Parser(); parser.parse(args);",
|
272 |
+
"parser.printHelp();",
|
273 |
+
"ModuleLayer layer = ModuleLayer.boot(); layer.modules().forEach(System.out::println);",
|
274 |
+
"Process process = Runtime.getRuntime().exec(\"pip install package\");",
|
275 |
+
"Process process = Runtime.getRuntime().exec(\"pip uninstall package\");",
|
276 |
+
"String version = Package.getPackage(\"package\").getImplementationVersion();",
|
277 |
+
"Process process = Runtime.getRuntime().exec(\"python -m venv venv\");",
|
278 |
+
"Process process = Runtime.getRuntime().exec(\"pip list\");",
|
279 |
+
"Process process = Runtime.getRuntime().exec(\"pip install --upgrade package\");",
|
280 |
+
"Connection conn = DriverManager.getConnection(\"jdbc:sqlite:sample.db\");",
|
281 |
+
"Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(\"SELECT * FROM table\");",
|
282 |
+
"PreparedStatement pstmt = conn.prepareStatement(\"INSERT INTO table (column) VALUES (?)\"); pstmt.setString(1, \"value\"); pstmt.executeUpdate();",
|
283 |
+
"PreparedStatement pstmt = conn.prepareStatement(\"DELETE FROM table WHERE id = ?\"); pstmt.setInt(1, 1); pstmt.executeUpdate();",
|
284 |
+
"PreparedStatement pstmt = conn.prepareStatement(\"UPDATE table SET column = ? WHERE id = ?\"); pstmt.setString(1, \"new_value\"); pstmt.setInt(2, 1); pstmt.executeUpdate();",
|
285 |
+
"PreparedStatement pstmt = conn.prepareStatement(\"SELECT * FROM table\"); ResultSet rs = pstmt.executeQuery();",
|
286 |
+
"PreparedStatement pstmt = conn.prepareStatement(\"SELECT * FROM table WHERE column = ?\"); pstmt.setString(1, \"value\"); ResultSet rs = pstmt.executeQuery();",
|
287 |
+
"conn.close();",
|
288 |
+
"Statement stmt = conn.createStatement(); stmt.execute(\"CREATE TABLE table (id INT, column VARCHAR(255))\");",
|
289 |
+
"Statement stmt = conn.createStatement(); stmt.execute(\"DROP TABLE table\");",
|
290 |
+
"DatabaseMetaData metaData = conn.getMetaData(); ResultSet rs = metaData.getTables(null, null, \"table\", null); boolean exists = rs.next();",
|
291 |
+
"DatabaseMetaData metaData = conn.getMetaData(); ResultSet rs = metaData.getTables(null, null, null, new String[]{\"TABLE\"});",
|
292 |
+
"Session session = sessionFactory.openSession(); session.save(new Entity());",
|
293 |
+
"Session session = sessionFactory.openSession(); List<Entity> entities = session.createQuery(\"FROM Entity\").list();",
|
294 |
+
"Session session = sessionFactory.openSession(); session.delete(session.get(Entity.class, 1));",
|
295 |
+
"Session session = sessionFactory.openSession(); Entity entity = session.get(Entity.class, 1); entity.setColumn(\"new_value\"); session.update(entity);",
|
296 |
+
"class Entity { @Id @GeneratedValue private int id; private String column; }",
|
297 |
+
"class ChildEntity extends ParentEntity {}",
|
298 |
+
"class Entity { @Id @GeneratedValue private int id; }",
|
299 |
+
"class Entity { @Column(unique = true) private String column; }",
|
300 |
+
"class Entity { @Column(columnDefinition = \"VARCHAR(255) DEFAULT 'default_value'\") private String column; }",
|
301 |
+
"CSVWriter writer = new CSVWriter(new FileWriter(\"output.csv\")); writer.writeNext(new String[]{\"column1\", \"column2\"});",
|
302 |
+
"Workbook workbook = new XSSFWorkbook(); Sheet sheet = workbook.createSheet(\"Sheet1\"); FileOutputStream fileOut = new FileOutputStream(\"workbook.xlsx\"); workbook.write(fileOut);",
|
303 |
+
"Gson gson = new Gson(); String json = gson.toJson(new Entity());",
|
304 |
+
"Workbook workbook = WorkbookFactory.create(new File(\"workbook.xlsx\")); Sheet sheet = workbook.getSheetAt(0);",
|
305 |
+
"Workbook workbook1 = WorkbookFactory.create(new File(\"workbook1.xlsx\")); Workbook workbook2 = WorkbookFactory.create(new File(\"workbook2.xlsx\")); Sheet sheet = workbook1.createSheet(\"Merged\");",
|
306 |
+
"Workbook workbook = new XSSFWorkbook(); Sheet sheet = workbook.createSheet(\"New Sheet\");",
|
307 |
+
"Sheet sheet1 = workbook.getSheetAt(0); Sheet sheet2 = workbook.createSheet(\"Copy\"); CellStyle style = sheet1.getRow(0).getCell(0).getCellStyle(); sheet2.getRow(0).getCell(0).setCellStyle(style);",
|
308 |
+
"CellStyle style = workbook.createCellStyle(); style.setFillForegroundColor(IndexedColors.RED.getIndex()); style.setFillPattern(FillPatternType.SOLID_FOREGROUND);",
|
309 |
+
"Font font = workbook.createFont(); font.setBold(true); CellStyle style = workbook.createCellStyle(); style.setFont(font);",
|
310 |
+
"Sheet sheet = workbook.getSheetAt(0); String cellValue = sheet.getRow(0).getCell(0).getStringCellValue();",
|
311 |
+
"Sheet sheet = workbook.getSheetAt(0); sheet.getRow(0).getCell(0).setCellValue(\"New Value\");",
|
312 |
+
"BufferedImage image = ImageIO.read(new File(\"image.jpg\")); int width = image.getWidth(); int height = image.getHeight();",
|
313 |
+
"BufferedImage originalImage = ImageIO.read(new File(\"image.jpg\")); BufferedImage resizedImage = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g = resizedImage.createGraphics(); g.drawImage(originalImage, 0, 0, 100, 100, null);"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
|
315 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
316 |
|
317 |
|
318 |
|