-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbltings.src
More file actions
515 lines (349 loc) · 9.56 KB
/
bltings.src
File metadata and controls
515 lines (349 loc) · 9.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
//Max Function
list.max = function
return self[0:].sort[-1]
end function
map.max = function
Items = self.values
return self.indexes[Items.indexOf(Items.max)]
end function
//MaxIndex Function
list.maxIndex = function
return self.indexOf(self.max)
end function
//Min Function
list.min = function
return self[0:].sort[0]
end function
map.min = function
Items = self.values
return self.indexes[Items.indexOf(Items.max)]
end function
//MinIndex Function
list.minIndex = function
return self.indexOf(self.min)
end function
//Delete Function
list.delete = function(item)
if self.indexOf(item) != null then self.remove(self.indexOf(item))
return self
end function
//DeleteAll Function
list.deleteAll = function(item)
if self.indexOf(item) == null then return self
while self.indexOf(item) != null
self.delete(item)
end while
return self
end function
//Set Function
list.set = function
Values = []
for i in self
if Values.indexOf(i) == null then Values.push(i)
end for
return Values
end function
//Count Function
list.count = function(item)
return self.len - self[0:].deleteAll(item).len
end function
map.count = function(item)
return str(self[item]).len
end function
//Mean Function
list.mean = function
return sum(self) / self.len
end function
//Median Function
list.median = function
if self.len % 2 == 0 then
x = self.len / 2
return sum(self[0:]).sort[x : x + 1] / 2
end if
return self[0:].sort[floor(round(self.len / 2))]
end function
//Mode Function
list.mode = function
Items = self[0:].set
Counts = []
for i in Items
Counts.push(Items.count(i))
end for
return Counts[Counts.maxIndex]
end function
//ApplyFunction Function
list.applyFunction = function(func)
for i in range(self.len - 1)
self[i] = func(self[i])
end for
return self
end function
//Factors Function
factors = function(value)
Temp = []
for i in range(1, floor(sqrt(value)) + 1)
if value % i == 0 then Temp.push([i, floor(value / i)])
end for
Factors = []
for pair in Temp
for item in pair
Factors.push(item)
end for
end for
return Factors.set.sort
end function
number.factors = function
return factors(self)
end function
//FactorsPrime Function
factorsPrime = function(number)
Factors = [1]
while not isPrime(number)
number = floor(number / Factors[-1])
for i in factors(number)
if isPrime(i) then
Factors.push(i)
break
end if
end for
end while
return Factors[1:]
end function
number.factorsPrime = function
return factorsPrime(self)
end function
//IsPrime Function
isPrime = function(number)
if number == 1 then return false
return factors(number).len == 2
end function
number.isPrime = function
return isPrime(self)
end function
//GreatestCommonFactor Function
greatestCommonFactor = function(Values)
Items = Values[0:]
for i in range(Items.len - 1)
Items[i] = factors(Items[i])
end for
FactorAmounts = []
for item in Items
FactorAmounts.push(item.len)
end for
smallest = Items[FactorAmounts.minIndex]
Items.delete(smallest)
Data = []
for small in smallest
Temp = []
for item in Items
if item.indexOf(small) != null then Temp.push(true)
end for
if Temp.len > 0 then
if Temp.count(true) == Items.len then Data.push(small)
end if
end for
return Data.max
end function
//Decimal to Percent Function
decimalpercent = function(value)
return value * 100
end function
number.decimalpercent = function
return self * 100
end function
//Percent to Decimal Function
percentdecimal = function(value)
return value / 100
end function
number.percentdecimal = function
return self / 100
end function
//Percent to Multiplier Function
percentmultiplier = function(value)
return percentdecimal(value) + 1
end function
number.percentmultiplier = function
return percentdecimal(self) + 1
end function
//Multiplier to Percent Function
multiplierpercent = function(value)
return decimalpercent(value - 1)
end function
number.multiplierpercent = function
return decimalpercent(self - 1)
end function
//Decimal to Fraction Function
decimalfraction = function(value)
value = str(value).split("\.")
if value.len == 0 then return value[0]
denominator = 10 ^ value[1].len
numerator = value[1].to_int + (value[0].to_int * denominator)
factor = greatestCommonFactor([numerator, denominator])
numerator = floor(numerator / factor)
denominator = floor(denominator / factor)
return numerator + "/" + denominator
end function
number.decimalfraction = function
return decimalfraction(self)
end function
//Decimal to Base Function
decimalToBase = function(value, base)
digits = []
while value > 0
digits.push(floor(value % base))
value = floor(value / base)
end while
digits.reverse
return digits
end function
//Hex Function
hex = function(value)
dectohex = function(n)
if n < 10 then return n else return char(n + 87)
end function
return decimalToBase(value, 16).applyFunction(@dectohex).join("")
end function
//Binary function
bin = function(value)
return decimalToBase(value, 2).join("")
end function
//Binary function
oct = function(value)
return decimalToBase(value, 8).join("")
end function
//Capitalize Function
string.capitalize = function(self)
return self[0].upper + self[1:]
end function
//RFill Function
string.rfill = function(amount, filler = "0")
return self + filler * [0, amount - self.len].max
end function
//LFill Function
string.lfill = function(amount, filler = "0")
return filler * [0, amount - self.len].max + self
end function
//Format Function
string.format = function(Variables)
x = 0
while not self.indexOf("{}") == null
i = self.indexOf("{}")
self = self[0:i] + Variables[x] + self[i + 2:]
x = x + 1
end while
return self
end function
//Group Function
string.group = function(groupsize)
strings = []
for i in range(0, str(self).len, groupsize)
strings.push(str(self)[i : [i + groupsize, str(self).len].min])
end for
return strings
end function
//All Function
all = function(Values)
for item in Values
if not item then return false
end for
return true
end function
list.all = function
return all(self)
end function
//Any Function
any = function(Values)
for item in Values
if item then return true
end for
return false
end function
list.any = function
return any(self)
end function
//Folder Count Function
foldercount = function(folder)
if is_folder(file) then return file.get_folders.len else return null
end function
//File Count Function
filecount = function(folder)
if is_folder(file) then return file.get_files.len else return null
end function
//Open Ports Function
open_ports = function(router)
ports = []
for port in router.used_ports
if not port.is_closed then ports.push(port)
end for
return ports
end function
//Closed Ports Function
closed_ports = function(router)
ports = []
for port in router.used_ports
if port.is_closed then ports.push(port)
end for
return ports
end function
//File Hash Function
filehash = function(file)
return md5(file.get_content)
end function
//Folder Hash Function
folderhash = function(folder)
content = ""
for folder in folder.get_folders
content = "{}:{}".format([content,folder.path])
end for
for file in folder.get_files
content = "{}:{}".format([content,file.path])
end for
return md5(content)
end function
//String to List Function
string.list = function
stringlist = []
for i in self
stringlist.push(i)
end for
return stringlist
end function
//Base to Decimal Function
baseToDecimal = function(value, base)
valuestring = value.list
valuestring.reverse
for i in range(valuestring.len - 1)
valuestring[i] = to_int(valuestring[i])
if typeof(valuestring[i]) == "string" then valuestring[i] = valuestring[i].code - 87
end for
for i in range(0, valuestring.len - 1)
valuestring[i] = valuestring[i] * (base ^ i)
end for
return sum(valuestring)
end function
//Has Item Function
list.hasItem = function(item)
return self.indexOf(item) != null
end function
//Natural Log Function
nlog = function(number)
return log(number, e)
end function
//Log 10 Function
log10 = function(number)
return log(number, 10)
end function
//Natural Number
e = function
return 2.718281828459045
end function
//Random Integer
rndint = function(min, max)
return floor(rnd * (max - min + 1) + min)
end function
//Random Uniform
rnduni = function(min, max, decimals = 6)
max = max * 10 ^ decimals
min = min * 10 ^ decimals
return floor(rnd * (max - min + 1) + min) / 10 ^ decimals
end function