[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Programming/Scripting Ideas
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 20
Thread images: 3
File: bash.jpg (21 KB, 246x320) Image search: [Google]
bash.jpg
21 KB, 246x320
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
>>
File: 1441051136545s.jpg (4 KB, 125x111) Image search: [Google]
1441051136545s.jpg
4 KB, 125x111
>>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
>>
>>>/g/dpt/
>>
>>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
>>
File: leo-tolstoy.jpg (33 KB, 800x600) Image search: [Google]
leo-tolstoy.jpg
33 KB, 800x600
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 -
Thread replies: 20
Thread images: 3

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.