Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -13,143 +13,123 @@ app.logger = logging.getLogger("CodeSearchAPI")
|
|
13 |
|
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 |
-
"""class ChildClass extends MyClass {
|
118 |
-
constructor() {
|
119 |
-
super()
|
120 |
-
}
|
121 |
-
}""",
|
122 |
-
"""class ChildClass extends MyClass {
|
123 |
-
myMethod() {
|
124 |
-
super.myMethod()
|
125 |
-
}
|
126 |
-
}""",
|
127 |
-
"const instance = new MyClass(); instance.myMethod()",
|
128 |
-
"""class MyClass {
|
129 |
-
static myStaticMethod() {}
|
130 |
-
}""",
|
131 |
-
"const typeOf = obj => typeof obj",
|
132 |
-
"const getProp = (obj, prop) => obj[prop]",
|
133 |
-
"const setProp = (obj, prop, value) => obj[prop] = value",
|
134 |
-
"const deleteProp = (obj, prop) => delete obj[prop]",
|
135 |
"try{foo();}catch(e){}",
|
136 |
"throw new Error('CustomError')",
|
137 |
"""try{foo();}catch(e){const info=e.message;}""",
|
138 |
"console.error(err)",
|
139 |
"const timer={start(){this.s=Date.now()},stop(){return Date.now()-this.s}}",
|
140 |
"const runtime=(s)=>Date.now()-s",
|
141 |
-
"""const progress=(i,n)=>process.stdout.write(Math.floor(i/
|
142 |
"const delay=(ms)=>new Promise(r=>setTimeout(r,ms))",
|
143 |
-
"const f=(x)=>
|
144 |
-
"const m=arr.map(x=>
|
145 |
"const f2=arr.filter(x=>x>0)",
|
146 |
"const r=arr.reduce((a,x)=>a+x,0)",
|
147 |
-
"const a
|
148 |
-
"const o={a:1,b:2};const d={k
|
149 |
-
"const s=new Set(
|
150 |
-
"const inter=new Set(
|
151 |
-
"const uni=new Set(
|
152 |
-
"const diff=new Set(
|
153 |
"const noNone=list.filter(x=>x!=null)",
|
154 |
"""try{fs.openSync(path)}catch{}""",
|
155 |
"typeof x==='string'",
|
@@ -163,43 +143,43 @@ CODE_SNIPPETS = [
|
|
163 |
"for(...){if(cond)continue}",
|
164 |
"function fn(){}",
|
165 |
"function fn(a=1){}",
|
166 |
-
"function fn(){return
|
167 |
"function fn(...a){}",
|
168 |
"function fn(kwargs){const{a,b}=kwargs}",
|
169 |
"""function timed(fn){return(...a)=>{const s=Date.now();const r=fn(...a);console.log(Date.now()-s);return r}}""",
|
170 |
"""const deco=fn=>(...a)=>fn(...a)""",
|
171 |
-
"""const memo=fn=>{const c={};return x=>c
|
172 |
-
"
|
173 |
"const g=gen();",
|
174 |
-
"const it={i:0,next(){return this.i<2?{value
|
175 |
"for(const x of it){}",
|
176 |
-
"for(const
|
177 |
-
"const z=arr1.map((v,i)
|
178 |
-
"const dict=Object.fromEntries(arr1.map((v,i)
|
179 |
"JSON.stringify(arr1)===JSON.stringify(arr2)",
|
180 |
"JSON.stringify(obj1)===JSON.stringify(obj2)",
|
181 |
"JSON.stringify(new Set(a))===JSON.stringify(new Set(b))",
|
182 |
-
"const uniq
|
183 |
"set.clear()",
|
184 |
"set.size===0",
|
185 |
"set.add(x)",
|
186 |
"set.delete(x)",
|
187 |
"set.has(x)",
|
188 |
"set.size",
|
189 |
-
"const hasInt=(
|
190 |
"arr1.every(x=>arr2.includes(x))",
|
191 |
"str.includes(sub)",
|
192 |
-
"str
|
193 |
-
"str
|
194 |
-
"""const isText=path
|
195 |
-
"""const isImage=path
|
196 |
"Math.round(n)",
|
197 |
"Math.ceil(n)",
|
198 |
"Math.floor(n)",
|
199 |
"n.toFixed(2)",
|
200 |
-
"""const randStr=(l)
|
201 |
"const exists=require('fs').existsSync(path)",
|
202 |
-
"""const walk=(d)=>require('fs').readdirSync(d).flatMap(f=>{const p=require('path').join(d,f);return require('fs').statSync(p).isDirectory()?walk(p)
|
203 |
"""const ext=require('path').extname(fp)""",
|
204 |
"""const name=require('path').basename(fp)""",
|
205 |
"""const full=require('path').resolve(fp)""",
|
@@ -207,129 +187,130 @@ CODE_SNIPPETS = [
|
|
207 |
"process.platform",
|
208 |
"require('os').cpus().length",
|
209 |
"require('os').totalmem()",
|
210 |
-
"""const d=require('os').diskUsageSync?require('os').diskUsageSync('/')
|
211 |
"require('os').networkInterfaces()",
|
212 |
-
"""require('dns').resolve('
|
213 |
"""require('https').get(url,res=>res.pipe(require('fs').createWriteStream(dest)))""",
|
214 |
"""const upload=async f=>Promise.resolve('ok')""",
|
215 |
-
"""require('https').request({method:'POST',host,u
|
216 |
"""require('https').get(url+'?'+new URLSearchParams(params),res=>{})""",
|
217 |
"""const req=()=>fetch(url,{headers})""",
|
218 |
"""const jsdom=require('jsdom');const d=new jsdom.JSDOM(html)""",
|
219 |
-
"""const title=jsdom.JSDOM(html).window
|
220 |
-
"""const links
|
221 |
"""Promise.all(links.map(u=>fetch(u).then(r=>r.blob()).then(b=>require('fs').writeFileSync(require('path').basename(u),Buffer.from(b)))))""",
|
222 |
-
"""const freq=html.split(/\W+/).reduce((c,w)=>{c
|
223 |
-
"""const login=()=>fetch(url,{method:'POST',body
|
224 |
-
"""const text=html.replace(
|
225 |
-
"""const emails=html.match(
|
226 |
-
"""const phones=html.match(
|
227 |
"""const nums=html.match(/\d+/g)""",
|
228 |
"""const newHtml=html.replace(/foo/g,'bar')""",
|
229 |
-
"""const ok=/^\d{3}
|
230 |
-
"""const noTags=html.replace(
|
231 |
-
"""const enc=html.replace(/./g,c=>'
|
232 |
-
"""const dec=enc.replace(
|
233 |
-
"""const {app,BrowserWindow}=require('electron');app.on('ready',()=>new BrowserWindow().loadURL('about
|
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 |
-
"db
|
310 |
-
"db
|
311 |
-
"
|
312 |
-
"
|
313 |
-
"Model
|
314 |
-
"Model
|
315 |
-
"
|
316 |
-
"class
|
317 |
-
"
|
318 |
-
"
|
319 |
-
"
|
320 |
-
"
|
321 |
-
"
|
322 |
-
"
|
323 |
-
"
|
324 |
-
"
|
325 |
-
"xlsx
|
326 |
-
"
|
327 |
-
"
|
328 |
-
"
|
329 |
-
"
|
330 |
-
"
|
331 |
-
"
|
332 |
-
"
|
|
|
333 |
|
334 |
|
335 |
|
|
|
13 |
|
14 |
# 预定义代码片段
|
15 |
CODE_SNIPPETS = [
|
16 |
+
"echo 'Hello, World!';",
|
17 |
+
"function add($a, $b) { return $a + $b; }",
|
18 |
+
"$randomNumber = rand();",
|
19 |
+
"function isEven($num) { return $num % 2 == 0; }",
|
20 |
+
"strlen('example');",
|
21 |
+
"date('Y-m-d');",
|
22 |
+
"file_exists('example.txt');",
|
23 |
+
"file_get_contents('example.txt');",
|
24 |
+
"file_put_contents('example.txt', 'Hello, World!');",
|
25 |
+
"date('H:i:s');",
|
26 |
+
"strtoupper('example');",
|
27 |
+
"strtolower('EXAMPLE');",
|
28 |
+
"strrev('example');",
|
29 |
+
"count([1, 2, 3]);",
|
30 |
+
"max([1, 2, 3]);",
|
31 |
+
"min([1, 2, 3]);",
|
32 |
+
"sort([3, 1, 2]);",
|
33 |
+
"array_merge([1, 2], [3, 4]);",
|
34 |
+
"array_splice($array, $offset, $length);",
|
35 |
+
"empty([]);",
|
36 |
+
"substr_count('example', 'e');",
|
37 |
+
"strpos('example', 'amp') !== false;",
|
38 |
+
"strval(123);",
|
39 |
+
"intval('123');",
|
40 |
+
"is_numeric('123');",
|
41 |
+
"array_search('value', $array);",
|
42 |
+
"$array = [];",
|
43 |
+
"array_reverse([1, 2, 3]);",
|
44 |
+
"array_unique([1, 2, 2, 3]);",
|
45 |
+
"in_array('value', $array);",
|
46 |
+
"$array = ['key' => 'value'];",
|
47 |
+
"$array['new_key'] = 'new_value';",
|
48 |
+
"unset($array['key']);",
|
49 |
+
"array_keys($array);",
|
50 |
+
"array_values($array);",
|
51 |
+
"array_merge($array1, $array2);",
|
52 |
+
"empty($array);",
|
53 |
+
"$array['key'];",
|
54 |
+
"array_key_exists('key', $array);",
|
55 |
+
"$array = [];",
|
56 |
+
"count(file('example.txt'));",
|
57 |
+
"file_put_contents('example.txt', implode(PHP_EOL, $array));",
|
58 |
+
"file('example.txt', FILE_IGNORE_NEW_LINES);",
|
59 |
+
"str_word_count(file_get_contents('example.txt'));",
|
60 |
+
"function isLeapYear($year) { return ($year % 4 == 0 && ($year % 100 != 0 || $year % 400 == 0)); }",
|
61 |
+
"date('Y-m-d H:i:s');",
|
62 |
+
"(strtotime('2023-12-31') - strtotime('2023-01-01')) / (60 * 60 * 24);",
|
63 |
+
"getcwd();",
|
64 |
+
"scandir('.');",
|
65 |
+
"mkdir('new_directory');",
|
66 |
+
"rmdir('directory');",
|
67 |
+
"is_file('example.txt');",
|
68 |
+
"is_dir('directory');",
|
69 |
+
"filesize('example.txt');",
|
70 |
+
"rename('old.txt', 'new.txt');",
|
71 |
+
"copy('source.txt', 'destination.txt');",
|
72 |
+
"rename('source.txt', 'destination.txt');",
|
73 |
+
"unlink('example.txt');",
|
74 |
+
"getenv('PATH');",
|
75 |
+
"putenv('PATH=/new/path');",
|
76 |
+
"exec('start https://example.com');",
|
77 |
+
"file_get_contents('https://example.com');",
|
78 |
+
"json_decode('{\"key\":\"value\"}', true);",
|
79 |
+
"file_put_contents('example.json', json_encode($data));",
|
80 |
+
"json_decode(file_get_contents('example.json'), true);",
|
81 |
+
"implode(',', $array);",
|
82 |
+
"explode(',', 'a,b,c');",
|
83 |
+
"implode(PHP_EOL, $array);",
|
84 |
+
"explode(' ', 'a b c');",
|
85 |
+
"explode(',', 'a,b,c');",
|
86 |
+
"str_split('example');",
|
87 |
+
"str_replace('old', 'new', 'old text');",
|
88 |
+
"trim(' example ');",
|
89 |
+
"preg_replace('/[^a-zA-Z0-9]/', '', 'example!');",
|
90 |
+
"empty('');",
|
91 |
+
"strrev('example') == 'example';",
|
92 |
+
"fputcsv($file, $array);",
|
93 |
+
"array_map('str_getcsv', file('example.csv'));",
|
94 |
+
"count(file('example.csv'));",
|
95 |
+
"shuffle($array);",
|
96 |
+
"$array[array_rand($array)];",
|
97 |
+
"array_rand($array, $num);",
|
98 |
+
"rand(1, 6);",
|
99 |
+
"rand(0, 1);",
|
100 |
+
"substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'), 0, 8);",
|
101 |
+
"printf('#%06X', mt_rand(0, 0xFFFFFF));",
|
102 |
+
"uniqid();",
|
103 |
+
"class Example {}",
|
104 |
+
"$example = new Example();",
|
105 |
+
"class Example { function method() {} }",
|
106 |
+
"class Example { public $property; }",
|
107 |
+
"class Child extends Parent {}",
|
108 |
+
"class Child extends Parent { function method() {} }",
|
109 |
+
"Example::method();",
|
110 |
+
"Example::staticMethod();",
|
111 |
+
"is_object($example);",
|
112 |
+
"get_object_vars($example);",
|
113 |
+
"$example->property = 'value';",
|
114 |
+
"unset($example->property);",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
"try{foo();}catch(e){}",
|
116 |
"throw new Error('CustomError')",
|
117 |
"""try{foo();}catch(e){const info=e.message;}""",
|
118 |
"console.error(err)",
|
119 |
"const timer={start(){this.s=Date.now()},stop(){return Date.now()-this.s}}",
|
120 |
"const runtime=(s)=>Date.now()-s",
|
121 |
+
"""const progress=(i,n)=>process.stdout.write(Math.floor(i/n100)+'%\r')""",
|
122 |
"const delay=(ms)=>new Promise(r=>setTimeout(r,ms))",
|
123 |
+
"const f=(x)=>x2",
|
124 |
+
"const m=arr.map(x=>x2)",
|
125 |
"const f2=arr.filter(x=>x>0)",
|
126 |
"const r=arr.reduce((a,x)=>a+x,0)",
|
127 |
+
"const a=[1,2,3].map(x=>x)",
|
128 |
+
"const o={a:1,b:2};const d={k:v for([k,v] of Object.entries(o))}",
|
129 |
+
"const s=new Set([1,2,3]);const p=new Set(x for(x of s))",
|
130 |
+
"const inter=new Set([...a].filter(x=>b.has(x)))",
|
131 |
+
"const uni=new Set([...a,...b])",
|
132 |
+
"const diff=new Set([...a].filter(x=>!b.has(x)))",
|
133 |
"const noNone=list.filter(x=>x!=null)",
|
134 |
"""try{fs.openSync(path)}catch{}""",
|
135 |
"typeof x==='string'",
|
|
|
143 |
"for(...){if(cond)continue}",
|
144 |
"function fn(){}",
|
145 |
"function fn(a=1){}",
|
146 |
+
"function fn(){return [1,2]}",
|
147 |
"function fn(...a){}",
|
148 |
"function fn(kwargs){const{a,b}=kwargs}",
|
149 |
"""function timed(fn){return(...a)=>{const s=Date.now();const r=fn(...a);console.log(Date.now()-s);return r}}""",
|
150 |
"""const deco=fn=>(...a)=>fn(...a)""",
|
151 |
+
"""const memo=fn=>{const c={};return x=>c[x]||=(fn(x))}""",
|
152 |
+
"functiongen(){yield 1;yield 2}",
|
153 |
"const g=gen();",
|
154 |
+
"const it={i:0,next(){return this.i<2?{value:this.i++,done:false}:{done:true}}}",
|
155 |
"for(const x of it){}",
|
156 |
+
"for(const [i,x] of arr.entries()){}",
|
157 |
+
"const z=arr1.map((v,i)=>[v,arr2[i]])",
|
158 |
+
"const dict=Object.fromEntries(arr1.map((v,i)=>[v,arr2[i]]))",
|
159 |
"JSON.stringify(arr1)===JSON.stringify(arr2)",
|
160 |
"JSON.stringify(obj1)===JSON.stringify(obj2)",
|
161 |
"JSON.stringify(new Set(a))===JSON.stringify(new Set(b))",
|
162 |
+
"const uniq=[...new Set(arr)]",
|
163 |
"set.clear()",
|
164 |
"set.size===0",
|
165 |
"set.add(x)",
|
166 |
"set.delete(x)",
|
167 |
"set.has(x)",
|
168 |
"set.size",
|
169 |
+
"const hasInt=([...a].some(x=>b.has(x)))",
|
170 |
"arr1.every(x=>arr2.includes(x))",
|
171 |
"str.includes(sub)",
|
172 |
+
"str[0]",
|
173 |
+
"str[str.length-1]",
|
174 |
+
"""const isText=path=>['.txt','.md'].includes(require('path').extname(path))""",
|
175 |
+
"""const isImage=path=>['.png','.jpg','.jpeg','.gif'].includes(require('path').extname(path))""",
|
176 |
"Math.round(n)",
|
177 |
"Math.ceil(n)",
|
178 |
"Math.floor(n)",
|
179 |
"n.toFixed(2)",
|
180 |
+
"""const randStr=(l)=>[...Array(l)].map(()=>Math.random().toString(36).charAt(2)).join('')""",
|
181 |
"const exists=require('fs').existsSync(path)",
|
182 |
+
"""const walk=(d)=>require('fs').readdirSync(d).flatMap(f=>{const p=require('path').join(d,f);return require('fs').statSync(p).isDirectory()?walk(p):p})""",
|
183 |
"""const ext=require('path').extname(fp)""",
|
184 |
"""const name=require('path').basename(fp)""",
|
185 |
"""const full=require('path').resolve(fp)""",
|
|
|
187 |
"process.platform",
|
188 |
"require('os').cpus().length",
|
189 |
"require('os').totalmem()",
|
190 |
+
"""const d=require('os').diskUsageSync?require('os').diskUsageSync('/'):null""",
|
191 |
"require('os').networkInterfaces()",
|
192 |
+
"""require('dns').resolve('www.google.com',e=>console.log(!e))""",
|
193 |
"""require('https').get(url,res=>res.pipe(require('fs').createWriteStream(dest)))""",
|
194 |
"""const upload=async f=>Promise.resolve('ok')""",
|
195 |
+
"""require('https').request({method:'POST',host,u:path},()=>{}).end(data)""",
|
196 |
"""require('https').get(url+'?'+new URLSearchParams(params),res=>{})""",
|
197 |
"""const req=()=>fetch(url,{headers})""",
|
198 |
"""const jsdom=require('jsdom');const d=new jsdom.JSDOM(html)""",
|
199 |
+
"""const title=jsdom.JSDOM(html).window.document.querySelector('title').textContent""",
|
200 |
+
"""const links=[...d.window.document.querySelectorAll('a')].map(a=>a.href)""",
|
201 |
"""Promise.all(links.map(u=>fetch(u).then(r=>r.blob()).then(b=>require('fs').writeFileSync(require('path').basename(u),Buffer.from(b)))))""",
|
202 |
+
"""const freq=html.split(/\W+/).reduce((c,w)=>{c[w]=(c[w]||0)+1;return c},{})""",
|
203 |
+
"""const login=()=>fetch(url,{method:'POST',body:creds})""",
|
204 |
+
"""const text=html.replace(/<[^>]+>/g,'')""",
|
205 |
+
"""const emails=html.match(/[\w.-]+@[\w.-]+/g)""",
|
206 |
+
"""const phones=html.match(/\+?\d[\d -]{7,}\d/g)""",
|
207 |
"""const nums=html.match(/\d+/g)""",
|
208 |
"""const newHtml=html.replace(/foo/g,'bar')""",
|
209 |
+
"""const ok=/^\d{3}$/.test(str)""",
|
210 |
+
"""const noTags=html.replace(/<[^>]*>/g,'')""",
|
211 |
+
"""const enc=html.replace(/./g,c=>'&#'+c.charCodeAt(0)+';')""",
|
212 |
+
"""const dec=enc.replace(/&#(\d+);/g,(m,n)=>String.fromCharCode(n))""",
|
213 |
+
"""const {app,BrowserWindow}=require('electron');app.on('ready',()=>new BrowserWindow().loadURL('about:blank'))""",
|
214 |
+
"$button = new GtkButton('Click Me'); $window->add($button);",
|
215 |
+
"$button->connect('clicked', function() { echo 'Button clicked!'; });",
|
216 |
+
"$dialog = new GtkMessageDialog($window, GtkDialogFlags::MODAL, GtkMessageType::INFO, GtkButtonsType::OK, 'Hello!'); $dialog->run();",
|
217 |
+
"$entry = new GtkEntry(); $input = $entry->get_text();",
|
218 |
+
"$window->set_title('New Title');",
|
219 |
+
"$window->set_default_size(800, 600);",
|
220 |
+
"$window->set_position(Gtk::WIN_POS_CENTER);",
|
221 |
+
"$menubar = new GtkMenuBar(); $menu = new GtkMenu(); $menuitem = new GtkMenuItem('File'); $menuitem->set_submenu($menu); $menubar->append($menuitem); $window->add($menubar);",
|
222 |
+
"$combobox = new GtkComboBoxText(); $combobox->append_text('Option 1'); $combobox->append_text('Option 2'); $window->add($combobox);",
|
223 |
+
"$radiobutton1 = new GtkRadioButton('Option 1'); $radiobutton2 = new GtkRadioButton($radiobutton1, 'Option 2'); $window->add($radiobutton1); $window->add($radiobutton2);",
|
224 |
+
"$checkbutton = new GtkCheckButton('Check Me'); $window->add($checkbutton);",
|
225 |
+
"$image = new GtkImage('image.png'); $window->add($image);",
|
226 |
+
"exec('play audio.mp3');",
|
227 |
+
"exec('play video.mp4');",
|
228 |
+
"$current_time = exec('get_current_time_command');",
|
229 |
+
"exec('screenshot_command');",
|
230 |
+
"exec('record_screen_command');",
|
231 |
+
"$mouse_position = exec('get_mouse_position_command');",
|
232 |
+
"exec('simulate_keyboard_input_command');",
|
233 |
+
"exec('simulate_mouse_click_command');",
|
234 |
+
"time();",
|
235 |
+
"date('Y-m-d H:i:s', $timestamp);",
|
236 |
+
"strtotime('2023-10-01 12:00:00');",
|
237 |
+
"date('l');",
|
238 |
+
"date('t');",
|
239 |
+
"date('Y-01-01');",
|
240 |
+
"date('Y-12-31');",
|
241 |
+
"date('Y-m-01', strtotime('2023-10-01'));",
|
242 |
+
"date('Y-m-t', strtotime('2023-10-01'));",
|
243 |
+
"date('N') < 6;",
|
244 |
+
"date('N') >= 6;",
|
245 |
+
"date('H');",
|
246 |
+
"date('i');",
|
247 |
+
"date('s');",
|
248 |
+
"sleep(1);",
|
249 |
+
"floor(microtime(true) * 1000);",
|
250 |
+
"date('Y-m-d H:i:s', $time);",
|
251 |
+
"strtotime($time_string);",
|
252 |
+
"$thread = new Thread(); $thread->start();",
|
253 |
+
"$thread->sleep(1);",
|
254 |
+
"$threads = []; for ($i = 0; $i < 5; $i++) { $threads[$i] = new Thread(); $threads[$i]->start(); }",
|
255 |
+
"$thread->getName();",
|
256 |
+
"$thread->setDaemon(true);",
|
257 |
+
"$lock = new Mutex(); $lock->lock(); $lock->unlock();",
|
258 |
+
"$pid = pcntl_fork();",
|
259 |
+
"getmypid();",
|
260 |
+
"posix_kill($pid, 0);",
|
261 |
+
"$pids = []; for ($i = 0; $i < 5; $i++) { $pids[$i] = pcntl_fork(); if ($pids[$i] == 0) { exit; } }",
|
262 |
+
"$queue = new Threaded(); $queue->push('value');",
|
263 |
+
"$pipe = fopen('php://stdin', 'r'); fwrite($pipe, 'value'); fclose($pipe);",
|
264 |
+
"set_time_limit(0);",
|
265 |
+
"exec('ls');",
|
266 |
+
"exec('ls', $output);",
|
267 |
+
"exec('ls', $output, $status);",
|
268 |
+
"$status === 0;",
|
269 |
+
"__FILE__;",
|
270 |
+
"$argv;",
|
271 |
+
"$parser = new ArgParser(); $parser->addArgument('arg1'); $parser->parse($argv);",
|
272 |
+
"$parser->printHelp();",
|
273 |
+
"print_r(get_loaded_extensions());",
|
274 |
+
"exec('pip install package_name');",
|
275 |
+
"exec('pip uninstall package_name');",
|
276 |
+
"exec('pip show package_name | grep Version');",
|
277 |
+
"exec('python -m venv venv');",
|
278 |
+
"exec('pip list');",
|
279 |
+
"exec('pip install --upgrade package_name');",
|
280 |
+
"$db = new SQLite3('database.db');",
|
281 |
+
"$result = $db->query('SELECT * FROM table');",
|
282 |
+
"$db->exec(\"INSERT INTO table (column) VALUES ('value')\");",
|
283 |
+
"$db->exec(\"DELETE FROM table WHERE id = 1\");",
|
284 |
+
"$db->exec(\"UPDATE table SET column = 'new_value' WHERE id = 1\");",
|
285 |
+
"$result = $db->query('SELECT * FROM table'); while ($row = $result->fetchArray()) { print_r($row); }",
|
286 |
+
"$stmt = $db->prepare('SELECT * FROM table WHERE id = :id'); $stmt->bindValue(':id', 1); $result = $stmt->execute();",
|
287 |
+
"$db->close();",
|
288 |
+
"$db->exec('CREATE TABLE table (id INTEGER PRIMARY KEY, column TEXT)');",
|
289 |
+
"$db->exec('DROP TABLE table');",
|
290 |
+
"$result = $db->query(\"SELECT name FROM sqlite_master WHERE type='table' AND name='table'\");",
|
291 |
+
"$result = $db->query(\"SELECT name FROM sqlite_master WHERE type='table'\");",
|
292 |
+
"$model = new Model(); $model->save();",
|
293 |
+
"$model = Model::find(1);",
|
294 |
+
"$model = Model::find(1); $model->delete();",
|
295 |
+
"$model = Model::find(1); $model->column = 'new_value'; $model->save();",
|
296 |
+
"class Model extends ORM { protected static $table = 'table'; }",
|
297 |
+
"class ChildModel extends ParentModel {}",
|
298 |
+
"protected static $primaryKey = 'id';",
|
299 |
+
"protected static $unique = ['column'];",
|
300 |
+
"protected static $defaults = ['column' => 'default_value'];",
|
301 |
+
"$file = fopen('data.csv', 'w'); fputcsv($file, $data); fclose($file);",
|
302 |
+
"$excel = new ExcelWriter('data.xlsx'); $excel->write($data); $excel->close();",
|
303 |
+
"$json = json_encode($data); file_put_contents('data.json', $json);",
|
304 |
+
"$excel = new ExcelReader('data.xlsx'); $data = $excel->read(); $excel->close();",
|
305 |
+
"$excel = new ExcelWriter('merged.xlsx'); foreach ($files as $file) { $data = (new ExcelReader($file))->read(); $excel->write($data); } $excel->close();",
|
306 |
+
"$excel = new ExcelWriter('data.xlsx'); $excel->addSheet('New Sheet'); $excel->close();",
|
307 |
+
"$excel = new ExcelWriter('data.xlsx'); $excel->copyStyle('Sheet1', 'Sheet2'); $excel->close();",
|
308 |
+
"$excel = new ExcelWriter('data.xlsx'); $excel->setCellColor('A1', 'FF0000'); $excel->close();",
|
309 |
+
"$excel = new ExcelWriter('data.xlsx'); $excel->setFontStyle('A1', 'bold'); $excel->close();",
|
310 |
+
"$excel = new ExcelReader('data.xlsx'); $value = $excel->getCellValue('A1'); $excel->close();",
|
311 |
+
"$excel = new ExcelWriter('data.xlsx'); $excel->setCellValue('A1', 'Hello'); $excel->close();",
|
312 |
+
"list($width, $height) = getimagesize('image.png');",
|
313 |
+
"$image = new Imagick('image.png'); $image->resizeImage(100, 100, Imagick::FILTER_LANCZOS, 1); $image->writeImage('resized_image.png');"
|
314 |
|
315 |
|
316 |
|