Forrest99 commited on
Commit
bea36b1
·
verified ·
1 Parent(s): 0e93965

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +336 -416
app.py CHANGED
@@ -14,422 +14,342 @@ app.logger = logging.getLogger("CodeSearchAPI")
14
  # 预定义代码片段
15
  CODE_SNIPPETS = [
16
 
17
-
18
- "puts 'Hello, World!'",
19
- "def sum(a, b); a + b; end",
20
- "rand",
21
- "def even?(num); num.even?; end",
22
- "str.length",
23
- "Date.today",
24
- "File.exist?('file.txt')",
25
- "File.read('file.txt')",
26
- "File.write('file.txt', 'content')",
27
- "Time.now",
28
- "str.upcase",
29
- "str.downcase",
30
- "str.reverse",
31
- "list.size",
32
- "list.max",
33
- "list.min",
34
- "list.sort",
35
- "list1 + list2",
36
- "list.delete(element)",
37
- "list.empty?",
38
- "str.count(char)",
39
- "str.include?(substring)",
40
- "num.to_s",
41
- "str.to_i",
42
- "str.match?(/^\d+$/)",
43
- "list.index(element)",
44
- "list.clear",
45
- "list.reverse",
46
- "list.uniq",
47
- "list.include?(value)",
48
- "{}",
49
- "hash[key] = value",
50
- "hash.delete(key)",
51
- "hash.keys",
52
- "hash.values",
53
- "hash1.merge(hash2)",
54
- "hash.empty?",
55
- "hash[key]",
56
- "hash.key?(key)",
57
- "hash.clear",
58
- "File.readlines('file.txt').size",
59
- "File.write('file.txt', list.join('\\n'))",
60
- "File.read('file.txt').split('\\n')",
61
- "File.read('file.txt').split.size",
62
- "def leap_year?(year); (year % 400 == 0) || (year % 100 != 0 && year % 4 == 0); end",
63
- "Time.now.strftime('%Y-%m-%d %H:%M:%S')",
64
- "(Date.today - Date.new(2023, 1, 1)).to_i",
65
- "Dir.pwd",
66
- "Dir.entries('.')",
67
- "Dir.mkdir('new_dir')",
68
- "Dir.rmdir('new_dir')",
69
- "File.file?('path')",
70
- "File.directory?('path')",
71
- "File.size('file.txt')",
72
- "File.rename('old.txt', 'new.txt')",
73
- "FileUtils.cp('source.txt', 'destination.txt')",
74
- "FileUtils.mv('source.txt', 'destination.txt')",
75
- "File.delete('file.txt')",
76
- "ENV['VAR_NAME']",
77
- "ENV['VAR_NAME'] = 'value'",
78
- "system('open https://example.com')",
79
- "require 'net/http'; Net::HTTP.get(URI('https://example.com'))",
80
- "require 'json'; JSON.parse(json_string)",
81
- "require 'json'; File.write('file.json', JSON.dump(data))",
82
- "require 'json'; JSON.parse(File.read('file.json'))",
83
- "list.join",
84
- "str.split(',')",
85
- "list.join(',')",
86
- "list.join('\\n')",
87
- "str.split",
88
- "str.split(delimiter)",
89
- "str.chars",
90
- "str.gsub(old, new)",
91
- "str.gsub(' ', '')",
92
- "str.gsub(/[^a-zA-Z0-9]/, '')",
93
- "str.empty?",
94
- "str == str.reverse",
95
- "require 'csv'; CSV.open('file.csv', 'w') { |csv| csv << ['data'] }",
96
- "require 'csv'; CSV.read('file.csv')",
97
- "require 'csv'; CSV.read('file.csv').size",
98
- "list.shuffle",
99
- "list.sample",
100
- "list.sample(n)",
101
- "rand(6) + 1",
102
- "rand(2) == 0 ? 'Heads' : 'Tails'",
103
- "SecureRandom.alphanumeric(8)",
104
- "format('#%06x', rand(0xffffff))",
105
- "SecureRandom.uuid",
106
- "class MyClass; end",
107
- "MyClass.new",
108
- "class MyClass; def my_method; end; end",
109
- "class MyClass; attr_accessor :my_attr; end",
110
- "class ChildClass < ParentClass; end",
111
- "class ChildClass < ParentClass; def my_method; super; end; end",
112
- "class MyClass; def self.class_method; end; end",
113
- "class MyClass; def self.static_method; end; end",
114
- "obj.is_a?(Class)",
115
- "obj.instance_variable_get(:@attr)",
116
- "obj.instance_variable_set(:@attr, value)",
117
- "obj.instance_variable_defined?(:@attr)",
118
- "begin; risky_operation; rescue => e; puts e; end",
119
- """class CustomError < StandardError
120
- end
121
- raise CustomError, 'error occurred'""",
122
- "begin; raise 'oops'; rescue => e; e.message; end",
123
- """require 'logger'
124
- logger = Logger.new('error.log')
125
- logger.error('error occurred')""",
126
- "start_time = Time.now",
127
- "Time.now - start_time",
128
- "20.times { |i| print \"\\r[#{'='*(i+1)}#{' '*(19-i)}]\"; sleep(0.1) }",
129
- "sleep(1)",
130
- "square = ->(x) { xx }",
131
- "squares = [1,2,3].map { |n| nn }",
132
- "evens = [1,2,3,4].select { |n| n.even? }",
133
- "sum = [1,2,3].reduce(0) { |acc,n| acc+n }",
134
- "doubles = [1,2,3,4,5].map { |n| n2 }",
135
- "hash = [1,2,3].map { |n| [n, n2] }.to_h",
136
- "require 'set'; s = Set.new([1,2,3].map { |n| n*2 })",
137
- "intersection = a & b",
138
- "union = a | b",
139
- "diff = a - b",
140
- "filtered = list.compact",
141
- "begin; File.open('file.txt'); rescue; false; end",
142
- "x.is_a?(String)",
143
- "bool = ['true','1'].include?(str.downcase)",
144
- "puts 'yes' if x > 0",
145
- "i=0; while i<5; i+=1; end",
146
- "for item in [1,2,3]; puts item; end",
147
- """h = {a:1, b:2}
148
- for k, v in h
149
- puts "#{k}:#{v}"
150
- end""",
151
- """for c in 'hello'.chars
152
- puts c
153
- end""",
154
- """for i in 1..5
155
- break if i==3
156
- puts i
157
- end""",
158
- """for i in 1..5
159
- next if i==3
160
- puts i
161
- end""",
162
- "def foo; end",
163
- "def foo(a=1); a; end",
164
- "def foo; [1,2]; end",
165
- "def foo(*args); args; end",
166
- "def foo(a:, b:); a+b; end",
167
- """def foo
168
- end
169
- start = Time.now
170
- foo
171
- puts Time.now - start""",
172
- """def decorate(f)
173
- ->(args) { puts 'before'; result = f.call(args); puts 'after'; result }
174
- end""",
175
- """def fib(n, memo={})
176
- return memo[n] if memo[n]
177
- memo[n] = n<2 ? n : fib(n-1, memo) + fib(n-2, memo)
178
- end""",
179
- "gen = Enumerator.new { |y| i=0; loop { y << i; i+=1 } }",
180
- "def foo; yield 1; end",
181
- "gen.next",
182
- "itr = [1,2,3].each",
183
- """itr = [1,2,3].each
184
- loop do
185
- puts itr.next
186
- end""",
187
- "[1,2].each_with_index { |v, i| puts i, v }",
188
- "zipped = [1,2].zip(['a','b'])",
189
- "h = [1,2].zip(['a','b']).to_h",
190
- "[1,2] == [1,2]",
191
- "{a:1, b:2} == {b:2, a:1}",
192
- "require 'set'; Set.new([1,2]) == Set.new([2,1])",
193
- "unique = [1,2,1].uniq",
194
- "s.clear",
195
- "s.empty?",
196
- "s.add(1)",
197
- "s.delete(1)",
198
- "s.include?(1)",
199
- "s.size",
200
- "!(a & b).empty?",
201
- "[1,2].all? { |e| [1,2,3].include?(e) }",
202
- "'hi'.include?('h')",
203
- "str[0]",
204
- "str[-1]",
205
- "File.extname(path) == '.txt'",
206
- "['.png','.jpg','.jpeg','.gif'].include?(File.extname(path))",
207
- "x.round",
208
- "x.ceil",
209
- "x.floor",
210
- "sprintf('%.2f', x)",
211
- "require 'securerandom'; SecureRandom.alphanumeric(8)",
212
- "File.exist?('path')",
213
- "Dir['**/'].each { |f| puts f }",
214
- "File.extname('path.txt')",
215
- "File.basename(path)",
216
- "File.expand_path(path)",
217
- "RUBY_VERSION",
218
- "RUBY_PLATFORM",
219
- "require 'etc'; Etc.nprocessors",
220
- "mem = grep MemTotal /proc/meminfo",
221
- "df = df -h /",
222
- """require 'socket'
223
- ip = Socket.ip_address_list.detect(&:ipv4_private).ip_address""",
224
- "system('ping -c1 8.8.8.8 > /dev/null 2>&1')",
225
- """require 'open-uri'
226
- File.open('file', 'wb') { |f| f.write open(url).read }""",
227
- """def upload(file)
228
- puts 'Uploading'
229
- end""",
230
- """require 'net/http'
231
- uri = URI(url)
232
- Net::HTTP.post_form(uri, key: 'value')""",
233
- """uri = URI(url)
234
- uri.query = URI.encode_www_form(params)
235
- Net::HTTP.get(uri)""",
236
- """require 'net/http'
237
- uri = URI(url)
238
- req = Net::HTTP::Get.new(uri)
239
- req['User-Agent'] = 'Custom'
240
- res = Net::HTTP.start(uri.hostname, uri.port) { |http| http.request(req) }""",
241
- "require 'nokogiri'; doc = Nokogiri::HTML(html)",
242
- "doc.at('title').text",
243
- "links = doc.css('a').map { |a| a['href'] }",
244
- """doc.css('img').each do |img|
245
- open(img['src']).each do |chunk|
246
- File.open(File.basename(img['src']), 'ab') { |f| f.write chunk }
247
- end
248
- end""",
249
- """freq = Hash.new(0)
250
- text.split.each { |w| freq[w] += 1 }""",
251
- """require 'net/http'
252
- res = Net::HTTP.post_form(URI(login_url), username: 'u', password: 'p')""",
253
- "Nokogiri::HTML(html).text",
254
- "emails = text.scan(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/)",
255
- "phones = text.scan(/\b\d{3}-\d{3}-\d{4}\b/)",
256
- "nums = text.scan(/\d+/)",
257
- "new = text.gsub(/foo/, 'bar')",
258
- "!!(text =~ /pattern/)",
259
- "clean = text.gsub(/<[^>]>/, '')",
260
- "CGI.escapeHTML(text)",
261
- "CGI.unescapeHTML(text)",
262
- """require 'tk'
263
- root = TkRoot.new { title 'App' }
264
- Tk.mainloop""",
265
- "require 'tk'",
266
- """root = TkRoot.new
267
- button = TkButton.new(root) {text 'Click Me'; command { Tk.messageBox(message: 'Button Clicked!') }}
268
- button.pack""",
269
- """Tk.messageBox(message: 'Hello, World!')""",
270
- """entry = TkEntry.new(root).pack
271
- entry.get""",
272
- """root.title = 'My Window'""",
273
- """root.geometry('400x300')""",
274
- """root.geometry('+%d+%d' % [(root.winfo_screenwidth() - root.winfo_reqwidth()) / 2, (root.winfo_screenheight() - root.winfo_reqheight()) / 2])""",
275
- """menu = TkMenu.new(root)
276
- root['menu'] = menu
277
- menu.add('command', 'label' => 'File')""",
278
- """combobox = Tk::Tile::Combobox.new(root).pack""",
279
- """radio = TkRadioButton.new(root) {text 'Option 1'}.pack""",
280
- """check = TkCheckButton.new(root) {text 'Check Me'}.pack""",
281
- """image = TkPhotoImage.new(file: 'image.png')
282
- label = TkLabel.new(root) {image image}.pack""",
283
- """`afplay audio.mp3`""",
284
- """`ffplay video.mp4`""",
285
- """`ffmpeg -i video.mp4 -f null - 2>&1 | grep 'time=' | awk '{print $2}'`""",
286
- """`screencapture screen.png`""",
287
- """`ffmpeg -f avfoundation -i "1" -t 10 screen.mp4`""",
288
- """`cliclick p:.`""",
289
- """`cliclick kd:cmd kp:space ku:cmd`""",
290
- """`cliclick c:.`""",
291
- """Time.now.to_i""",
292
- """Time.at(timestamp).strftime('%Y-%m-%d')""",
293
- """Time.parse(date).to_i""",
294
- """Time.now.strftime('%A')""",
295
- """Time.days_in_month(Time.now.month, Time.now.year)""",
296
- """Time.new(Time.now.year, 1, 1)""",
297
- """Time.new(Time.now.year, 12, 31)""",
298
- """Time.new(year, month, 1)""",
299
- """Time.new(year, month, -1)""",
300
- """Time.now.wday.between?(1, 5)""",
301
- """Time.now.wday.between?(6, 7)""",
302
- """Time.now.hour""",
303
- """Time.now.min""",
304
- """Time.now.sec""",
305
- """sleep(1)""",
306
- """(Time.now.to_f * 1000).to_i""",
307
- """Time.now.strftime('%Y-%m-%d %H:%M:%S')""",
308
- """Time.parse(time_str)""",
309
- """Thread.new { puts 'Hello from thread' }""",
310
- """sleep(1)""",
311
- """threads = []
312
- 3.times { threads << Thread.new { puts 'Hello from thread' } }
313
- threads.each(&:join)""",
314
- """Thread.current.name""",
315
- """thread = Thread.new { puts 'Hello from thread' }
316
- thread.abort_on_exception = true""",
317
- """mutex = Mutex.new
318
- mutex.synchronize { puts 'Hello from synchronized thread' }""",
319
- """pid = Process.spawn('sleep 5')""",
320
- """Process.pid""",
321
- """Process.kill(0, pid) rescue false""",
322
- """pids = []
323
- 3.times { pids << Process.spawn('sleep 5') }
324
- pids.each { |pid| Process.wait(pid) }""",
325
- """queue = Queue.new
326
- queue.push('Hello')
327
- queue.pop""",
328
- """reader, writer = IO.pipe
329
- writer.puts 'Hello'
330
- reader.gets""",
331
- """Process.setrlimit(:CPU, 50)""",
332
- """`ls`""",
333
- """`ls`.chomp""",
334
- """$?.exitstatus""",
335
- """$?.success?""",
336
- """File.expand_path(__FILE__)""",
337
- """ARGV""",
338
- """require 'optparse'
339
- OptionParser.new { |opts| opts.on('-h', '--help', 'Show help') { puts opts } }.parse!""",
340
- """OptionParser.new { |opts| opts.on('-h', '--help', 'Show help') { puts opts } }.parse!""",
341
- """Gem.loaded_specs.keys""",
342
- """`gem install package_name`""",
343
- """`gem uninstall package_name`""",
344
- """Gem.loaded_specs['package_name'].version.to_s""",
345
- """`bundle exec ruby script.rb`""",
346
- """Gem::Specification.map(&:name)""",
347
- """`gem update package_name`""",
348
- """require 'sqlite3'
349
- db = SQLite3::Database.new('test.db')""",
350
- """db.execute('SELECT * FROM table')""",
351
- """db.execute('INSERT INTO table (column) VALUES (?)', 'value')""",
352
- """db.execute('DELETE FROM table WHERE id = ?', 1)""",
353
- """db.execute('UPDATE table SET column = ? WHERE id = ?', 'new_value', 1)""",
354
- """db.execute('SELECT * FROM table').each { |row| puts row }""",
355
- """db.execute('SELECT * FROM table WHERE column = ?', 'value')""",
356
- """db.close""",
357
- """db.execute('CREATE TABLE table (id INTEGER PRIMARY KEY, column TEXT)')""",
358
- """db.execute('DROP TABLE table')""",
359
- """db.table_info('table').any?""",
360
- """db.execute('SELECT name FROM sqlite_master WHERE type = "table"')""",
361
- """class Model < ActiveRecord::Base
362
- end
363
- Model.create(column: 'value')""",
364
- """Model.find_by(column: 'value')""",
365
- """Model.find_by(column: 'value').destroy""",
366
- """Model.find_by(column: 'value').update(column: 'new_value')""",
367
- """class Model < ActiveRecord::Base
368
- end""",
369
- """class ChildModel < ParentModel
370
- end""",
371
- """class Model < ActiveRecord::Base
372
- self.primary_key = 'id'
373
- end""",
374
- """class Model < ActiveRecord::Base
375
- validates_uniqueness_of :column
376
- end""",
377
- """class Model < ActiveRecord::Base
378
- attribute :column, default: 'value'
379
- end""",
380
- """require 'csv'
381
- CSV.open('data.csv', 'w') { |csv| csv << ['column1', 'column2'] }""",
382
- """require 'spreadsheet'
383
- book = Spreadsheet::Workbook.new
384
- sheet = book.create_worksheet
385
- sheet[0, 0] = 'Hello'
386
- book.write('data.xls')""",
387
- """require 'json'
388
- File.write('data.json', {key: 'value'}.to_json)""",
389
- """require 'spreadsheet'
390
- book = Spreadsheet.open('data.xls')
391
- sheet = book.worksheet(0)
392
- sheet.each { |row| puts row }""",
393
- """require 'spreadsheet'
394
- book1 = Spreadsheet.open('file1.xls')
395
- book2 = Spreadsheet.open('file2.xls')
396
- book1.worksheets.each { |sheet| book2.add_worksheet(sheet) }
397
- book2.write('merged.xls')""",
398
- """require 'spreadsheet'
399
- book = Spreadsheet::Workbook.new
400
- book.create_worksheet(name: 'New Sheet')
401
- book.write('data.xls')""",
402
- """require 'spreadsheet'
403
- book = Spreadsheet.open('data.xls')
404
- sheet = book.worksheet(0)
405
- new_sheet = book.create_worksheet
406
- new_sheet.format_with(sheet)
407
- book.write('data.xls')""",
408
- """require 'spreadsheet'
409
- book = Spreadsheet.open('data.xls')
410
- sheet = book.worksheet(0)
411
- sheet.row(0).set_format(0, Spreadsheet::Format.new(color: :red))
412
- book.write('data.xls')""",
413
- """require 'spreadsheet'
414
- book = Spreadsheet.open('data.xls')
415
- sheet = book.worksheet(0)
416
- sheet.row(0).set_format(0, Spreadsheet::Format.new(weight: :bold))
417
- book.write('data.xls')""",
418
- """require 'spreadsheet'
419
- book = Spreadsheet.open('data.xls')
420
- sheet = book.worksheet(0)
421
- sheet[0, 0]""",
422
- """require 'spreadsheet'
423
- book = Spreadsheet::Workbook.new
424
- sheet = book.create_worksheet
425
- sheet[0, 0] = 'Hello'
426
- book.write('data.xls')""",
427
- """require 'rmagick'
428
- image = Magick::Image.read('image.png').first
429
- [image.columns, image.rows]""",
430
- """require 'rmagick'
431
- image = Magick::Image.read('image.png').first
432
- image.resize!(100, 100)"""
433
 
434
 
435
 
 
14
  # 预定义代码片段
15
  CODE_SNIPPETS = [
16
 
17
+ "#include <stdio.h>\nvoid print_text() { printf(\"Hello, World!\"); }",
18
+ "#include <stdio.h>\nint sum(int a, int b) { return a + b; }",
19
+ "#include <stdlib.h>\n#include <time.h>\nint generate_random() { srand(time(NULL)); return rand(); }",
20
+ "#include <stdio.h>\nint is_even(int num) { return num % 2 == 0; }",
21
+ "#include <string.h>\nint string_length(char *str) { return strlen(str); }",
22
+ "#include <time.h>\nvoid get_current_date() { time_t t = time(NULL); printf(\"%s\", ctime(&t)); }",
23
+ "#include <stdio.h>\nint file_exists(char *filename) { FILE *file = fopen(filename, \"r\"); if (file) { fclose(file); return 1; } return 0; }",
24
+ "#include <stdio.h>\nvoid read_file(char *filename) { FILE *file = fopen(filename, \"r\"); char ch; while ((ch = fgetc(file)) != EOF) { putchar(ch); } fclose(file); }",
25
+ "#include <stdio.h>\nvoid write_file(char *filename, char *content) { FILE *file = fopen(filename, \"w\"); fprintf(file, \"%s\", content); fclose(file); }",
26
+ "#include <time.h>\nvoid get_current_time() { time_t t = time(NULL); printf(\"%s\", ctime(&t)); }",
27
+ "#include <ctype.h>\nvoid to_upper(char *str) { for (int i = 0; str[i]; i++) { str[i] = toupper(str[i]); } }",
28
+ "#include <ctype.h>\nvoid to_lower(char *str) { for (int i = 0; str[i]; i++) { str[i] = tolower(str[i]); } }",
29
+ "#include <string.h>\nvoid reverse_string(char *str) { int len = strlen(str); for (int i = 0; i < len / 2; i++) { char temp = str[i]; str[i] = str[len - i - 1]; str[len - i - 1] = temp; } }",
30
+ "#include <stdio.h>\nint list_length(int *arr, int size) { return size; }",
31
+ "#include <limits.h>\nint list_max(int *arr, int size) { int max = INT_MIN; for (int i = 0; i < size; i++) { if (arr[i] > max) max = arr[i]; } return max; }",
32
+ "#include <limits.h>\nint list_min(int *arr, int size) { int min = INT_MAX; for (int i = 0; i < size; i++) { if (arr[i] < min) min = arr[i]; } return min; }",
33
+ "#include <stdlib.h>\nvoid sort_list(int *arr, int size) { qsort(arr, size, sizeof(int), (int (*)(const void *, const void *))strcmp); }",
34
+ "#include <stdio.h>\nvoid merge_lists(int *arr1, int size1, int *arr2, int size2, int *result) { memcpy(result, arr1, size1 * sizeof(int)); memcpy(result + size1, arr2, size2 * sizeof(int)); }",
35
+ "#include <stdio.h>\nvoid remove_element(int *arr, int *size, int index) { for (int i = index; i < *size - 1; i++) { arr[i] = arr[i + 1]; } (*size)--; }",
36
+ "#include <stdio.h>\nint is_list_empty(int *arr, int size) { return size == 0; }",
37
+ "#include <string.h>\nint count_char(char *str, char ch) { int count = 0; for (int i = 0; str[i]; i++) { if (str[i] == ch) count++; } return count; }",
38
+ "#include <string.h>\nint contains_substring(char *str, char *sub) { return strstr(str, sub) != NULL; }",
39
+ "#include <stdlib.h>\nvoid int_to_string(int num, char *str) { sprintf(str, \"%d\", num); }",
40
+ "#include <stdlib.h>\nint string_to_int(char *str) { return atoi(str); }",
41
+ "#include <ctype.h>\nint is_numeric(char *str) { for (int i = 0; str[i]; i++) { if (!isdigit(str[i])) return 0; } return 1; }",
42
+ "#include <stdio.h>\nint find_index(int *arr, int size, int value) { for (int i = 0; i < size; i++) { if (arr[i] == value) return i; } return -1; }",
43
+ "#include <stdio.h>\nvoid clear_list(int *arr, int *size) { *size = 0; }",
44
+ "#include <stdio.h>\nvoid reverse_list(int *arr, int size) { for (int i = 0; i < size / 2; i++) { int temp = arr[i]; arr[i] = arr[size - i - 1]; arr[size - i - 1] = temp; } }",
45
+ "#include <stdio.h>\nvoid remove_duplicates(int *arr, int *size) { for (int i = 0; i < *size; i++) { for (int j = i + 1; j < *size; j++) { if (arr[i] == arr[j]) { remove_element(arr, size, j); j--; } } } }",
46
+ "#include <stdio.h>\nint is_in_list(int *arr, int size, int value) { for (int i = 0; i < size; i++) { if (arr[i] == value) return 1; } return 0; }",
47
+ "#include <stdio.h>\nvoid create_dict() { }",
48
+ "#include <stdio.h>\nvoid add_to_dict() { }",
49
+ "#include <stdio.h>\nvoid delete_from_dict() { }",
50
+ "#include <stdio.h>\nvoid get_dict_keys() { }",
51
+ "#include <stdio.h>\nvoid get_dict_values() { }",
52
+ "#include <stdio.h>\nvoid merge_dicts() { }",
53
+ "#include <stdio.h>\nint is_dict_empty() { return 1; }",
54
+ "#include <stdio.h>\nvoid get_dict_value() { }",
55
+ "#include <stdio.h>\nint key_in_dict() { return 1; }",
56
+ "#include <stdio.h>\nvoid clear_dict() { }",
57
+ "#include <stdio.h>\nint count_file_lines(char *filename) { FILE *file = fopen(filename, \"r\"); int count = 0; char ch; while ((ch = fgetc(file)) != EOF) { if (ch == '\\n') count++; } fclose(file); return count; }",
58
+ "#include <stdio.h>\nvoid write_list_to_file(char *filename, int *arr, int size) { FILE *file = fopen(filename, \"w\"); for (int i = 0; i < size; i++) { fprintf(file, \"%d\\n\", arr[i]); } fclose(file); }",
59
+ "#include <stdio.h>\nvoid read_list_from_file(char *filename, int *arr, int *size) { FILE *file = fopen(filename, \"r\"); *size = 0; while (fscanf(file, \"%d\", &arr[*size]) != EOF) { (*size)++; } fclose(file); }",
60
+ "#include <stdio.h>\nint count_file_words(char *filename) { FILE *file = fopen(filename, \"r\"); int count = 0; char ch; while ((ch = fgetc(file)) != EOF) { if (ch == ' ') count++; } fclose(file); return count + 1; }",
61
+ "#include <stdio.h>\nint is_leap_year(int year) { return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); }",
62
+ "#include <time.h>\nvoid format_time() { time_t t = time(NULL); struct tm *tm = localtime(&t); char buffer[80]; strftime(buffer, 80, \"%Y-%m-%d %H:%M:%S\", tm); printf(\"%s\", buffer); }",
63
+ "#include <time.h>\nint days_between_dates(struct tm *date1, struct tm *date2) { return (int)(difftime(mktime(date1), mktime(date2)) / (60 * 60 * 24)); }",
64
+ "#include <unistd.h>\nvoid get_current_directory() { char cwd[1024]; getcwd(cwd, sizeof(cwd)); printf(\"%s\", cwd); }",
65
+ "#include <dirent.h>\nvoid list_directory_files(char *path) { DIR *dir = opendir(path); struct dirent *entry; while ((entry = readdir(dir)) != NULL) { printf(\"%s\\n\", entry->d_name); } closedir(dir); }",
66
+ "#include <sys/stat.h>\nvoid create_directory(char *path) { mkdir(path, 0777); }",
67
+ "#include <unistd.h>\nvoid delete_directory(char *path) { rmdir(path); }",
68
+ "#include <sys/stat.h>\nint is_file(char *path) { struct stat path_stat; stat(path, &path_stat); return S_ISREG(path_stat.st_mode); }",
69
+ "#include <sys/stat.h>\nint is_directory(char *path) { struct stat path_stat; stat(path, &path_stat); return S_ISDIR(path_stat.st_mode); }",
70
+ "#include <sys/stat.h>\nlong get_file_size(char *filename) { struct stat st; stat(filename, &st); return st.st_size; }",
71
+ "#include <stdio.h>\nvoid rename_file(char *old_name, char *new_name) { rename(old_name, new_name); }",
72
+ "#include <stdio.h>\nvoid copy_file(char *src, char *dest) { FILE *fsrc = fopen(src, \"rb\"); FILE *fdest = fopen(dest, \"wb\"); char ch; while ((ch = fgetc(fsrc)) != EOF) { fputc(ch, fdest); } fclose(fsrc); fclose(fdest); }",
73
+ "#include <stdio.h>\nvoid move_file(char *src, char *dest) { rename(src, dest); }",
74
+ "#include <stdio.h>\nvoid delete_file(char *filename) { remove(filename); }",
75
+ "#include <stdlib.h>\nvoid get_env_var(char *var) { printf(\"%s\", getenv(var)); }",
76
+ "#include <stdlib.h>\nvoid set_env_var(char *var, char *value) { setenv(var, value, 1); }",
77
+ "#include <stdio.h>\nvoid open_url(char *url) { char command[256]; sprintf(command, \"xdg-open %s\", url); system(command); }",
78
+ "#include <stdio.h>\n#include <curl/curl.h>\nvoid send_get_request(char *url) { CURL *curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_perform(curl); curl_easy_cleanup(curl); } }",
79
+ "#include <stdio.h>\n#include <json-c/json.h>\nvoid parse_json(char *json_str) { json_object *jobj = json_tokener_parse(json_str); printf(\"%s\", json_object_to_json_string(jobj)); }",
80
+ "#include <stdio.h>\n#include <json-c/json.h>\nvoid write_json_to_file(char *filename, json_object *jobj) { FILE *file = fopen(filename, \"w\"); fprintf(file, \"%s\", json_object_to_json_string(jobj)); fclose(file); }",
81
+ "#include <stdio.h>\n#include <json-c/json.h>\nvoid read_json_from_file(char *filename) { FILE *file = fopen(filename, \"r\"); char buffer[1024]; fread(buffer, 1, sizeof(buffer), file); fclose(file); json_object *jobj = json_tokener_parse(buffer); printf(\"%s\", json_object_to_json_string(jobj)); }",
82
+ "#include <stdio.h>\nvoid list_to_string(int *arr, int size, char *str) { for (int i = 0; i < size; i++) { sprintf(str + strlen(str), \"%d \", arr[i]); } }",
83
+ "#include <stdio.h>\nvoid string_to_list(char *str, int *arr, int *size) { *size = 0; char *token = strtok(str, \" \"); while (token != NULL) { arr[*size] = atoi(token); (*size)++; token = strtok(NULL, \" \"); } }",
84
+ "#include <stdio.h>\nvoid join_with_comma(int *arr, int size, char *str) { for (int i = 0; i < size; i++) { sprintf(str + strlen(str), \"%d,\", arr[i]); } str[strlen(str) - 1] = '\\0'; }",
85
+ "#include <stdio.h>\nvoid join_with_newline(int *arr, int size, char *str) { for (int i = 0; i < size; i++) { sprintf(str + strlen(str), \"%d\\n\", arr[i]); } }",
86
+ "#include <stdio.h>\nvoid split_by_space(char *str, char **arr, int *size) { *size = 0; char *token = strtok(str, \" \"); while (token != NULL) { arr[*size] = token; (*size)++; token = strtok(NULL, \" \"); } }",
87
+ "#include <stdio.h>\nvoid split_by_delimiter(char *str, char *delimiter, char **arr, int *size) { *size = 0; char *token = strtok(str, delimiter); while (token != NULL) { arr[*size] = token; (*size)++; token = strtok(NULL, delimiter); } }",
88
+ "#include <stdio.h>\nvoid split_to_chars(char *str, char *arr) { for (int i = 0; str[i]; i++) { arr[i] = str[i]; } }",
89
+ "#include <stdio.h>\nvoid replace_string(char *str, char *old, char *new) { char *pos = strstr(str, old); if (pos) { memmove(pos + strlen(new), pos + strlen(old), strlen(pos + strlen(old)) + 1); memcpy(pos, new, strlen(new)); } }",
90
+ "#include <stdio.h>\nvoid remove_spaces(char *str) { int count = 0; for (int i = 0; str[i]; i++) { if (str[i] != ' ') str[count++] = str[i]; } str[count] = '\\0'; }",
91
+ "#include <ctype.h>\nvoid remove_punctuation(char *str) { int count = 0; for (int i = 0; str[i]; i++) { if (!ispunct(str[i])) str[count++] = str[i]; } str[count] = '\\0'; }",
92
+ "#include <stdio.h>\nint is_string_empty(char *str) { return strlen(str) == 0; }",
93
+ "#include <stdio.h>\nint is_palindrome(char *str) { int len = strlen(str); for (int i = 0; i < len / 2; i++) { if (str[i] != str[len - i - 1]) return 0; } return 1; }",
94
+ "#include <stdio.h>\nvoid write_csv(char *filename, int *arr, int size) { FILE *file = fopen(filename, \"w\"); for (int i = 0; i < size; i++) { fprintf(file, \"%d,\", arr[i]); } fclose(file); }",
95
+ "#include <stdio.h>\nvoid read_csv(char *filename, int *arr, int *size) { FILE *file = fopen(filename, \"r\"); *size = 0; while (fscanf(file, \"%d,\", &arr[*size]) != EOF) { (*size)++; } fclose(file); }",
96
+ "#include <stdio.h>\nint count_csv_lines(char *filename) { FILE *file = fopen(filename, \"r\"); int count = 0; char ch; while ((ch = fgetc(file)) != EOF) { if (ch == '\\n') count++; } fclose(file); return count; }",
97
+ "#include <stdlib.h>\nvoid shuffle_list(int *arr, int size) { for (int i = 0; i < size; i++) { int j = rand() % size; int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } }",
98
+ "#include <stdlib.h>\nint random_element(int *arr, int size) { return arr[rand() % size]; }",
99
+ "#include <stdlib.h>\nvoid random_elements(int *arr, int size, int *result, int count) { for (int i = 0; i < count; i++) { result[i] = arr[rand() % size]; } }",
100
+ "#include <stdlib.h>\nint roll_dice() { return rand() % 6 + 1; }",
101
+ "#include <stdlib.h>\nint flip_coin() { return rand() % 2; }",
102
+ "#include <stdlib.h>\nvoid generate_password(char *password, int length) { for (int i = 0; i < length; i++) { password[i] = rand() % 94 + 33; } password[length] = '\\0'; }",
103
+ "#include <stdlib.h>\nvoid generate_color(char *color) { sprintf(color, \"#%06X\", rand() % 0xFFFFFF); }",
104
+ "#include <stdlib.h>\nvoid generate_uuid(char *uuid) { sprintf(uuid, \"%04x%04x-%04x-%04x-%04x-%04x%04x%04x\", rand() % 0xFFFF, rand() % 0xFFFF, rand() % 0xFFFF, rand() % 0xFFFF, rand() % 0xFFFF, rand() % 0xFFFF, rand() % 0xFFFF, rand() % 0xFFFF); }",
105
+ """typedef struct {
106
+ int id;
107
+ char name[50];
108
+ } MyClass;""",
109
+ """MyClass create_instance(int id, char *name) {
110
+ MyClass instance;
111
+ instance.id = id;
112
+ strcpy(instance.name, name);
113
+ return instance;
114
+ }""",
115
+ """void my_method(MyClass *obj) {
116
+ printf("Method called with ID: %d, Name: %s\\n", obj->id, obj->name);
117
+ }""",
118
+ """typedef struct {
119
+ int id;
120
+ char name[50];
121
+ } MyClass;""",
122
+ """typedef struct {
123
+ MyClass base;
124
+ int additionalField;
125
+ } DerivedClass;""",
126
+ """void overridden_method(DerivedClass *obj) {
127
+ printf("Overridden method called with additional field: %d\\n", obj->additionalField);
128
+ }""",
129
+ """void class_method() {
130
+ printf("Class method called\\n");
131
+ }""",
132
+ """void static_method() {
133
+ printf("Static method called\\n");
134
+ }""",
135
+ """int is_type(MyClass *obj, const char *type) {
136
+ return strcmp(type, "MyClass") == 0;
137
+ }""",
138
+ """int get_property(MyClass *obj, const char *property) {
139
+ if (strcmp(property, "id") == 0) return obj->id;
140
+ if (strcmp(property, "name") == 0) return (int)obj->name;
141
+ return -1;
142
+ }""",
143
+ """void set_property(MyClass *obj, const char *property, int value) {
144
+ if (strcmp(property, "id") == 0) obj->id = value;
145
+ }""",
146
+ """void delete_property(MyClass *obj, const char *property) {
147
+ if (strcmp(property, "id") == 0) obj->id = 0;
148
+ }""",
149
+ "#include <setjmp.h>\njmp_buf env;\n#define TRY if (setjmp(env) == 0)\n#define CATCH else",
150
+ "#define THROW longjmp(env, 1)",
151
+ "#include <stdio.h>\n#define GET_EXCEPTION_INFO fprintf(stderr, \"Exception occurred\\n\")",
152
+ "#include <stdio.h>\n#define LOG_ERROR(msg) fprintf(stderr, \"ERROR: %s\\n\", msg)",
153
+ "#include <time.h>\nclock_t start_timer() { return clock(); }",
154
+ "double get_elapsed_time(clock_t start) { return (double)(clock() - start) / CLOCKS_PER_SEC; }",
155
+ "#include <stdio.h>\nvoid print_progress_bar(int progress, int total) { printf(\"[%.*s%*s] %d%%\\r\", progress * 20 / total, \"==================\", 20 - progress * 20 / total, \"\", progress * 100 / total); fflush(stdout); }",
156
+ "#include <unistd.h>\nvoid delay(unsigned int seconds) { sleep(seconds); }",
157
+ "#define LAMBDA(return_type, body) ({ return_type __fn__ body __fn__; })",
158
+ "#include <stdlib.h>\nint* map(int* arr, size_t size, int (*func)(int)) { int* result = malloc(size * sizeof(int)); for (size_t i = 0; i < size; i++) result[i] = func(arr[i]); return result; }",
159
+ "#include <stdlib.h>\nint* filter(int* arr, size_t size, int (*func)(int), size_t* result_size) { int* result = malloc(size * sizeof(int)); *result_size = 0; for (size_t i = 0; i < size; i++) if (func(arr[i])) result[(*result_size)++] = arr[i]; return result; }",
160
+ "#include <stdlib.h>\nint reduce(int* arr, size_t size, int (*func)(int, int), int initial) { int result = initial; for (size_t i = 0; i < size; i++) result = func(result, arr[i]); return result; }",
161
+ "#include <stdlib.h>\nint* list_comprehension(int* arr, size_t size, int (*func)(int), size_t* result_size) { int* result = malloc(size * sizeof(int)); *result_size = 0; for (size_t i = 0; i < size; i++) result[(*result_size)++] = func(arr[i]); return result; }",
162
+ "#include <stdlib.h>\nint* dict_comprehension(int* keys, int* values, size_t size, int (*func)(int, int), size_t* result_size) { int* result = malloc(size * sizeof(int)); *result_size = 0; for (size_t i = 0; i < size; i++) result[(*result_size)++] = func(keys[i], values[i]); return result; }",
163
+ "#include <stdlib.h>\nint* set_comprehension(int* arr, size_t size, int (*func)(int), size_t* result_size) { int* result = malloc(size * sizeof(int)); *result_size = 0; for (size_t i = 0; i < size; i++) result[(*result_size)++] = func(arr[i]); return result; }",
164
+ "#include <stdlib.h>\nint* set_intersection(int* set1, int* set2, size_t size1, size_t size2, size_t* result_size) { int* result = malloc((size1 < size2 ? size1 : size2) * sizeof(int)); *result_size = 0; for (size_t i = 0; i < size1; i++) for (size_t j = 0; j < size2; j++) if (set1[i] == set2[j]) result[(*result_size)++] = set1[i]; return result; }",
165
+ "#include <stdlib.h>\nint* set_union(int* set1, int* set2, size_t size1, size_t size2, size_t* result_size) { int* result = malloc((size1 + size2) * sizeof(int)); *result_size = 0; for (size_t i = 0; i < size1; i++) result[(*result_size)++] = set1[i]; for (size_t j = 0; j < size2; j++) { int found = 0; for (size_t i = 0; i < size1; i++) if (set2[j] == set1[i]) { found = 1; break; } if (!found) result[(*result_size)++] = set2[j]; } return result; }",
166
+ "#include <stdlib.h>\nint* set_difference(int* set1, int* set2, size_t size1, size_t size2, size_t* result_size) { int* result = malloc(size1 * sizeof(int)); *result_size = 0; for (size_t i = 0; i < size1; i++) { int found = 0; for (size_t j = 0; j < size2; j++) if (set1[i] == set2[j]) { found = 1; break; } if (!found) result[(*result_size)++] = set1[i]; } return result; }",
167
+ "#include <stdlib.h>\nint* remove_none_values(int* arr, size_t size, size_t* result_size) { int* result = malloc(size * sizeof(int)); *result_size = 0; for (size_t i = 0; i < size; i++) if (arr[i] != 0) result[(*result_size)++] = arr[i]; return result; }",
168
+ "#include <stdio.h>\n#define TRY_OPEN_FILE(file) if ((file = fopen(\"filename\", \"r\")) == NULL) { perror(\"Error opening file\"); } else",
169
+ "#include <stdio.h>\n#define CHECK_TYPE(var, type) _Generic((var), type: 1, default: 0)",
170
+ "#include <stdbool.h>\nbool str_to_bool(const char* str) { return strcmp(str, \"true\") == 0 || strcmp(str, \"1\") == 0; }",
171
+ "#define IF(condition) if (condition)",
172
+ "#define WHILE(condition) while (condition)",
173
+ "#define FOR_LIST(list, size, i) for (size_t i = 0; i < size; i++)",
174
+ "#define FOR_DICT(dict, size, i) for (size_t i = 0; i < size; i++)",
175
+ "#define FOR_STRING(str, i) for (size_t i = 0; i < strlen(str); i++)",
176
+ "#define BREAK break",
177
+ "#define CONTINUE continue",
178
+ "#define DEFINE_FUNC(name, return_type, ...) return_type name(__VA_ARGS__)",
179
+ "#define DEFAULT_ARG(arg, value) arg = value",
180
+ "#define RETURN_MULTIPLE(...) { __VA_ARGS__ }",
181
+ "#define VARARGS(...) __VA_ARGS__",
182
+ "#define KEYWORD_ARGS(...) __VA_ARGS__",
183
+ "#include <time.h>\n#define TIME_FUNC(func, ...) { clock_t start = clock(); func(__VA_ARGS__); printf(\"Time: %f\\n\", (double)(clock() - start) / CLOCKS_PER_SEC); }",
184
+ "#define DECORATE(func, decorator) decorator(func)",
185
+ "#include <stdlib.h>\n#define CACHE_FUNC(func, ...) { static int cached_result = 0; if (!cached_result) cached_result = func(__VA_ARGS__); return cached_result; }",
186
+ "#define CREATE_GENERATOR(name, type) type name() { static type state = 0; return state++; }",
187
+ "#define YIELD(value) return value",
188
+ "#define NEXT(generator) generator()",
189
+ "#define CREATE_ITERATOR(name, type) type name() { static type state = 0; return state++; }",
190
+ "#define MANUAL_ITERATE(iterator) iterator()",
191
+ "#define ENUMERATE(list, size, i) for (size_t i = 0; i < size; i++)",
192
+ "#include <stdlib.h>\nint* zip(int* list1, int* list2, size_t size, size_t* result_size) { int* result = malloc(size * sizeof(int)); *result_size = 0; for (size_t i = 0; i < size; i++) result[(*result_size)++] = list1[i] + list2[i]; return result; }",
193
+ "#include <stdlib.h>\nint* list_to_dict(int* keys, int* values, size_t size, size_t* result_size) { int* result = malloc(size * sizeof(int)); *result_size = 0; for (size_t i = 0; i < size; i++) result[(*result_size)++] = values[i]; return result; }",
194
+ "#define EQUAL_LISTS(list1, list2, size) memcmp(list1, list2, size) == 0",
195
+ "#define EQUAL_DICTS(dict1, dict2, size) memcmp(dict1, dict2, size) == 0",
196
+ "#define EQUAL_SETS(set1, set2, size) memcmp(set1, set2, size) == 0",
197
+ "#include <stdlib.h>\nint* set_unique(int* set, size_t size, size_t* result_size) { int* result = malloc(size * sizeof(int)); *result_size = 0; for (size_t i = 0; i < size; i++) { int found = 0; for (size_t j = 0; j < *result_size; j++) if (set[i] == result[j]) { found = 1; break; } if (!found) result[(*result_size)++] = set[i]; } return result; }",
198
+ "#define CLEAR_SET(set, size) memset(set, 0, size * sizeof(int))",
199
+ "#define IS_SET_EMPTY(set, size) size == 0",
200
+ "#define ADD_TO_SET(set, size, value) set[size++] = value",
201
+ "#define REMOVE_FROM_SET(set, size, value) { for (size_t i = 0; i < size; i++) if (set[i] == value) { set[i] = set[--size]; break; } }",
202
+ "#define SET_CONTAINS(set, size, value) ({ int found = 0; for (size_t i = 0; i < size; i++) if (set[i] == value) { found = 1; break; } found; })",
203
+ "#define SET_SIZE(set, size) size",
204
+ "#define SETS_INTERSECT(set1, set2, size1, size2) ({ int found = 0; for (size_t i = 0; i < size1; i++) for (size_t j = 0; j < size2; j++) if (set1[i] == set2[j]) { found = 1; break; } found; })",
205
+ "#define IS_SUBSET(list1, list2, size1, size2) ({ int found = 1; for (size_t i = 0; i < size1; i++) { int match = 0; for (size_t j = 0; j < size2; j++) if (list1[i] == list2[j]) { match = 1; break; } if (!match) { found = 0; break; } } found; })",
206
+ "#define IS_SUBSTRING(str, substr) strstr(str, substr) != NULL",
207
+ "#define FIRST_CHAR(str) str[0]",
208
+ "#define LAST_CHAR(str) str[strlen(str) - 1]",
209
+ "#include <stdio.h>\n#define IS_TEXT_FILE(file) fgetc(file) != EOF",
210
+ "#include <stdio.h>\n#define IS_IMAGE_FILE(file) fgetc(file) != EOF",
211
+ "#include <math.h>\n#define ROUND(num) round(num)",
212
+ "#include <math.h>\n#define CEIL(num) ceil(num)",
213
+ "#include <math.h>\n#define FLOOR(num) floor(num)",
214
+ "#include <stdio.h>\n#define FORMAT_DECIMAL(num, places) printf(\"%.*f\", places, num)",
215
+ "#include <stdlib.h>\n#define RANDOM_STRING(length) ({ char* str = malloc(length + 1); for (size_t i = 0; i < length; i++) str[i] = 'a' + rand() % 26; str[length] = '\\0'; str; })",
216
+ "#include <unistd.h>\n#define PATH_EXISTS(path) access(path, F_OK) == 0",
217
+ "#include <dirent.h>\n#define LIST_DIRECTORY(dir) ({ DIR* d = opendir(dir); struct dirent* entry; while ((entry = readdir(d)) != NULL) printf(\"%s\\n\", entry->d_name); closedir(d); })",
218
+ "#include <libgen.h>\n#define GET_EXTENSION(path) strrchr(path, '.')",
219
+ "#include <libgen.h>\n#define GET_FILENAME(path) basename(path)",
220
+ "#include <libgen.h>\n#define GET_FULL_PATH(path) realpath(path, NULL)",
221
+ "#include <Python.h>\n#define PYTHON_VERSION Py_GetVersion()",
222
+ "#include <sys/utsname.h>\n#define SYSTEM_INFO ({ struct utsname info; uname(&info); info.sysname; })",
223
+ "#include <unistd.h>\n#define CPU_CORES sysconf(_SC_NPROCESSORS_ONLN)",
224
+ "#include <sys/sysinfo.h>\n#define MEMORY_SIZE ({ struct sysinfo info; sysinfo(&info); info.totalram; })",
225
+ "#include <sys/statvfs.h>\n#define DISK_USAGE(path) ({ struct statvfs info; statvfs(path, &info); (info.f_blocks - info.f_bfree) * info.f_frsize; })",
226
+ "#include <ifaddrs.h>\n#define NETWORK_IP ({ struct ifaddrs* ifaddr; getifaddrs(&ifaddr); ifaddr->ifa_addr; })",
227
+ "#include <unistd.h>\n#define IS_CONNECTED system(\"ping -c 1 google.com\") == 0",
228
+ "#include <curl/curl.h>\n#define DOWNLOAD_FILE(url, file) ({ CURL* curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEDATA, fopen(file, \"wb\")); curl_easy_perform(curl); curl_easy_cleanup(curl); })",
229
+ "#include <curl/curl.h>\n#define UPLOAD_FILE(url, file) ({ CURL* curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_READDATA, fopen(file, \"rb\")); curl_easy_perform(curl); curl_easy_cleanup(curl); })",
230
+ "#include <curl/curl.h>\n#define POST_REQUEST(url, data) ({ CURL* curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); curl_easy_perform(curl); curl_easy_cleanup(curl); })",
231
+ "#include <curl/curl.h>\n#define SEND_REQUEST(url, params) ({ CURL* curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, params); curl_easy_perform(curl); curl_easy_cleanup(curl); })",
232
+ "#include <curl/curl.h>\n#define SET_HEADERS(curl, headers) curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers)",
233
+ "#include <libxml/HTMLparser.h>\n#define PARSE_HTML(html) ({ htmlDocPtr doc = htmlReadDoc((xmlChar*)html, NULL, NULL, HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING); doc; })",
234
+ "#include <libxml/HTMLparser.h>\n#define EXTRACT_TITLE(doc) ({ xmlChar* title = xmlNodeGetContent(xmlDocGetRootElement(doc)->children); title; })",
235
+ "#include <libxml/HTMLparser.h>\n#define EXTRACT_LINKS(doc) ({ xmlNodePtr cur = xmlDocGetRootElement(doc)->children; while (cur != NULL) { if (cur->type == XML_ELEMENT_NODE && xmlStrcmp(cur->name, (xmlChar*)\"a\") == 0) printf(\"%s\\n\", xmlGetProp(cur, (xmlChar*)\"href\")); cur = cur->next; } })",
236
+ "#include <libxml/HTMLparser.h>\n#define DOWNLOAD_IMAGES(doc) ({ xmlNodePtr cur = xmlDocGetRootElement(doc)->children; while (cur != NULL) { if (cur->type == XML_ELEMENT_NODE && xmlStrcmp(cur->name, (xmlChar*)\"img\") == 0) printf(\"%s\\n\", xmlGetProp(cur, (xmlChar*)\"src\")); cur = cur->next; } })",
237
+ "#include <libxml/HTMLparser.h>\n#define COUNT_WORDS(doc) ({ xmlNodePtr cur = xmlDocGetRootElement(doc)->children; int count = 0; while (cur != NULL) { if (cur->type == XML_TEXT_NODE) count += xmlStrlen(cur->content); cur = cur->next; } count; })",
238
+ "#include <libxml/HTMLparser.h>\n#define SIMULATE_LOGIN(doc, username, password) ({ xmlNodePtr cur = xmlDocGetRootElement(doc)->children; while (cur != NULL) { if (cur->type == XML_ELEMENT_NODE && xmlStrcmp(cur->name, (xmlChar*)\"form\") == 0) printf(\"%s\\n\", xmlGetProp(cur, (xmlChar*)\"action\")); cur = cur->next; } })",
239
+ "#include <libxml/HTMLparser.h>\n#define HTML_TO_TEXT(doc) ({ xmlChar* text = xmlNodeGetContent(xmlDocGetRootElement(doc)); text; })",
240
+ "#include <regex.h>\n#define EXTRACT_EMAIL(str) ({ regex_t regex; regcomp(&regex, \"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}\", REG_EXTENDED); regmatch_t match; regexec(&regex, str, 1, &match, 0); strndup(str + match.rm_so, match.rm_eo - match.rm_so); })",
241
+ "#include <regex.h>\n#define EXTRACT_PHONE(str) ({ regex_t regex; regcomp(&regex, \"\\\\+?[0-9]{10,13}\", REG_EXTENDED); regmatch_t match; regexec(&regex, str, 1, &match, 0); strndup(str + match.rm_so, match.rm_eo - match.rm_so); })",
242
+ "#include <regex.h>\n#define FIND_ALL_NUMBERS(str) ({ regex_t regex; regcomp(&regex, \"[0-9]+\", REG_EXTENDED); regmatch_t match; char* result = str; while (regexec(&regex, result, 1, &match, 0) == 0) { printf(\"%s\\n\", strndup(result + match.rm_so, match.rm_eo - match.rm_so)); result += match.rm_eo; } })",
243
+ "#include <regex.h>\n#define REGEX_REPLACE(str, pattern, replacement) ({ regex_t regex; regcomp(&regex, pattern, REG_EXTENDED); regmatch_t match; char* result = str; while (regexec(&regex, result, 1, &match, 0) == 0) { printf(\"%s%s\", strndup(result, match.rm_so), replacement); result += match.rm_eo; } printf(\"%s\\n\", result); })",
244
+ "#include <regex.h>\n#define MATCH_REGEX(str, pattern) ({ regex_t regex; regcomp(&regex, pattern, REG_EXTENDED); regexec(&regex, str, 0, NULL, 0) == 0; })",
245
+ "#include <libxml/HTMLparser.h>\n#define REMOVE_HTML_TAGS(html) ({ xmlChar* text = xmlNodeGetContent(xmlDocGetRootElement(htmlReadDoc((xmlChar*)html, NULL, NULL, HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING))); text; })",
246
+ "#include <libxml/HTMLparser.h>\n#define HTML_ENCODE(str) ({ xmlChar* encoded = xmlEncodeEntitiesReentrant(NULL, (xmlChar*)str); encoded; })",
247
+ "#include <libxml/HTMLparser.h>\n#define HTML_DECODE(str) ({ xmlChar* decoded = xmlDecodeEntitiesReentrant(NULL, (xmlChar*)str, XML_SUBSTITUTE_REF); decoded; })",
248
+ "#include <gtk/gtk.h>\n#define CREATE_GUI_WINDOW() ({ gtk_init(NULL, NULL); GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_show_all(window); gtk_main(); })",
249
+ "void add_button_to_window(GtkWidget *window, const char *label) { GtkWidget *button = gtk_button_new_with_label(label); gtk_container_add(GTK_CONTAINER(window), button); }",
250
+ "void on_button_clicked(GtkWidget *widget, gpointer data) { g_print(\"Button clicked\\n\"); }",
251
+ "void show_message_dialog(GtkWidget *window, const char *message) { GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, message); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); }",
252
+ "const char *get_entry_text(GtkWidget *entry) { return gtk_entry_get_text(GTK_ENTRY(entry)); }",
253
+ "void set_window_title(GtkWidget *window, const char *title) { gtk_window_set_title(GTK_WINDOW(window), title); }",
254
+ "void set_window_size(GtkWidget *window, int width, int height) { gtk_window_set_default_size(GTK_WINDOW(window), width, height); }",
255
+ "void center_window(GtkWidget *window) { gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); }",
256
+ "GtkWidget *create_menu_bar() { return gtk_menu_bar_new(); }",
257
+ "GtkWidget *create_combo_box() { return gtk_combo_box_text_new(); }",
258
+ "GtkWidget *create_radio_button() { return gtk_radio_button_new(NULL); }",
259
+ "GtkWidget *create_check_button() { return gtk_check_button_new(); }",
260
+ "void show_image(GtkWidget *window, const char *file_path) { GtkWidget *image = gtk_image_new_from_file(file_path); gtk_container_add(GTK_CONTAINER(window), image); }",
261
+ "void play_audio(const char *file_path) { GstElement *pipeline = gst_parse_launch(\"playbin uri=file://\" file_path, NULL); gst_element_set_state(pipeline, GST_STATE_PLAYING); }",
262
+ "void play_video(const char *file_path) { GstElement *pipeline = gst_parse_launch(\"playbin uri=file://\" file_path, NULL); gst_element_set_state(pipeline, GST_STATE_PLAYING); }",
263
+ "gint64 get_current_play_time(GstElement *pipeline) { gint64 current_time; gst_element_query_position(pipeline, GST_FORMAT_TIME, &current_time); return current_time; }",
264
+ "void capture_screen() { Display *display = XOpenDisplay(NULL); Window root = DefaultRootWindow(display); XImage *image = XGetImage(display, root, 0, 0, DisplayWidth(display, 0), DisplayHeight(display, 0), AllPlanes, ZPixmap); XCloseDisplay(display); }",
265
+ "void record_screen(int duration) { /* Implementation for screen recording */ }",
266
+ "void get_mouse_position(int *x, int *y) { Display *display = XOpenDisplay(NULL); Window root = DefaultRootWindow(display); Window child; int root_x, root_y; XQueryPointer(display, root, &root, &child, x, y, &root_x, &root_y, NULL); XCloseDisplay(display); }",
267
+ "void simulate_keyboard_input(const char *text) { /* Implementation for keyboard input simulation */ }",
268
+ "void simulate_mouse_click(int x, int y) { /* Implementation for mouse click simulation */ }",
269
+ "time_t get_current_timestamp() { return time(NULL); }",
270
+ "char *timestamp_to_date(time_t timestamp) { return ctime(&timestamp); }",
271
+ "time_t date_to_timestamp(const char *date) { struct tm tm; strptime(date, \"%Y-%m-%d %H:%M:%S\", &tm); return mktime(&tm); }",
272
+ "int get_current_weekday() { time_t now = time(NULL); struct tm *tm = localtime(&now); return tm->tm_wday; }",
273
+ "int get_days_in_month(int year, int month) { struct tm tm = {0, 0, 0, 0, month - 1, year - 1900}; return 31 - ((mktime(&tm) / 86400) % 31); }",
274
+ "time_t get_first_day_of_year(int year) { struct tm tm = {0, 0, 0, 1, 0, year - 1900}; return mktime(&tm); }",
275
+ "time_t get_last_day_of_year(int year) { struct tm tm = {0, 0, 0, 31, 11, year - 1900}; return mktime(&tm); }",
276
+ "time_t get_first_day_of_month(int year, int month) { struct tm tm = {0, 0, 0, 1, month - 1, year - 1900}; return mktime(&tm); }",
277
+ "time_t get_last_day_of_month(int year, int month) { struct tm tm = {0, 0, 0, 0, month, year - 1900}; tm.tm_mday -= 1; return mktime(&tm); }",
278
+ "int is_weekday(time_t timestamp) { struct tm *tm = localtime(&timestamp); return tm->tm_wday >= 1 && tm->tm_wday <= 5; }",
279
+ "int is_weekend(time_t timestamp) { struct tm *tm = localtime(&timestamp); return tm->tm_wday == 0 || tm->tm_wday == 6; }",
280
+ "int get_current_hour() { time_t now = time(NULL); struct tm *tm = localtime(&now); return tm->tm_hour; }",
281
+ "int get_current_minute() { time_t now = time(NULL); struct tm *tm = localtime(&now); return tm->tm_min; }",
282
+ "int get_current_second() { time_t now = time(NULL); struct tm *tm = localtime(&now); return tm->tm_sec; }",
283
+ "void sleep_one_second() { sleep(1); }",
284
+ "long get_millisecond_timestamp() { struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec * 1000 + tv.tv_usec / 1000; }",
285
+ "char *format_time(time_t timestamp, const char *format) { struct tm *tm = localtime(&timestamp); static char buffer[80]; strftime(buffer, 80, format, tm); return buffer; }",
286
+ "time_t parse_time(const char *time_str, const char *format) { struct tm tm; strptime(time_str, format, &tm); return mktime(&tm); }",
287
+ "void *thread_function(void *arg) { /* Implementation for thread function */ return NULL; }",
288
+ "void create_thread() { pthread_t thread; pthread_create(&thread, NULL, thread_function, NULL); }",
289
+ "void pause_thread(pthread_t thread) { pthread_kill(thread, SIGSTOP); }",
290
+ "void run_function_in_thread(void *(*function)(void *), void *arg) { pthread_t thread; pthread_create(&thread, NULL, function, arg); }",
291
+ "char *get_current_thread_name() { static char name[16]; pthread_getname_np(pthread_self(), name, 16); return name; }",
292
+ "void set_thread_as_daemon(pthread_t thread) { pthread_detach(thread); }",
293
+ "pthread_mutex_t lock;",
294
+ "void lock_thread() { pthread_mutex_lock(&lock); }",
295
+ "void unlock_thread() { pthread_mutex_unlock(&lock); }",
296
+ "void create_process() { pid_t pid = fork(); if (pid == 0) { /* Child process */ } else { /* Parent process */ } }",
297
+ "pid_t get_process_pid() { return getpid(); }",
298
+ "int is_process_alive(pid_t pid) { return kill(pid, 0) == 0; }",
299
+ "void run_function_in_process(void (*function)()) { pid_t pid = fork(); if (pid == 0) { function(); exit(0); } }",
300
+ "void send_message_to_queue(int msgid, const void *msg, size_t size) { msgsnd(msgid, msg, size, 0); }",
301
+ "void receive_message_from_queue(int msgid, void *msg, size_t size, long type) { msgrcv(msgid, msg, size, type, 0); }",
302
+ "void pipe_communication() { int fd[2]; pipe(fd); if (fork() == 0) { close(fd[0]); write(fd[1], \"Hello\", 6); close(fd[1]); } else { close(fd[1]); char buffer[6]; read(fd[0], buffer, 6); close(fd[0]); } }",
303
+ "void limit_cpu_usage(int percentage) { /* Implementation for CPU usage limiting */ }",
304
+ "void run_shell_command(const char *command) { system(command); }",
305
+ "char *get_command_output(const char *command) { FILE *fp = popen(command, \"r\"); static char buffer[1024]; fgets(buffer, 1024, fp); pclose(fp); return buffer; }",
306
+ "int get_command_status_code(const char *command) { return system(command); }",
307
+ "int is_command_successful(const char *command) { return system(command) == 0; }",
308
+ "char *get_current_script_path() { static char path[1024]; readlink(\"/proc/self/exe\", path, 1024); return path; }",
309
+ "void parse_arguments(int argc, char *argv[]) { struct argp_option options[] = { {0} }; struct argp argp = {options, NULL, NULL, NULL}; argp_parse(&argp, argc, argv, 0, 0, NULL); }",
310
+ "void generate_help_document() { /* Implementation for help document generation */ }",
311
+ "void list_python_modules() { system(\"python -c 'import sys; print(sys.modules)'\"); }",
312
+ "void install_python_package(const char *package) { system(\"pip install \" package); }",
313
+ "void uninstall_python_package(const char *package) { system(\"pip uninstall \" package); }",
314
+ "char *get_package_version(const char *package) { FILE *fp = popen(\"pip show \" package, \"r\"); static char buffer[1024]; fgets(buffer, 1024, fp); pclose(fp); return buffer; }",
315
+ "void use_virtual_environment(const char *env) { setenv(\"VIRTUAL_ENV\", env, 1); }",
316
+ "void list_installed_packages() { system(\"pip list\"); }",
317
+ "void upgrade_python_package(const char *package) { system(\"pip install --upgrade \" package); }",
318
+ "void connect_to_database(const char *db_name) { sqlite3_open(db_name, &db); }",
319
+ "void execute_sql_query(const char *query) { sqlite3_exec(db, query, NULL, NULL, NULL); }",
320
+ "void insert_record(const char *table, const char *values) { char query[1024]; sprintf(query, \"INSERT INTO %s VALUES (%s)\", table, values); sqlite3_exec(db, query, NULL, NULL, NULL); }",
321
+ "void delete_record(const char *table, const char *condition) { char query[1024]; sprintf(query, \"DELETE FROM %s WHERE %s\", table, condition); sqlite3_exec(db, query, NULL, NULL, NULL); }",
322
+ "void update_record(const char *table, const char *set_clause, const char *condition) { char query[1024]; sprintf(query, \"UPDATE %s SET %s WHERE %s\", table, set_clause, condition); sqlite3_exec(db, query, NULL, NULL, NULL); }",
323
+ "void select_records(const char *table, const char *condition) { char query[1024]; sprintf(query, \"SELECT * FROM %s WHERE %s\", table, condition); sqlite3_exec(db, query, NULL, NULL, NULL); }",
324
+ "void use_parameterized_query(const char *query, const char *params) { sqlite3_stmt *stmt; sqlite3_prepare_v2(db, query, -1, &stmt, NULL); sqlite3_bind_text(stmt, 1, params, -1, SQLITE_STATIC); sqlite3_step(stmt); sqlite3_finalize(stmt); }",
325
+ "void close_database_connection() { sqlite3_close(db); }",
326
+ "void create_table(const char *table, const char *columns) { char query[1024]; sprintf(query, \"CREATE TABLE %s (%s)\", table, columns); sqlite3_exec(db, query, NULL, NULL, NULL); }",
327
+ "void drop_table(const char *table) { char query[1024]; sprintf(query, \"DROP TABLE %s\", table); sqlite3_exec(db, query, NULL, NULL, NULL); }",
328
+ "int is_table_exists(const char *table) { char query[1024]; sprintf(query, \"SELECT name FROM sqlite_master WHERE type='table' AND name='%s'\", table); sqlite3_stmt *stmt; sqlite3_prepare_v2(db, query, -1, &stmt, NULL); int result = sqlite3_step(stmt); sqlite3_finalize(stmt); return result == SQLITE_ROW; }",
329
+ "void list_all_tables() { sqlite3_exec(db, \"SELECT name FROM sqlite_master WHERE type='table'\", NULL, NULL, NULL); }",
330
+ "void orm_insert_data(const char *table, const char *values) { char query[1024]; sprintf(query, \"INSERT INTO %s VALUES (%s)\", table, values); sqlite3_exec(db, query, NULL, NULL, NULL); }",
331
+ "void orm_select_data(const char *table, const char *condition) { char query[1024]; sprintf(query, \"SELECT * FROM %s WHERE %s\", table, condition); sqlite3_exec(db, query, NULL, NULL, NULL); }",
332
+ "void orm_delete_data(const char *table, const char *condition) { char query[1024]; sprintf(query, \"DELETE FROM %s WHERE %s\", table, condition); sqlite3_exec(db, query, NULL, NULL, NULL); }",
333
+ "void orm_update_data(const char *table, const char *set_clause, const char *condition) { char query[1024]; sprintf(query, \"UPDATE %s SET %s WHERE %s\", table, set_clause, condition); sqlite3_exec(db, query, NULL, NULL, NULL); }",
334
+ "void define_model_class(const char *name, const char *fields) { /* Implementation for model class definition */ }",
335
+ "void implement_model_inheritance(const char *base_class, const char *derived_class) { /* Implementation for model inheritance */ }",
336
+ "void set_primary_key(const char *table, const char *field) { char query[1024]; sprintf(query, \"ALTER TABLE %s ADD PRIMARY KEY (%s)\", table, field); sqlite3_exec(db, query, NULL, NULL, NULL); }",
337
+ "void set_unique_constraint(const char *table, const char *field) { char query[1024]; sprintf(query, \"ALTER TABLE %s ADD UNIQUE (%s)\", table, field); sqlite3_exec(db, query, NULL, NULL, NULL); }",
338
+ "void set_field_default_value(const char *table, const char *field, const char *default_value) { char query[1024]; sprintf(query, \"ALTER TABLE %s ALTER COLUMN %s SET DEFAULT %s\", table, field, default_value); sqlite3_exec(db, query, NULL, NULL, NULL); }",
339
+ "void export_data_to_csv(const char *table, const char *file_path) { char query[1024]; sprintf(query, \".mode csv\\n.output %s\\nSELECT * FROM %s\", file_path, table); sqlite3_exec(db, query, NULL, NULL, NULL); }",
340
+ "void export_data_to_excel(const char *table, const char *file_path) { /* Implementation for Excel export */ }",
341
+ "void export_data_to_json(const char *table, const char *file_path) { /* Implementation for JSON export */ }",
342
+ "void read_excel_data(const char *file_path) { /* Implementation for Excel data reading */ }",
343
+ "void merge_excel_files(const char *file1, const char *file2, const char *output_file) { /* Implementation for Excel file merging */ }",
344
+ "void add_sheet_to_excel(const char *file_path, const char *sheet_name) { /* Implementation for adding sheet to Excel */ }",
345
+ "void copy_excel_sheet_style(const char *source_file, const char *target_file) { /* Implementation for copying Excel sheet style */ }",
346
+ "void set_excel_cell_color(const char *file_path, const char *sheet, int row, int col, const char *color) { /* Implementation for setting Excel cell color */ }",
347
+ "void set_excel_font_style(const char *file_path, const char *sheet, int row, int col, const char *style) { /* Implementation for setting Excel font style */ }",
348
+ "void read_excel_cell_content(const char *file_path, const char *sheet, int row, int col) { /* Implementation for reading Excel cell content */ }",
349
+ "void write_excel_cell_content(const char *file_path, const char *sheet, int row, int col, const char *content) { /* Implementation for writing Excel cell content */ }",
350
+ "void get_image_dimensions(const char *file_path, int *width, int *height) { /* Implementation for getting image dimensions */ }",
351
+ "void resize_image(const char *file_path, int new_width, int new_height) { /* Implementation for resizing image */ }"
352
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
 
354
 
355