democracy 1.0.93 → 1.0.94

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +56 -50
  3. data/VERSION_NUMBER +1 -1
  4. data/bin/autocorrect +312 -0
  5. data/bin/black +0 -0
  6. data/bin/black_bold +0 -0
  7. data/bin/black_bold_underline +0 -0
  8. data/bin/black_underline +0 -0
  9. data/bin/blue +0 -0
  10. data/bin/blue_bold +0 -0
  11. data/bin/blue_bold_underline +0 -0
  12. data/bin/blue_underline +0 -0
  13. data/bin/bold +0 -0
  14. data/bin/cyan +0 -0
  15. data/bin/cyan_bold +0 -0
  16. data/bin/cyan_bold_underline +0 -0
  17. data/bin/cyan_underline +0 -0
  18. data/bin/green +0 -0
  19. data/bin/green_bold +0 -0
  20. data/bin/green_bold_underline +0 -0
  21. data/bin/green_underline +0 -0
  22. data/bin/magenta +0 -0
  23. data/bin/magenta_bold +0 -0
  24. data/bin/magenta_bold_underline +0 -0
  25. data/bin/magenta_underline +0 -0
  26. data/bin/red +0 -0
  27. data/bin/red_bold +0 -0
  28. data/bin/red_bold_underline +0 -0
  29. data/bin/red_underline +0 -0
  30. data/bin/underline +0 -0
  31. data/bin/white +0 -0
  32. data/bin/white_bold +0 -0
  33. data/bin/white_bold_underline +0 -0
  34. data/bin/white_underline +0 -0
  35. data/bin/yellow +0 -0
  36. data/bin/yellow_bold +0 -0
  37. data/bin/yellow_bold_underline +0 -0
  38. data/bin/yellow_underline +0 -0
  39. data/documentation/autocorrect +3 -0
  40. data/documentation/email +2 -2
  41. data/documentation/left_right.exe +4 -3
  42. data/gem_data/VERSION_NUMBER +1 -1
  43. data/gem_data/push_snap +30 -0
  44. data/images/Store.png +0 -0
  45. data/index.html +59 -56
  46. data/non_compiled_programs/autocorrect +312 -0
  47. data/push_snap +30 -0
  48. data/src/color_tools/black +0 -0
  49. data/src/color_tools/black.c +9 -12
  50. data/src/color_tools/black_bold +0 -0
  51. data/src/color_tools/black_bold.c +9 -12
  52. data/src/color_tools/black_bold_underline +0 -0
  53. data/src/color_tools/black_bold_underline.c +9 -12
  54. data/src/color_tools/black_underline +0 -0
  55. data/src/color_tools/black_underline.c +9 -12
  56. data/src/color_tools/blue +0 -0
  57. data/src/color_tools/blue.c +9 -12
  58. data/src/color_tools/blue_bold +0 -0
  59. data/src/color_tools/blue_bold.c +9 -12
  60. data/src/color_tools/blue_bold_underline +0 -0
  61. data/src/color_tools/blue_bold_underline.c +9 -12
  62. data/src/color_tools/blue_underline +0 -0
  63. data/src/color_tools/blue_underline.c +9 -12
  64. data/src/color_tools/bold +0 -0
  65. data/src/color_tools/bold.c +9 -12
  66. data/src/color_tools/colors.rb +9 -12
  67. data/src/color_tools/cyan +0 -0
  68. data/src/color_tools/cyan.c +9 -12
  69. data/src/color_tools/cyan_bold +0 -0
  70. data/src/color_tools/cyan_bold.c +9 -12
  71. data/src/color_tools/cyan_bold_underline +0 -0
  72. data/src/color_tools/cyan_bold_underline.c +9 -12
  73. data/src/color_tools/cyan_underline +0 -0
  74. data/src/color_tools/cyan_underline.c +9 -12
  75. data/src/color_tools/green +0 -0
  76. data/src/color_tools/green.c +9 -12
  77. data/src/color_tools/green_bold +0 -0
  78. data/src/color_tools/green_bold.c +9 -12
  79. data/src/color_tools/green_bold_underline +0 -0
  80. data/src/color_tools/green_bold_underline.c +9 -12
  81. data/src/color_tools/green_underline +0 -0
  82. data/src/color_tools/green_underline.c +9 -12
  83. data/src/color_tools/magenta +0 -0
  84. data/src/color_tools/magenta.c +9 -12
  85. data/src/color_tools/magenta_bold +0 -0
  86. data/src/color_tools/magenta_bold.c +9 -12
  87. data/src/color_tools/magenta_bold_underline +0 -0
  88. data/src/color_tools/magenta_bold_underline.c +9 -12
  89. data/src/color_tools/magenta_underline +0 -0
  90. data/src/color_tools/magenta_underline.c +9 -12
  91. data/src/color_tools/red +0 -0
  92. data/src/color_tools/red.c +9 -12
  93. data/src/color_tools/red_bold +0 -0
  94. data/src/color_tools/red_bold.c +9 -12
  95. data/src/color_tools/red_bold_underline +0 -0
  96. data/src/color_tools/red_bold_underline.c +9 -12
  97. data/src/color_tools/red_underline +0 -0
  98. data/src/color_tools/red_underline.c +9 -12
  99. data/src/color_tools/underline +0 -0
  100. data/src/color_tools/underline.c +9 -12
  101. data/src/color_tools/white +0 -0
  102. data/src/color_tools/white.c +9 -12
  103. data/src/color_tools/white_bold +0 -0
  104. data/src/color_tools/white_bold.c +9 -12
  105. data/src/color_tools/white_bold_underline +0 -0
  106. data/src/color_tools/white_bold_underline.c +9 -12
  107. data/src/color_tools/white_underline +0 -0
  108. data/src/color_tools/white_underline.c +9 -12
  109. data/src/color_tools/yellow +0 -0
  110. data/src/color_tools/yellow.c +9 -12
  111. data/src/color_tools/yellow_bold +0 -0
  112. data/src/color_tools/yellow_bold.c +9 -12
  113. data/src/color_tools/yellow_bold_underline +0 -0
  114. data/src/color_tools/yellow_bold_underline.c +9 -12
  115. data/src/color_tools/yellow_underline +0 -0
  116. data/src/color_tools/yellow_underline.c +9 -12
  117. metadata +8 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f0151657641cbcb519df1c3a2a214a2351086bb27774271697a382cf5d6ac69
4
- data.tar.gz: dfa3f7a2b73369d7973ada477abb3034bec2129a8558a895a4db6a923c497416
3
+ metadata.gz: e0dbd66e046e8541ec09f701cc7eb90cc5fbf21f91dea00e8d1436adbcce9a05
4
+ data.tar.gz: 6a3534ef302760464c312a000d3e3f40db30154de53544a639e8ca3ef95979a5
5
5
  SHA512:
6
- metadata.gz: 306be6d6b9dda5dfc5390313bb4903e1e5d5302bac3672a3cb57f7fddbb8e9fccd8394e8b7150511f0f4b5a5e461bb7bb7c87a3d8902972cf4cf1660eb4d136c
7
- data.tar.gz: 5decfbc8e8514a07dce8992fd38cb0cc83f2cec7d9ad6ad4bf908387f5bffebfd4c4bb7d3d05e5fbcc9433c1f66d7c69bf2ff2f1c2665269eddf8506d5c2ba11
6
+ metadata.gz: f85ce0f1b8ae5825da1529c35b7b57f63150f2f2195c84c6e0df96ade326b67c8d2ea08fc6cc40a1ddaa7fcd845d0ef98d46185c7a639b44adfa7bc156568d14
7
+ data.tar.gz: 172dfb8bb9850bdec099171167776a25ffb96146a106f230065c08802b3a36ff4f7d8ac972bed91cb2b208b3181f5bc4dcf0ab6ed5ec90fafe26328138194e60
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 87 programs.
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 87 documented programs. (The obvious usage
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 gets viewpoints from the person that see the good in each political
188
- side, left, right, left, right, etc.
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. Processes
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
- ### 11. Emeraldc
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
- ### 12. Nth Word
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
- ### 13. Last Nth
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
- ### 14. Speakcat
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
- ### 15. UCA CLI
384
+ ### 16. UCA CLI
380
385
 
381
386
  CLI for uca app
382
- ### 16. Big Num
387
+ ### 17. Big Num
383
388
 
384
389
  ![UCA](./images/10.png)
385
- ### 17. Squeeze
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
- ### 18. Dictate
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
- ### 19. Prepend
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
- ### 20. Chat Rb
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
- ### 21. Append
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
- ### 22. Delete
428
+ ### 23. Delete
424
429
 
425
430
  Recursively delete all files named a certain name.
426
- ### 23. Gsubip
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
- ### 24. Rhyme
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
- ### 25. Email
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
- Email [yourself]
637
+ email [yourself]
633
638
  email [addr]
634
- Email one email address
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
- ### 26. Floor
644
+ ### 27. Floor
640
645
 
641
646
  Gets the floor of numbers e.g. 21.3 -> 21
642
- ### 27. Rgsub
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
- ### 28. Lines
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
- ### 29. Clock
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
- ### 30. Emoji
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
- ### 31. Close
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,12 +724,12 @@ 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
- ### 32. Copy
727
+ ### 33. Copy
723
728
 
724
729
  copy copies the standard input
725
730
  Example
726
731
  ls | copy
727
- ### 33. Ctit
732
+ ### 34. Ctit
728
733
 
729
734
  Capitalize Title
730
735
  A work in progress.
@@ -734,7 +739,7 @@ ones are omitted.)
734
739
  You can also do
735
740
  ctit .... | copy
736
741
  To copy the title to your clipboard
737
- ### 34. Gsub
742
+ ### 35. Gsub
738
743
 
739
744
  Gsub is very powerful.
740
745
  Usage
@@ -743,7 +748,7 @@ ones are omitted.)
743
748
  cat text | gsub man dog
744
749
  cat text | gsub 'man|boy|cat|dog' food
745
750
  ls | gsub Desktop cat
746
- ### 35. News
751
+ ### 36. News
747
752
 
748
753
  Gets the news from bbc
749
754
  Usage
@@ -751,14 +756,14 @@ ones are omitted.)
751
756
  news speak
752
757
  uses google_speak to SPEAK the news, one story at a time.
753
758
  ![UCA](./images/5.png)
754
- ### 36. Args
759
+ ### 37. Args
755
760
 
756
761
  args is like a better xargs
757
762
  args works properly with spaces in the name of commands
758
763
  It takes exactly one argument
759
764
  Example
760
765
  ls | args “mv -t ../f”
761
- ### 37. Rnip
766
+ ### 38. Rnip
762
767
 
763
768
  Replace Not In Place
764
769
  This is like gsub, but for strings, not for regular expressions
@@ -766,10 +771,10 @@ ones are omitted.)
766
771
  echo .......... | rnip foo bar
767
772
  See also
768
773
  gsub
769
- ### 38. Trim
774
+ ### 39. Trim
770
775
 
771
776
  Trims spaces of each line
772
- ### 39. Quot
777
+ ### 40. Quot
773
778
 
774
779
  Turns quotes in text into good text and makes text presentable.
775
780
  Example
@@ -780,7 +785,7 @@ ones are omitted.)
780
785
  Example 3
781
786
  (Quote the file and output it)
782
787
  quot text_file
783
- ### 40. Open
788
+ ### 41. Open
784
789
 
785
790
  “open” is a very efficient program that searches a query from google,
786
791
  and then opens it in Emerald Browser.
@@ -801,25 +806,25 @@ ones are omitted.)
801
806
  See also
802
807
  emerald-browser
803
808
  close
804
- ### 41. Swap
809
+ ### 42. Swap
805
810
 
806
811
  Swaps two files
807
812
  Example
808
813
  swap text1 text2
809
- ### 42. Exp
814
+ ### 43. Exp
810
815
 
811
816
  exp is an exponentiation tool
812
817
  (echo 5; echo 3) | exp
813
818
  => 125
814
819
  (echo 2; echo 10) | exp
815
820
  => 1024
816
- ### 43. Div
821
+ ### 44. Div
817
822
 
818
823
  Divides numbers
819
824
  Example
820
825
  (echo 5000; echo 100) | div
821
826
  => 50
822
- ### 44. Mul
827
+ ### 45. Mul
823
828
 
824
829
  Multiply numbers
825
830
  echo 1 > file
@@ -829,10 +834,10 @@ ones are omitted.)
829
834
  echo 5 >> file
830
835
  cat file | mul
831
836
  => 120
832
- ### 45. Nth
837
+ ### 46. Nth
833
838
 
834
839
  Nth gets the nth line from the input
835
- ### 46. Abs
840
+ ### 47. Abs
836
841
 
837
842
  Abs gets the absolute value of an integer
838
843
  The absolute value of a number is the value of that number without its
@@ -845,13 +850,13 @@ ones are omitted.)
845
850
  => 12
846
851
  The last one would do -2 - -10, the result would be -12, and then the
847
852
  absolute value would be computed, and so the result would be 12.
848
- ### 47. Add
853
+ ### 48. Add
849
854
 
850
855
  See the sub example
851
856
  add adds integers from the standard input
852
857
  (echo 1; echo 2; echo 3) | add
853
858
  The result would be 6
854
- ### 48. Sub
859
+ ### 49. Sub
855
860
 
856
861
  Sub is a simple command line program that subtracts integers.
857
862
  For some reason, no simple program did this.
@@ -868,14 +873,14 @@ ones are omitted.)
868
873
  (echo 5; echo 2) | sub
869
874
  Result =>
870
875
  3
871
- ### 49. Rip
876
+ ### 50. Rip
872
877
 
873
878
  Replace In Place
874
879
  rip tool replaces a string, not a regular expression, with another
875
880
  string
876
881
  Example
877
882
  rip cat dog file
878
- ### 50. G+
883
+ ### 51. G+
879
884
 
880
885
  A compiler for C += 2. If you want to use C++ with Python syntax, you
881
886
  can use this.
@@ -883,7 +888,7 @@ ones are omitted.)
883
888
  Example
884
889
  g+ a.cpp -o out
885
890
  See also README file & emerald-browser and its source
886
- ### 51. T
891
+ ### 52. T
887
892
 
888
893
  “t” is incredibly useful.
889
894
  It can be used many, many times every day by computer power users.
@@ -930,6 +935,7 @@ Navigation
930
935
  Google Speak
931
936
  Append Each
932
937
  Selectlines
938
+ Autocorrect
933
939
  Processes
934
940
  Emeraldc
935
941
  Nth Word
data/VERSION_NUMBER CHANGED
@@ -1 +1 @@
1
- 93.0
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
Binary file
data/bin/black_underline CHANGED
Binary file
data/bin/blue CHANGED
Binary file
data/bin/blue_bold CHANGED
Binary file
Binary file