Feeds:
Posts
Comments

Archive for August, 2011

This single line of code grabs any IP address from a list of files and sorts them and removes all duplicates then puts them in a file with and extension of .ip

 

for file in *; do cat $file | grep -o ‘[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}’ | sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 | uniq -u >> $file.ip; done

Advertisements

Read Full Post »

I was screwing around this morning and I needed some random words to test something with. The words needed to bereal words, not just random sequences of characters (btw, you can generate a random sequence of 8 characters from the shell using jot -r -c 8 a z | rs -g 0 8). In this case, I decided to simply grab a random word from /usr/share/dict/words.

Hmm, but how do I grab a random word from a file? My solution was to generate a random number in the range [1..n]where n is the number of lines in the file, cat -n the file so that line numbers are printed, grep for the line matching the random number, then print out the second column. It looks like this:

$ n=$(cat /usr/share/dict/words | wc -l)
$ cat -n /usr/share/dict/words | grep -w $(jot -r 1 1 $n) | cut -f2
idic
$ cat -n /usr/share/dict/words | grep -w $(jot -r 1 1 $n) | cut -f2
goldentop
$ cat -n /usr/share/dict/words | grep -w $(jot -r 1 1 $n) | cut -f2
Hamitism
$ cat -n /usr/share/dict/words | grep -w $(jot -r 1 1 $n) | cut -f2
accumulativeness
$ cat -n /usr/share/dict/words | grep -w $(jot -r 1 1 $n) | cut -f2
ratihabition

Read Full Post »

The other day I needed to find the location of an application using its bundle ID. Easy, just use LaunchServices. But I needed to do this from a script. Here are a couple perl one-liners to do it.

$ perl -MMac::Processes -e 'printf "%s\n", LSFindApplicationForInfo(undef, "com.apple.TextEdit")'/Applications/TextEdit.app$ mv /Applications/TextEdit.app ~/Desktop/
$ perl -MMac::Processes -e 'printf "%s\n", LSFindApplicationForInfo(undef, "com.apple.TextEdit")'/Users/jgm/Desktop/TextEdit.app$ mv ~/Desktop/TextEdit.app /Applications/
$ perl -MMac::Processes -e 'printf "%s\n", LSFindApplicationForInfo(undef, undef, "TextEdit.app")'/Applications/TextEdit.app

(Yes, I know mdfind could do something similar. But it wouldn’t necessarily return the one that LaunchServices thinks is the “preferred” one if there were multiple applications with the same bundle ID.)

Read Full Post »

The hearing regarding the preliminary injunction in the German Apple v. Samsung case is currently under way. Biggest revelation so far? Samsung is accusing Apple of 27 (!) cases of altering pictures, all done to make Samsung’s products appear more similar to Apple’s than they really are. Like last time, Andreas Udo de Haes, editor at WebWereld.nl, present in the court room, is covering this. Update: It’s on. Update II: Apple claims official picture of Galaxy Tab is rigged. Update III: Lolwut Apple? Update IV: Neelie Kroes is on the edge of her seat. Update V: The judge has upheld the German preliminary injunction. Final ruling on September 9.

Read Full Post »

“Opa, a new opensource programming language aiming to make web development transparent has been publicly launched. Opa automatically generates client-side Javascript and handles communication and session control. The ultimate goal of this project is to allow writing distributed web applications using a single programming language to code application logics, database queries and user interfaces. Among existing applications already developed in Opa, some are worth a look. Best place to start is the project homepage which contains extensive

Read Full Post »

“After years of focusing on further improving KDE4 two weeks ago the developers of the free desktop announced the next big step for their project: KDE Frameworks 5.0. But as long-time developer – and Plasma team leader – Aaron Seigo points out in an interview with derStandard.at/web, the source-incompatible changes shall be held to a minimum. Also calls Frameworks 5.0 only the “first step”, new Applications and Workspace releases are to follow later, Seigo goes on to talk about the chances in the mobile market with Plasma Active and further areas of collaboration with the other big free desktop: GNOME.”

Read Full Post »

I thought OSNews would be a good forum to talk about a matter that has been weighing on my mind lately primarily because the site has been so focused on Apple’s patents and litigation as of late. The news that HP, the largest PC manufacturer in the world is spinning off or getting out of this business is what really prompted me to write this article. Read more on this exclusive OSNews article…

Read Full Post »

Older Posts »