Bash can handle getting integer from float very easily:
[root@i ~]# cat ./f_to_i.sh
#!/bin/bash
f=20.3
i=${f%.*}
echo "float: " $f
echo "integer: " $i
[root@i ~]#
[root@i ~]# bash ./f_to_i.sh float: 20.3 integer: 20 [root@i ~]#
Bash can handle getting integer from float very easily:
[root@i ~]# cat ./f_to_i.sh
#!/bin/bash
f=20.3
i=${f%.*}
echo "float: " $f
echo "integer: " $i
[root@i ~]#
[root@i ~]# bash ./f_to_i.sh float: 20.3 integer: 20 [root@i ~]#
This is how you can use traceroute for a specific port:
traceroute -T -p 3306 10.20.41.1
or the same:
traceroute --tcp -p 3306 10.20.41.1
Here’s a quick way to log raw HTTP requests in PHP:
$env = print_r($_SERVER, TRUE);
$req = print_r($_REQUEST, TRUE);
$fp = fopen('/tmp/request.log', 'a');
fwrite($fp, $env);
fwrite($fp, $req);
where $env is environment parameters values and $req is request content. Handy.
trac-admin <trac_env> ticket remove <ticket_id>
An example:
[trac@zorro trac]$ trac-admin ./ ticket remove 201 Ticket #201 and all associated data removed. [trac@zorro trac]$
If you get this error
Can't save in background: fork: Cannot allocate memory
it means that your current database is bigger than memory you have. To fix the issue enable vm.overcommit_memory:
sysctl vm.overcommit_memory=1
To have if after reboot add this line to /etc/sysctl.conf:
vm.overcommit_memory=1
‘show procecclist‘ can be quite long in MySQL. Here’s simple way to filer out sleeping processes:
mysql> pager grep -v Sleep mysql> show processlist;
Sometimes you might need to check how Apache sees your virtual hosts. Especially if you have hundreds of them. Here’s how you can go:
httpd -D DUMP_VHOSTS
Apache will output all your virtual hosts.
Getting such error while using selenium with Python means that you most probably updated Firefox and didn’t selenium.
[dande@j ~]$ python zs.py
Traceback (most recent call last):
File "zs.py", line 6, in <module>
browser = webdriver.Firefox()
File "/usr/lib/python2.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 58, in __init__
self.binary, timeout),
File "/usr/lib/python2.6/site-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
self.binary.launch_browser(self.profile)
File "/usr/lib/python2.6/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 48, in launch_browser
self._wait_until_connectable()
File "/usr/lib/python2.6/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 95, in _wait_until_connectable
self.profile.path, self._get_firefox_output()))
selenium.common.exceptions.WebDriverException: Message: 'Can\'t load the profile. Profile Dir: /tmp/tmpOGd4Im Firefox output: Xlib: extension "RANDR" missing on displa
y ":1".\n*** LOG addons.xpi: startup\n*** LOG addons.xpi: checkForChanges\n*** LOG addons.xpi: No changes found\n'
[dande@j ~]$
Fixing:
[dante@j ~]# pip-python install -U selenium
Downloading/unpacking selenium
Downloading selenium-2.32.0.tar.gz (2.5Mb): 2.5Mb downloaded
Running setup.py egg_info for package selenium
Installing collected packages: selenium
Found existing installation: selenium 2.30.0
Uninstalling selenium:
Successfully uninstalled selenium
Running setup.py install for selenium
Successfully installed selenium
Cleaning up...
[dante@j ~]#
All set.
If you need to pass some variable from bash to sed use double quotes:
sed -i "s/$var/replace/g" "$file"
Easy.
1. Download Smart YouTube PRO to your plugins folder.
2. Unpack and activate the plugin.
3. Tune settings if needed.
4. Now just insert a link to a post and change the url prefix to:
httpv
That will do the trick. Now you are ready to share.