Monthly Archives: February 2014

curl and POST, GET, PUT, DELETE

Make requests with data:
Since we learn how to make POST, GET, PUT, DELETE requests, we can now make same requests with data. In order to send data with those requests, we should use –data parameter. Here are some examples:

::::/bin/bash
# send login data with POST request
curl –request POST ‘http://www.linuxhow.tk/login/’ \
–data ‘username=myusername&password=mypassword’

# send search data to with get request
curl –request GET ‘http://www.linuxhow.tk/results?search_query=my_keyword’

# send PUT request with data
curl –request PUT ‘http://www.linuxhow.tk/rest-api/user/12345/’\
–data ’[email protected]

# same thing but this one get data from a file named data.txt
curl –request PUT ‘http://www.linuxhow.tk/user/12345/’\
–data @data.txt

Fedora with Fedy

Fedy, formerly known as Fedora utils, is an open source collection of useful utilities such as mp3 support, Adobe Flash, Oracle Java and much more that Fedora doesn’t ship by default. Fedy lets you to install all the utilities with just a single click and you can customize/tweak your Fedora Linux as per your liking. Not only utilities, we can easily add repositories, so don’t bother about downloading and adding .repo files manually.

wget http://satya164.github.io/fedy/fedy-installer

chmod +x fedy-installer
sudo ./fedy-installer

fix UTF-8 files with BOM

If you want just to show BOM files, use this one:

grep -rl $’\xEF\xBB\xBF’ .

to remove BOM:
find . -type f -exec sed ‘1s/^\xEF\xBB\xBF//’ -i.bak {} \; -exec rm {}.bak \;
or
find -type f -print0 | xargs -0 grep -l `printf ‘^\xef\xbb\xbf’` | sed ‘s/^/found BOM in: /’