Hey /g/ents.
So I know we have our daily programming thread that gives us a place to show off our current projects, but I'd like to create a Scripting / Programming general thread that is more catered towards the providing ideas and solutions to scripts.
These can be things we've worked on in the past, ideas that we've had, or simple tasks that could be done with scripting or programming. All languages welcome, but as i'm learning bash and shell scripting atm, i'll be catering mine towards that.
Here's a start that I found a bit intriguing from one of the Daily Programming threads.Your task is to write a program (Linux application in C) that takes a text
file and prints out the number of occurrences of each word.
E.g:
test.txt <<<
Hello, this is a "Hello world"
text file, it is!
>>>
$ occurrence < test.txt
Hello 2
is 2
a 1
file 1
it 1
text 1
this 1
world 1
>>51916459
>le Hello World meme
>>51916556
>le meme
>meme
>>>/out/
No one wishes to contribute?
>>51919411
It is a cool idea, but there is another thread with many cool shell scripts
>>51916459
>I'd like to create a Scripting / Programming general thread that is more catered towards the providing ideas and solutions to scripts.
That is *exactly* what the daily programming thread exists for.
>Here's a start that I found a bit intriguing from one of the Daily Programming threads.
FFS. You just made the case that two separate threads are needed. Then you proceed to start your "programming/scripting ideas" thread with something from the /dpt/.
/g/ doesn't need a /dpt-2/. You could have at least made an effort to differentiate your thread from the /dpt/.
>>51916459
sudo ping tumblr.com
not C code but i read your post too quickly$ cat occurrences.py
#!/usr/bin/python
import sys, re
counts = {}
for line in sys.stdin:
line = re.sub("[^a-z ]*", "", line.lower())
words = line.split()
for word in words:
if word in counts:
counts[word] += 1
else:
counts[word] = 1
for key in counts:
print key, counts[key]
$ python occurrences.py < test.txt
a 1
this 1
text 1
is 2
it 1
file 1
world 1
hello 2
JavaScript + Underscore JS :^)var input = 'Hello, this is a "Hello world" text file, it is!';
_(input.replace(/[^a-z0-9 ]/gi, '').split(' '))
.chain()
.countBy(function(word) {
return word.toLowerCase();
})
.each(function(freq, word) {
console.log(word + ' ' + freq);
});
https://google.com
$ tr -s ' ' '\n' < test.txt | sed -e 's/\W//' | sort | uniq -c
1 a
1 file
2 Hello
2 is
1 it
1 text
1 this
1 world
>>51922120
sed looks so fucking great, I'll start learning it over this weekend as I've been meaning to in forever now
I took the liberty of running mine on Tolstoy's War and Peace. Enjoy.
http://pastebin.com/sZk5BhCG
>>51923041
Useless, sort that shit
>>51922120
which language is that written in
>>51923395
Here ya go princess. Good luck with your internship.
http://pastebin.com/9UDEprhQ
>>51923523
it's a shell script
>>51923670
Still useless, word cloud that shit.
wc -w -