politics 1.0.89 → 1.0.94
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README +2 -0
- data/README.md +62 -51
- data/VERSION_NUMBER +1 -1
- data/bin/autocorrect +312 -0
- data/bin/black +0 -0
- data/bin/black_bold +0 -0
- data/bin/black_bold_underline +0 -0
- data/bin/black_underline +0 -0
- data/bin/blue +0 -0
- data/bin/blue_bold +0 -0
- data/bin/blue_bold_underline +0 -0
- data/bin/blue_underline +0 -0
- data/bin/bold +0 -0
- data/bin/cyan +0 -0
- data/bin/cyan_bold +0 -0
- data/bin/cyan_bold_underline +0 -0
- data/bin/cyan_underline +0 -0
- data/bin/green +0 -0
- data/bin/green_bold +0 -0
- data/bin/green_bold_underline +0 -0
- data/bin/green_underline +0 -0
- data/bin/magenta +0 -0
- data/bin/magenta_bold +0 -0
- data/bin/magenta_bold_underline +0 -0
- data/bin/magenta_underline +0 -0
- data/bin/red +0 -0
- data/bin/red_bold +0 -0
- data/bin/red_bold_underline +0 -0
- data/bin/red_underline +0 -0
- data/bin/underline +0 -0
- data/bin/white +0 -0
- data/bin/white_bold +0 -0
- data/bin/white_bold_underline +0 -0
- data/bin/white_underline +0 -0
- data/bin/yellow +0 -0
- data/bin/yellow_bold +0 -0
- data/bin/yellow_bold_underline +0 -0
- data/bin/yellow_underline +0 -0
- data/documentation/autocorrect +3 -0
- data/documentation/ctit +12 -1
- data/documentation/email +2 -2
- data/documentation/left_right.exe +4 -3
- data/gem_data/README +2 -0
- data/gem_data/VERSION_NUMBER +1 -1
- data/gem_data/push_snap +30 -0
- data/images/STORE.png +0 -0
- data/images/STORE2.png +0 -0
- data/images/Store.png +0 -0
- data/index.html +60 -57
- data/non_compiled_programs/autocorrect +312 -0
- data/push_snap +30 -0
- data/src/color_tools/black +0 -0
- data/src/color_tools/black.c +9 -12
- data/src/color_tools/black_bold +0 -0
- data/src/color_tools/black_bold.c +9 -12
- data/src/color_tools/black_bold_underline +0 -0
- data/src/color_tools/black_bold_underline.c +9 -12
- data/src/color_tools/black_underline +0 -0
- data/src/color_tools/black_underline.c +9 -12
- data/src/color_tools/blue +0 -0
- data/src/color_tools/blue.c +9 -12
- data/src/color_tools/blue_bold +0 -0
- data/src/color_tools/blue_bold.c +9 -12
- data/src/color_tools/blue_bold_underline +0 -0
- data/src/color_tools/blue_bold_underline.c +9 -12
- data/src/color_tools/blue_underline +0 -0
- data/src/color_tools/blue_underline.c +9 -12
- data/src/color_tools/bold +0 -0
- data/src/color_tools/bold.c +9 -12
- data/src/color_tools/colors.rb +9 -12
- data/src/color_tools/cyan +0 -0
- data/src/color_tools/cyan.c +9 -12
- data/src/color_tools/cyan_bold +0 -0
- data/src/color_tools/cyan_bold.c +9 -12
- data/src/color_tools/cyan_bold_underline +0 -0
- data/src/color_tools/cyan_bold_underline.c +9 -12
- data/src/color_tools/cyan_underline +0 -0
- data/src/color_tools/cyan_underline.c +9 -12
- data/src/color_tools/green +0 -0
- data/src/color_tools/green.c +9 -12
- data/src/color_tools/green_bold +0 -0
- data/src/color_tools/green_bold.c +9 -12
- data/src/color_tools/green_bold_underline +0 -0
- data/src/color_tools/green_bold_underline.c +9 -12
- data/src/color_tools/green_underline +0 -0
- data/src/color_tools/green_underline.c +9 -12
- data/src/color_tools/magenta +0 -0
- data/src/color_tools/magenta.c +9 -12
- data/src/color_tools/magenta_bold +0 -0
- data/src/color_tools/magenta_bold.c +9 -12
- data/src/color_tools/magenta_bold_underline +0 -0
- data/src/color_tools/magenta_bold_underline.c +9 -12
- data/src/color_tools/magenta_underline +0 -0
- data/src/color_tools/magenta_underline.c +9 -12
- data/src/color_tools/red +0 -0
- data/src/color_tools/red.c +9 -12
- data/src/color_tools/red_bold +0 -0
- data/src/color_tools/red_bold.c +9 -12
- data/src/color_tools/red_bold_underline +0 -0
- data/src/color_tools/red_bold_underline.c +9 -12
- data/src/color_tools/red_underline +0 -0
- data/src/color_tools/red_underline.c +9 -12
- data/src/color_tools/underline +0 -0
- data/src/color_tools/underline.c +9 -12
- data/src/color_tools/white +0 -0
- data/src/color_tools/white.c +9 -12
- data/src/color_tools/white_bold +0 -0
- data/src/color_tools/white_bold.c +9 -12
- data/src/color_tools/white_bold_underline +0 -0
- data/src/color_tools/white_bold_underline.c +9 -12
- data/src/color_tools/white_underline +0 -0
- data/src/color_tools/white_underline.c +9 -12
- data/src/color_tools/yellow +0 -0
- data/src/color_tools/yellow.c +9 -12
- data/src/color_tools/yellow_bold +0 -0
- data/src/color_tools/yellow_bold.c +9 -12
- data/src/color_tools/yellow_bold_underline +0 -0
- data/src/color_tools/yellow_bold_underline.c +9 -12
- data/src/color_tools/yellow_underline +0 -0
- data/src/color_tools/yellow_underline.c +9 -12
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33b2ae2fa0148b8eb6b1eb12d3c802a304c1e516f02f23d31d44992e893a9240
|
4
|
+
data.tar.gz: a8e3e4f038ecf754cef5b51e2863f146f10368fadf5a12e4dfac14d0b274b45f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73ffe59b5103d65e390a7cddddafb22452022507384134370ac4520698fa61696a97b0b83411b21bae0c28715bbaf6d6cbfa3c5f0f89af77f8df9d0d60ca1586
|
7
|
+
data.tar.gz: 51a056c61fae58bf56147c6cf4b13b0bf49a527ed237a8375b882e4fc9ef2e31681c4a903460be94a7041e20c8542fe3495cf975cfe292447c9419e4dded634b
|
data/README
CHANGED
data/README.md
CHANGED
@@ -31,7 +31,7 @@ I intend to make people more able.
|
|
31
31
|
I was working on a “to buy” program regarding stocks, but it only
|
32
32
|
partly works right now and it's not as useful as the other software.
|
33
33
|
The find housing tool actually helped me to find housing in real life.
|
34
|
-
Those aside, there are these
|
34
|
+
Those aside, there are these 88 programs.
|
35
35
|
Some ones that convert text are skipped in this documentation because
|
36
36
|
their name and usage is obvious (e.g., color tools).
|
37
37
|
|
@@ -109,7 +109,7 @@ You can use them anywhere without dependencies.
|
|
109
109
|
|
110
110
|
Democracy Github Ruby Gem Python PIP Package
|
111
111
|
|
112
|
-
Without further ado, here are the
|
112
|
+
Without further ado, here are the 88 documented programs. (The obvious usage
|
113
113
|
ones are omitted.)
|
114
114
|
|
115
115
|
### 1. Ultimate Chat Application.exe
|
@@ -184,10 +184,10 @@ ones are omitted.)
|
|
184
184
|
|
185
185
|
This is a tool to bring sanity to politics.
|
186
186
|
![UCA](./images/8.png)
|
187
|
-
It
|
188
|
-
side
|
189
|
-
It then presents all of that.
|
190
|
-
Hopefully this can make people more sane and less hyper-partisan.
|
187
|
+
It asks for viewpints from a person that see the good things in each
|
188
|
+
political side--left, right, left, right, etc.
|
189
|
+
It then makes a webpage of that and presents all of that.
|
190
|
+
Hopefully this can make people more sane, and less hyper-partisan.
|
191
191
|
### 5. Find Housing
|
192
192
|
|
193
193
|
This is a nice tool to find housing with.
|
@@ -217,7 +217,12 @@ ones are omitted.)
|
|
217
217
|
(echo 2; echo; echo; echo) | selectlines
|
218
218
|
=> 2
|
219
219
|
The result would be 2, with no blank lines after that
|
220
|
-
### 10.
|
220
|
+
### 10. Autocorrect
|
221
|
+
|
222
|
+
Command line offline non-AI free software BSD licensed autocorrect
|
223
|
+
using words file.
|
224
|
+
Work in progress.
|
225
|
+
### 11. Processes
|
221
226
|
|
222
227
|
Processes lists all processes with a certain name
|
223
228
|
For example
|
@@ -225,7 +230,7 @@ ones are omitted.)
|
|
225
230
|
processes bash
|
226
231
|
processes ruby
|
227
232
|
processes gsub
|
228
|
-
###
|
233
|
+
### 12. Emeraldc
|
229
234
|
|
230
235
|
The Ultimate C Preprocessor
|
231
236
|
I'm naming this preprocessor “Emerald C.”
|
@@ -357,32 +362,32 @@ ones are omitted.)
|
|
357
362
|
sys 0m0.160s
|
358
363
|
Rust takes 0.637 seconds to compile an empty file!
|
359
364
|
That is not ideal.
|
360
|
-
###
|
365
|
+
### 13. Nth Word
|
361
366
|
|
362
367
|
nth_word gets the nth word of each line
|
363
368
|
For example
|
364
369
|
nth_word 3
|
365
370
|
gets the 3rd word of each line
|
366
|
-
###
|
371
|
+
### 14. Last Nth
|
367
372
|
|
368
373
|
Last nth gets the last n lines from input
|
369
374
|
For example
|
370
375
|
last_nth 3
|
371
376
|
Would get the 3rd from the last line
|
372
|
-
###
|
377
|
+
### 15. Speakcat
|
373
378
|
|
374
379
|
Speak cat is a tool like “cat,” which shows the content of files
|
375
380
|
(technically, it combines the content of files).
|
376
381
|
But speak cat also speaks the text.
|
377
382
|
Which could be useful in some circumstances.
|
378
383
|
It's kind of like “tee” to your ear.
|
379
|
-
###
|
384
|
+
### 16. UCA CLI
|
380
385
|
|
381
386
|
CLI for uca app
|
382
|
-
###
|
387
|
+
### 17. Big Num
|
383
388
|
|
384
389
|
![UCA](./images/10.png)
|
385
|
-
###
|
390
|
+
### 18. Squeeze
|
386
391
|
|
387
392
|
Squeeze reads all input from stdin, then it prints it back omitting
|
388
393
|
argument 1 line from the front, and argument 2 lines from the back
|
@@ -392,20 +397,20 @@ ones are omitted.)
|
|
392
397
|
squeeze 5 3
|
393
398
|
This would omit the first 5 lines and the last 3 lines
|
394
399
|
squeeze 2 2 [file] also works, it outputs text to file
|
395
|
-
###
|
400
|
+
### 19. Dictate
|
396
401
|
|
397
402
|
Dictate opens web pages in emerald browser, or in any browser
|
398
403
|
(depending on the environment variable set), by you speaking, instead
|
399
404
|
of typing.
|
400
405
|
There is a mode called c_mode, that allows you to make code from
|
401
406
|
speaking.
|
402
|
-
###
|
407
|
+
### 20. Prepend
|
403
408
|
|
404
409
|
prepend prepends input taken from the standard input to a file
|
405
410
|
Usage
|
406
411
|
prepend [file]
|
407
412
|
This is text to be prepended
|
408
|
-
###
|
413
|
+
### 21. Chat Rb
|
409
414
|
|
410
415
|
This program is excellent.
|
411
416
|
It's essentially a mix of ChatGPT and a shell, such as bash or ZSH.
|
@@ -414,16 +419,16 @@ ones are omitted.)
|
|
414
419
|
It outputs chatgpt data to an output folder in home folder and copies
|
415
420
|
it to clipboard
|
416
421
|
To run a shell command, prefix things with “c,” such as c gcc.....
|
417
|
-
###
|
422
|
+
### 22. Append
|
418
423
|
|
419
424
|
Appends text to file
|
420
425
|
Example
|
421
426
|
append file
|
422
427
|
This is more text to be appended
|
423
|
-
###
|
428
|
+
### 23. Delete
|
424
429
|
|
425
430
|
Recursively delete all files named a certain name.
|
426
|
-
###
|
431
|
+
### 24. Gsubip
|
427
432
|
|
428
433
|
Global Substitute (Gsub) In Place
|
429
434
|
gsubip is like gsub, which replaces all instances of a regular
|
@@ -440,7 +445,7 @@ ones are omitted.)
|
|
440
445
|
It takes exactly 3 arguments, no more, no fewer.
|
441
446
|
See also
|
442
447
|
gsub
|
443
|
-
###
|
448
|
+
### 25. Rhyme
|
444
449
|
|
445
450
|
A very powerful music generator program that doesn't use AI.
|
446
451
|
See this channel as an example of potential usage of this public
|
@@ -621,7 +626,7 @@ ones are omitted.)
|
|
621
626
|
Disingenuous to the extreme, the society they subvert
|
622
627
|
The society is the ones who hurt
|
623
628
|
---
|
624
|
-
###
|
629
|
+
### 26. Email
|
625
630
|
|
626
631
|
This currently doesn't work for gmail since 2022 due to policy changes.
|
627
632
|
A simple and practical tool to email people using Himalaya
|
@@ -629,17 +634,17 @@ ones are omitted.)
|
|
629
634
|
You would need to configure the script by changing its source code.
|
630
635
|
Modes
|
631
636
|
email [no arguments]
|
632
|
-
|
637
|
+
email [yourself]
|
633
638
|
email [addr]
|
634
|
-
|
639
|
+
email one email address
|
635
640
|
email [Subject] [addr] [option more addrs]
|
636
641
|
Example
|
637
642
|
email 'Gregory, I love your software!' gregorycohenvideos@gmail.com
|
638
643
|
my_friend@outlook.com person@example.com
|
639
|
-
###
|
644
|
+
### 27. Floor
|
640
645
|
|
641
646
|
Gets the floor of numbers e.g. 21.3 -> 21
|
642
|
-
###
|
647
|
+
### 28. Rgsub
|
643
648
|
|
644
649
|
Recursively replaces text.
|
645
650
|
Verbosely tells you everything that happens.
|
@@ -657,11 +662,11 @@ ones are omitted.)
|
|
657
662
|
-v, verbose mode
|
658
663
|
-- Indicate end of options.
|
659
664
|
|
660
|
-
###
|
665
|
+
### 29. Lines
|
661
666
|
|
662
667
|
Lines gets the number of files in the current folder that you are in.
|
663
668
|
It can also act like “wc -l” if you pipe data into it.
|
664
|
-
###
|
669
|
+
### 30. Clock
|
665
670
|
|
666
671
|
clock is useful
|
667
672
|
clock is a command line alarm clock
|
@@ -678,14 +683,14 @@ ones are omitted.)
|
|
678
683
|
To stop it
|
679
684
|
Run this command
|
680
685
|
clock stop
|
681
|
-
###
|
686
|
+
### 31. Emoji
|
682
687
|
|
683
688
|
Emoji converts words to emojis from the standard input
|
684
689
|
It can also speak the output
|
685
690
|
It can also copy the output to your clipboard
|
686
691
|
It is very useful
|
687
692
|
![UCA](./images/6.png)
|
688
|
-
###
|
693
|
+
### 32. Close
|
689
694
|
|
690
695
|
“Close” is a simple program that closes “Emerald Browser,” a new web
|
691
696
|
browser based on the same engine as Chrome. Currently, Emerald Browser
|
@@ -719,17 +724,22 @@ ones are omitted.)
|
|
719
724
|
some people.
|
720
725
|
Currently, content, like YouTube videos, can't be made fullscreen.
|
721
726
|
If anyone wants to contribute, feel free to!
|
722
|
-
###
|
727
|
+
### 33. Copy
|
723
728
|
|
724
729
|
copy copies the standard input
|
725
730
|
Example
|
726
731
|
ls | copy
|
727
|
-
###
|
732
|
+
### 34. Ctit
|
728
733
|
|
729
734
|
Capitalize Title
|
730
735
|
A work in progress.
|
731
|
-
Capitalizes
|
732
|
-
|
736
|
+
Capitalizes arguments and treats them like a title.
|
737
|
+
ctit this is my heading
|
738
|
+
==> This Is My Heading for a Document
|
739
|
+
You can also do
|
740
|
+
ctit .... | copy
|
741
|
+
To copy the title to your clipboard
|
742
|
+
### 35. Gsub
|
733
743
|
|
734
744
|
Gsub is very powerful.
|
735
745
|
Usage
|
@@ -738,7 +748,7 @@ ones are omitted.)
|
|
738
748
|
cat text | gsub man dog
|
739
749
|
cat text | gsub 'man|boy|cat|dog' food
|
740
750
|
ls | gsub Desktop cat
|
741
|
-
###
|
751
|
+
### 36. News
|
742
752
|
|
743
753
|
Gets the news from bbc
|
744
754
|
Usage
|
@@ -746,14 +756,14 @@ ones are omitted.)
|
|
746
756
|
news speak
|
747
757
|
uses google_speak to SPEAK the news, one story at a time.
|
748
758
|
![UCA](./images/5.png)
|
749
|
-
###
|
759
|
+
### 37. Args
|
750
760
|
|
751
761
|
args is like a better xargs
|
752
762
|
args works properly with spaces in the name of commands
|
753
763
|
It takes exactly one argument
|
754
764
|
Example
|
755
765
|
ls | args “mv -t ../f”
|
756
|
-
###
|
766
|
+
### 38. Rnip
|
757
767
|
|
758
768
|
Replace Not In Place
|
759
769
|
This is like gsub, but for strings, not for regular expressions
|
@@ -761,10 +771,10 @@ ones are omitted.)
|
|
761
771
|
echo .......... | rnip foo bar
|
762
772
|
See also
|
763
773
|
gsub
|
764
|
-
###
|
774
|
+
### 39. Trim
|
765
775
|
|
766
776
|
Trims spaces of each line
|
767
|
-
###
|
777
|
+
### 40. Quot
|
768
778
|
|
769
779
|
Turns quotes in text into good text and makes text presentable.
|
770
780
|
Example
|
@@ -775,7 +785,7 @@ ones are omitted.)
|
|
775
785
|
Example 3
|
776
786
|
(Quote the file and output it)
|
777
787
|
quot text_file
|
778
|
-
###
|
788
|
+
### 41. Open
|
779
789
|
|
780
790
|
“open” is a very efficient program that searches a query from google,
|
781
791
|
and then opens it in Emerald Browser.
|
@@ -796,25 +806,25 @@ ones are omitted.)
|
|
796
806
|
See also
|
797
807
|
emerald-browser
|
798
808
|
close
|
799
|
-
###
|
809
|
+
### 42. Swap
|
800
810
|
|
801
811
|
Swaps two files
|
802
812
|
Example
|
803
813
|
swap text1 text2
|
804
|
-
###
|
814
|
+
### 43. Exp
|
805
815
|
|
806
816
|
exp is an exponentiation tool
|
807
817
|
(echo 5; echo 3) | exp
|
808
818
|
=> 125
|
809
819
|
(echo 2; echo 10) | exp
|
810
820
|
=> 1024
|
811
|
-
###
|
821
|
+
### 44. Div
|
812
822
|
|
813
823
|
Divides numbers
|
814
824
|
Example
|
815
825
|
(echo 5000; echo 100) | div
|
816
826
|
=> 50
|
817
|
-
###
|
827
|
+
### 45. Mul
|
818
828
|
|
819
829
|
Multiply numbers
|
820
830
|
echo 1 > file
|
@@ -824,10 +834,10 @@ ones are omitted.)
|
|
824
834
|
echo 5 >> file
|
825
835
|
cat file | mul
|
826
836
|
=> 120
|
827
|
-
###
|
837
|
+
### 46. Nth
|
828
838
|
|
829
839
|
Nth gets the nth line from the input
|
830
|
-
###
|
840
|
+
### 47. Abs
|
831
841
|
|
832
842
|
Abs gets the absolute value of an integer
|
833
843
|
The absolute value of a number is the value of that number without its
|
@@ -840,13 +850,13 @@ ones are omitted.)
|
|
840
850
|
=> 12
|
841
851
|
The last one would do -2 - -10, the result would be -12, and then the
|
842
852
|
absolute value would be computed, and so the result would be 12.
|
843
|
-
###
|
853
|
+
### 48. Add
|
844
854
|
|
845
855
|
See the sub example
|
846
856
|
add adds integers from the standard input
|
847
857
|
(echo 1; echo 2; echo 3) | add
|
848
858
|
The result would be 6
|
849
|
-
###
|
859
|
+
### 49. Sub
|
850
860
|
|
851
861
|
Sub is a simple command line program that subtracts integers.
|
852
862
|
For some reason, no simple program did this.
|
@@ -863,14 +873,14 @@ ones are omitted.)
|
|
863
873
|
(echo 5; echo 2) | sub
|
864
874
|
Result =>
|
865
875
|
3
|
866
|
-
###
|
876
|
+
### 50. Rip
|
867
877
|
|
868
878
|
Replace In Place
|
869
879
|
rip tool replaces a string, not a regular expression, with another
|
870
880
|
string
|
871
881
|
Example
|
872
882
|
rip cat dog file
|
873
|
-
###
|
883
|
+
### 51. G+
|
874
884
|
|
875
885
|
A compiler for C += 2. If you want to use C++ with Python syntax, you
|
876
886
|
can use this.
|
@@ -878,7 +888,7 @@ ones are omitted.)
|
|
878
888
|
Example
|
879
889
|
g+ a.cpp -o out
|
880
890
|
See also README file & emerald-browser and its source
|
881
|
-
###
|
891
|
+
### 52. T
|
882
892
|
|
883
893
|
“t” is incredibly useful.
|
884
894
|
It can be used many, many times every day by computer power users.
|
@@ -925,6 +935,7 @@ Navigation
|
|
925
935
|
Google Speak
|
926
936
|
Append Each
|
927
937
|
Selectlines
|
938
|
+
Autocorrect
|
928
939
|
Processes
|
929
940
|
Emeraldc
|
930
941
|
Nth Word
|
data/VERSION_NUMBER
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
94.0
|
data/bin/autocorrect
ADDED
@@ -0,0 +1,312 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# frozen_string_literal: false
|
4
|
+
SPECIAL = {"cmd" => "command", "unix" => "UNIX"}
|
5
|
+
|
6
|
+
print "\rAUTOCORRECT\r\n"
|
7
|
+
require 'set'
|
8
|
+
$ln = Set.new File.read("/usr/share/dict/words").split
|
9
|
+
exc = %w[coo verb cad Mar Mao ma Mai Mae wag wan T's Th wad cab mad strep pi goo fob foe yo yon fog fop war i ] # '
|
10
|
+
|
11
|
+
exc.each do |i|
|
12
|
+
raise "No #{i}" unless $ln.include?(i)
|
13
|
+
end
|
14
|
+
|
15
|
+
$ln -= exc
|
16
|
+
|
17
|
+
LINES = "\n" << $ln.sort.reverse.join("\n") << "\n"
|
18
|
+
|
19
|
+
AMOUNT = 1
|
20
|
+
PUNCT = (("!".."@")).map do |i|
|
21
|
+
i.chr
|
22
|
+
end.reject do |i|
|
23
|
+
("0".."9").include? i
|
24
|
+
end
|
25
|
+
|
26
|
+
#puts PUNCT.to_a.to_s
|
27
|
+
|
28
|
+
def get_word_(word)
|
29
|
+
return word if $ln.include? word
|
30
|
+
return word if $ln.include? word.downcase
|
31
|
+
return word.capitalize if $ln.include? word.capitalize
|
32
|
+
|
33
|
+
special = SPECIAL[word]
|
34
|
+
if special; return special; end
|
35
|
+
|
36
|
+
c = word.chars
|
37
|
+
|
38
|
+
i = c.size
|
39
|
+
|
40
|
+
def get(c, i)
|
41
|
+
return "" if c.size.zero?
|
42
|
+
while i != 0
|
43
|
+
c.permutation(i).each do |q|
|
44
|
+
# if q == first_len
|
45
|
+
# i-=1
|
46
|
+
# next
|
47
|
+
# end
|
48
|
+
q = q.join
|
49
|
+
len = LINES.scan(reg = /\n#{q}[^\n]*/i).map do |i|
|
50
|
+
i[1..-1]
|
51
|
+
end.sort do |a, b|
|
52
|
+
if a[0].downcase? == b[0].downcase?
|
53
|
+
a <=> b
|
54
|
+
else
|
55
|
+
b <=> a
|
56
|
+
end
|
57
|
+
end
|
58
|
+
# puts (len.reject do |i| i.size != 3; end.to_a.to_s)
|
59
|
+
|
60
|
+
# warn "\n#{q}[^\n]".inspect[1..-2].prepend('/').concat('/')
|
61
|
+
# warn format('permutation of %s chars of %s len of %s', i, q, len.inspect)
|
62
|
+
# return len
|
63
|
+
next if len.empty?
|
64
|
+
|
65
|
+
char_size = c.size
|
66
|
+
# puts char_size, len[0].size, len.to_s
|
67
|
+
# sleep
|
68
|
+
# puts len.inspect
|
69
|
+
|
70
|
+
len.each do |i|
|
71
|
+
cur_siz = i.size
|
72
|
+
# puts [i, c].to_s
|
73
|
+
next if cur_siz < char_size
|
74
|
+
next if cur_siz > char_size + AMOUNT
|
75
|
+
|
76
|
+
funcs = []
|
77
|
+
q.chars.each do |i|
|
78
|
+
funcs << if ("A".."Z").cover? i
|
79
|
+
:upcase
|
80
|
+
else
|
81
|
+
:downcase
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
funcs.size.times do |q|
|
86
|
+
i[q] = i[q].send funcs[q]
|
87
|
+
end
|
88
|
+
return i
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
i -= 1
|
93
|
+
end
|
94
|
+
|
95
|
+
"ERROR text is #{c.join.inspect}"
|
96
|
+
end
|
97
|
+
|
98
|
+
if i > 4
|
99
|
+
max = 0
|
100
|
+
l = $ln
|
101
|
+
maxes = {}
|
102
|
+
|
103
|
+
j = c.join
|
104
|
+
|
105
|
+
# puts 55
|
106
|
+
|
107
|
+
(c.size - c.size).times do |n|
|
108
|
+
n += 1
|
109
|
+
cont = 0
|
110
|
+
while cont < c.size
|
111
|
+
first = j[0..cont - 1]
|
112
|
+
second = j[cont..cont + n - 1].upcase.clear
|
113
|
+
third = j[n + cont..-1]
|
114
|
+
unless third
|
115
|
+
cont += 1
|
116
|
+
next
|
117
|
+
end
|
118
|
+
first = "" if cont.zero?
|
119
|
+
|
120
|
+
puts first + second + third
|
121
|
+
cont += 1
|
122
|
+
end
|
123
|
+
|
124
|
+
puts "DONE"
|
125
|
+
end
|
126
|
+
# puts 'DO'
|
127
|
+
|
128
|
+
l.each_with_index do |a, _index|
|
129
|
+
count = 0
|
130
|
+
orig_a = a.dup
|
131
|
+
a = a.dup
|
132
|
+
|
133
|
+
c.each do |char|
|
134
|
+
if a.include? char
|
135
|
+
count += 1
|
136
|
+
a.sub! char, ""
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
next unless count >= max && count != 0
|
141
|
+
|
142
|
+
# puts [count, max].to_s
|
143
|
+
maxes[orig_a] = count
|
144
|
+
max = count
|
145
|
+
end
|
146
|
+
|
147
|
+
maxes.select! do |_k, v|
|
148
|
+
v == max
|
149
|
+
end
|
150
|
+
|
151
|
+
l.each do |i_|
|
152
|
+
next if i_.size < c.size
|
153
|
+
|
154
|
+
maxes[i_] = max if i_[0..3] == c.join[0..3]
|
155
|
+
end
|
156
|
+
#puts l.size
|
157
|
+
def foo(a, b, c)
|
158
|
+
p = 0
|
159
|
+
while p < c.size && p < a.size
|
160
|
+
break if c[p] != a[p]
|
161
|
+
|
162
|
+
p += 1
|
163
|
+
end
|
164
|
+
p2 = 0
|
165
|
+
while p2 < c.size && p2 < b.size
|
166
|
+
break if c[p2] != b[p2]
|
167
|
+
|
168
|
+
p2 += 1
|
169
|
+
end
|
170
|
+
|
171
|
+
[p, p2]
|
172
|
+
end
|
173
|
+
|
174
|
+
val = maxes.keys.sort do |a, b|
|
175
|
+
p, p2 = foo(a, b, c)
|
176
|
+
|
177
|
+
if p2 - p >= 1
|
178
|
+
1
|
179
|
+
elsif p2 == p2
|
180
|
+
0
|
181
|
+
elsif p2 - p <= 1
|
182
|
+
-1
|
183
|
+
end
|
184
|
+
end[0..20].sort_by(&:size)[0..10].sort do |a, b|
|
185
|
+
p, p2 = foo(a, b, c)
|
186
|
+
|
187
|
+
if p2 - p >= 1
|
188
|
+
1
|
189
|
+
elsif p2 == p2
|
190
|
+
0
|
191
|
+
elsif p2 - p <= 1
|
192
|
+
-1
|
193
|
+
end
|
194
|
+
end[0]
|
195
|
+
|
196
|
+
raise unless val.class == String
|
197
|
+
|
198
|
+
return val
|
199
|
+
else
|
200
|
+
get(c, i)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
require "io/console"
|
205
|
+
|
206
|
+
class String
|
207
|
+
def end?
|
208
|
+
self == "\r" || self == "\n" || self == "\t"
|
209
|
+
end
|
210
|
+
|
211
|
+
def downcase?
|
212
|
+
!!match(/[a-z]/)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
class DoneException < Exception
|
217
|
+
end
|
218
|
+
|
219
|
+
def _get
|
220
|
+
a = nil
|
221
|
+
$c = ""
|
222
|
+
while a != " "
|
223
|
+
a = $stdin.getc
|
224
|
+
#print a.inspect
|
225
|
+
raise DoneException.new if a == "\x03"
|
226
|
+
if a == "\u007F"
|
227
|
+
$all_text = $all_text[0..-2]
|
228
|
+
$c = $c[0..-2]
|
229
|
+
print "\e[1D \e[1D"
|
230
|
+
next
|
231
|
+
end
|
232
|
+
$c << a
|
233
|
+
$all_text << a
|
234
|
+
putc(a) unless a.end?
|
235
|
+
return nil if a.end?
|
236
|
+
end
|
237
|
+
|
238
|
+
$c.chomp! " "
|
239
|
+
# $c.gsub!(/\e\[[A-Z]/, "")
|
240
|
+
|
241
|
+
# print c.inspect
|
242
|
+
|
243
|
+
File.open("words", "a") do |f|
|
244
|
+
f.puts c.inspect
|
245
|
+
end if false
|
246
|
+
c = $c
|
247
|
+
|
248
|
+
$c = ""
|
249
|
+
c
|
250
|
+
end
|
251
|
+
|
252
|
+
str = ""
|
253
|
+
$all_text = ""
|
254
|
+
|
255
|
+
$stdin.tty? && $stdin.raw do
|
256
|
+
last_char = "."
|
257
|
+
loop do
|
258
|
+
qi = _get
|
259
|
+
i=qi&.gsub(/\e\[[A-Z]/, "")
|
260
|
+
|
261
|
+
|
262
|
+
if i.nil?
|
263
|
+
print "\r\n"
|
264
|
+
next
|
265
|
+
end
|
266
|
+
if i.empty?
|
267
|
+
# print ' '
|
268
|
+
next
|
269
|
+
end
|
270
|
+
|
271
|
+
# raise if / |\e/.match?(i)
|
272
|
+
|
273
|
+
new_word = get_word_(i.sub(/[[:punct:]]+/, "")) + i.match(/[[:punct:]]+$/ ).to_s; if PUNCT.include?(last_char); new_word[0]=new_word[0].upcase; end
|
274
|
+
puts new_word.inspect if false
|
275
|
+
|
276
|
+
amount = i.size + 1
|
277
|
+
f = File.open("words", "a") if false
|
278
|
+
|
279
|
+
# if amount == 0
|
280
|
+
#
|
281
|
+
# text = ""/
|
282
|
+
#else
|
283
|
+
if new_word == i
|
284
|
+
else
|
285
|
+
print "\e[#{amount}D" << new_word << " "
|
286
|
+
end
|
287
|
+
|
288
|
+
$all_text = $all_text[0..-(1 + i.size + " ".size)]
|
289
|
+
$all_text << new_word << " "
|
290
|
+
last_char = new_word[-1]
|
291
|
+
# end
|
292
|
+
|
293
|
+
# puts new_word.inspect
|
294
|
+
|
295
|
+
#print "\u001b[0K"
|
296
|
+
|
297
|
+
#{new_word} "
|
298
|
+
end
|
299
|
+
rescue DoneException
|
300
|
+
end #rescue DoneException
|
301
|
+
|
302
|
+
|
303
|
+
#$all_text << $c
|
304
|
+
#system 'tput reset'
|
305
|
+
at=nil
|
306
|
+
|
307
|
+
#puts "\n\nYour story\n\n"
|
308
|
+
IO.popen("xclip -selection c", 'w') do |i|
|
309
|
+
i.print at=$all_text.strip
|
310
|
+
end
|
311
|
+
puts "YOUR STORY COPIED"
|
312
|
+
print at
|
data/bin/black
CHANGED
Binary file
|
data/bin/black_bold
CHANGED
Binary file
|