[Quick Links] |
Search Site

Site Details

rendered in 0.0446 secs

Captain's Log | Friday 31st of July 2015

Force PowerMizer profile on linux
update: when working through this process with nvidia driver 346 it didn't work. instead I ran "nvidia-xconfig --cool-bits=4" as per this article, restarted mdm and then had a GPU fan speed % slider that I could use instead
sudo vim /etc/X11/xorg.conf
  if this file isn't present, run "sudo nvidia-xconfig" which will generate the initial configuration file.

find this section:
Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
----------

and change it to look like this:
Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    Option  "Coolbits" "1"
     Option  "RegistryDwords" "PowerMizerEnable=0x1; PerfLevelSrc=0x2222; PowerMizerLevel=0x2; PowerMizerDefault=0x2; PowerMizerDefaultAC=0x2"
EndSection
-----------

Play around with PowerMizerLevel=0x2 number, 0x3 was lowest performance for me. Changed to 0x2 and it locked it at mid performance. Once saved and closed, run:
sudo service mdm stop
log in at console and then:
sudo service mdm start

check the nvidia GUI and it should have locked to new value.

I was having an issue with it set to auto which was causing my fan to spin up nice and loud when playing a 2D RTS game. Decided to set it to lowest but the game struggled. Then turned the fan down but the GPU was getting very hot. So locked it to medium and the PC is quite but the game runs a treat.

Thanks
R
keywords: NVidia PowerMizer On Linux
book review: 301 smart answers to tough interview questions - Vicky Oliver
To be fair I picked this up by mistake. I thought it was a book related to coding interviews because I wanted to see the kind of questions asked so I could gauged where I lay in relation and maybe run through a few exercises. It wasn't, obviously. So I didn't enjoy as it just seemed like someone had written down a load of potential questions and they wrong a book on how they would answer them. Didn't really bring anything to the table as your whole experience and background are completely unrelated. To reiterate, probably more a fault of my own that the authors.

Captain's Log | Wednesday 29th of July 2015

What folders should I exclude from my anti virus software to help Sage performance? (Windows)
As well as the UNC path for the COMPANY folder, please also exclude:

File Types
.SLC; .SLI; .PRC; .PRI; .NMC; .NMI; .BKC; .BKI; .SKC; .SKI; .IVC; .IVI; .SPC; .SPI; .PCC; .PPI; .PCI; .REC; .REI; .SAC; SAI; .IPC; .IPI; .PDC; .PDI; .SLM; .PLM; .NLM; .ILM; .BLM; .CLM; .DLM; .report; .layout; .letter; .label ; .SRT; .SLY; .SLT; .SLB; .RPT; .DTA; .DTH; .COA; .S50

Folder Paths
C:\Program Files (x86)\Common Files\Sage SBD; C:\Program Files (x86)\Common Files\Sage Line50; C:\Program Files (x86)\Common Files\Sage Report Designer 2007; C:\Program Files (x86)\Common Files\Sage Shared; C:\Program Files (x86)\Sage EBanking; C:\Program Files\Common Files\Sage SBD; C:\Program Files\Common Files\Sage Line50; C:\Program Files\Common Files\Sage Report Designer 2007; C:\Program Files\Common Files\Sage Shared; C:\Program Files\Sage EBanking

Please note that these have been saved in a format that also you to copy and paste them directly into Windows Defender (Windows 8), Microsoft Security Essentials and Miscrosoft Forefront Security.

What's the easiest way to manage addons in vim?
I use Vundle as I like mature technology with great support documentation online. Once you've added in some new modules to your .vimrc, run the below from the terminal to have them automatically installed.
vim +BundleInstall +qall

Do you have a simple ping script for linux?
Very basic script that just paints your terminal green if the host is online and red if it's not.
vim pingtest.sh
paste:

#!/bin/bash                                                                                                                                                                                                                                  

target=$1

while :; do
        count=$( ping -c 1 $target | grep icmp* | wc -l )
       #count=$( ping -c 1 -w 1 $target | grep icmp* | wc -l ) //if you have the -w 1 and it drops, there is a chance it will never come back up, just report as red forever. so yes the switch to red and flagging drops is slower without it, but it stops the script crashing/reporting wrong

        if [ $count -eq 0 ]
        then
                echo "$(tput setab 1) "
                sleep 0.5
        else
                echo "$(tput setab 2) "
                sleep 0.5
        fi
done

Usage ./pingtest.sh 8.8.4.4
That will ping the google DNS server 8.8.4.4 and let you know when it, or more likely you, have lost connection.

Captain's Log | Thursday 23rd of July 2015

TSM Commands
  • update volume * access=readwrite wherestgpool=centos
  • checkin libv LB6.1.0.11 search=yes status=scratch checklab=barcode
  • select date_time,message from actlog where message like '%move data%' AND date_time>=current_timestamp-12 hours
  • disable replication
  • q auditocc
  • select NODE_NAME, BACKUP_MB, BACKUP_COPY_MB, ARCHIVE_MB, ARCHIVE_COPY_MB, TOTAL_MB from AUDITOCC order by TOTAL_MB desc | src
  • SELECT node_name, stgpool_name, type, CAST(FLOAT(SUM(logical_mb))/1024 AS DEC(8,2)) as GB, SUM(num_files) as Number_of_files FROM occupancy GROUP BY node_name, stgpool_name, type ORDER BY node_name, stgpool_name, type | src
  • SELECT node_name, filespace_name, stgpool_name, SUM(logical_mb) AS "Total MB" FROM occupancy WHERE node_name='FS5' AND stgpool_name='DISKPOOL' GROUP BY node_name, filespace_name, stgpool_name ORDER BY filespace_name


Captain's Log | Wednesday 15th of July 2015

codeigniter is giving me WSOD whitescreen white screen of death
for me it was related to sql, so maybe rename config/database.php and see if it is the same for you, the fix in my instance:
sudo yum remove php
sudo yum remove php-*
sudo yum install php php-mysql
sudo service httpd restart
How can I start httpd and mysqld at boot on fedora?sudo chkconfig httpd on
sudo chkconfig mysqld on

Bear in mind, after boot you may find virtual hosts routing incorrectly due to a race condition. See the bottom of this post for a quick fix.
book review: Code Complete: A Practical Handbook of Software Construction
Absolute must read for programmers. It's great because it's simple and the ideas are communicated clearly. Not filled with junk code but why this and that way are the best approach. It's a big book, but well worth the time invested in my opinion.
keep codeingiter in sync with your code using githubgit pull https://github.com/bcit-ci/CodeIgniter 2.2.2
the bit on the end is the branch you want to merge, in this case 2.2.2 of the linked repo. now you've probably got a lot of conflicts.
all the files that it has conflicts with have merge headers in them so you need to do one of three things with each and every file. option 2/3 allow you to add multiple files and folders in one step if you don't need to review changes.

to open both files in vim and compare what's changed:
git mergetool
git add

make sure you delete all the merge header lines from the code when finishing your review of each file
if you just want to explicitly keep a local version of the file:
git checkout --ours application/config/autoload.php
git add application/config/autoload.php
  also supports adding multiple files via:
git checkout --ours application/
git add application

here we've checked out our local version and replaced the version that has all the merge headers in it and then added those files ready to be commited.
if you just want to explicitly replace your local file(s) with those pulled:
git checkout --theirs system/
git add system/

when git status reports no more conflicts, just run through your usual commit process
git commit -av
git push


Captain's Log | Wednesday 15th of July 2015

book review: The Pragmatic Programmer
It was like a pocket edition of "Code Complete". A lot less pages, not as much reasoning behind the whys but still very good. If you had to choose one or the other I'd go for "Code Complete", as this book reiterates a lot that's already said there however you get the reasoning behind the choices a lot more with "Code Complete".
how do you lock mint MATE on boot (I have auto login enabled you see) | src
You may find a command online to lock it up from bash and then drop it into startup applications and wonder why it's not working; I did.
cat /home/rick111/111/scripts/lock_mate.sh
#!/bin/bash
mate-screensaver-command -a

chmod +x /home/rick111/111/scripts/lock_mate.sh

Now add this to "startup applications":
bash -c "sleep 5; /home/rick111/111/scripts/lock_mate.sh"What would a PHP test look like using phpunit?
class TestAll extends PHPUnit_Framework_TestCase {

    public function testRemoveWhiteAndEmpty() {
        if(!defined('BASEPATH')) {
            define('BASEPATH', 1);
        }
        require_once('arrayahoylib.php');

        $array_with_whiteshite = array(
            1 => "one",
            2 => " two with space at start",
            3 => ""
        );
        $classUnderTest = new ArrayAhoyLib();
        $array_with_whiteshite = $classUnderTest->removeWhiteAndEmpty($array_with_whiteshite);

        $this->assertArrayNotHasKey(3, $array_with_whiteshite);
        $this->assertStringStartsNotWith(' ', $array_with_whiteshite[2]);

    }  
}



Captain's Log | Wednesday 8th of July 2015

How can I use my ssh cert to authenticate rather than a password?
make sure you use quotes if you want to use a port other than 22. in this example we use port 111.
ssh-copy-id "user@123.45.56.78 -p111"
if you get an error that no identities exist, create one with
ssh-keygen -t rsa
Is there anything like treesize for linux? - srcsudo vim ~/bin/treesize
#!/bin/bash
du -k --max-depth=1 2> >(grep -v '^du: cannot \(access\|read\)' >&2) | sort -nr | awk '
     BEGIN {
        split("KB,MB,GB,TB", Units, ",");
     }
     {
        u = 1;
        while ($1 >= 1024) {
           $1 = $1 / 1024;
           u += 1
        }
        $1 = sprintf("%.1f %s", $1, Units[u]);
        print $0;
     }
    '
:wq
sudo chmod +x ~/bin/treesize
  then just type treesize in whatever dir you'd like to inspect

I need to restart apache after rebooting my laptop to get it to register the virtual hosts correctly, got any pokes?sudo vim /etc/rc.local
sleep 10
service apache2 restart
exit 0 make sure this is the final line the file
:wq

This is due to a race condition where your web server initializes quicker that your network interface.

Captain's Log | Sunday 5th of July 2015

local apache2 server not working with sslopenssl s_client -connect localhost:443
connect: Connection refused
connect:errno=111

sudo a2enmod ssl
Considering dependency setenvif for ssl:
Module setenvif already enabled
Considering dependency mime for ssl:
Module mime already enabled
Considering dependency socache_shmcb for ssl:
Enabling module socache_shmcb.
Enabling module ssl.
See /usr/share/doc/apache2/README.Debian.gz on how to configure SSL and create self-signed certificates.
To activate the new configuration, you need to run:
  service apache2 restart

sudo service apache2 restart
openssl s_client -connect localhost:443
CONNECTED(00000003)
depth=0 CN = mint
verify error:num=18:self signed certificate
verify return:1
depth=0 CN = mint
verify return:1
starting enable remaining boot-time encrypted block devices
bad fstab entry, pound some keys until it boots; I waited a while and then just went postal on the middle of my keyboard and it booted.
sudo vim /etc/fstab
#comment out potential bad entry
sudo reboot
How can I compare two files in vim? (diff) | I use vim plugin diffchar.vim to make the output clearervim -d file1.php file2.php
F7  to then tab between compare modes
How can I add a ppa repository?sudo add-apt-repository ppa:
sudo apt-get update

to remove a ppa
# find the correct ppa file to delete by listing all ppa files:
ls /etc/apt/sources.list.d

# delete the ppa that you would like to remove:
sudo rm /etc/apt/sources.list.d/some-ppa-to-remove.list
sudo apt-get update
optimise fedora 21 for laptop battery savingsu
crontab -e
* * * * *       for x in /sys/devices/system/cpu/cpu[0-3]/cpufreq/;do    echo 500000 > $x/scaling_max_freq; done #locks cpu to 800Mhz which usually resets if you come out of suspend or anything
:wq
tuned-adm profile powersave



Captain's Log | Sunday 5th of July 2015

How do I set the brightness on my laptop at boot programmatically? | intel mint 17
I had an issue where whenever I set the brightness on my laptop and rebooted it would reset back to maximum. Now even with the below command I was having an issue whereas it would reset back to max brightness after a minute or two. This is because in the power settings under battery it was set to "dim" the display. This auto dimming compared to the max brightness setting when on power was resetting the changes we make below at boot, so make sure to turn off "dim display" in power management when running on battery.

And then you can edit the file below which is ran automatically at boot by root:
sudo vim /etc/rc.local
echo 337 > /sys/class/backlight/intel_backlight/brightness
  make sure the above is before the final "exit 0"
:wq
Got any of those horizontal scrolls using a touchpad?
In mint 17.1 it was only showing the touchpad as a mouse and only vertical scrolling was working. To get vertical scrolling working it took the updating of the kernel. This was after trying many apps and ideas in the 17.1 (3.13) kernal. As soon as I updated to 13.18 and made a couple of changes under the new touchpad options on the control centre, everything was working as expected.

I'm not going to demo code for update as the wget location is changing all the time and it's done that way rather than via apt-get install. It involved:
  • download 3 files headers/headers generic/image generic
  • install all 3
  • update grub
  • reboot
example 1example 2