Search This Blog

Tuesday, September 2, 2014

Fix Retina MacBook poor battery life

The first of these, is to clear the PRAM and NVRAM settings. This seems to be a favorite of Apple support staff, as I recall being told to try this on a couple of pre-MacBook era machines for various things. To do it is really simple:
  • First, power off your MacBook Pro
  • Then, when you power up, hold down the cmd+option+P+R keys all at the same time
  • When you see it cycle round and you hear the startup sound again, let go and let your MacBook Pro boot up as normal.

This on its own may resolve the problem. The other method that runs in conjunction with this involves a little terminal:
  • Open up Terminal on your MacBook Pro
  • Type in cd ~/Library/Preferences/ then press enter
  • Then type rm com.apple.desktop.plist and press enter
  • Finally, type killall Dock and hit enter again

This command will delete the settings file listed in the second line, and restart your dock so you're not running with any faulty preferences anymore. It also seems to set your wallpaper back to the stock, Mountain Lion wallpaper, so that may be a good sign that you did everything right.

Source

Wednesday, August 27, 2014

Show hidden files in OSX Finder utility

You can use a Terminal command to reveal the hidden files in OS X by making a change to the default behavior of Finder.

defaults write com.apple.Finder AppleShowAllFiles TRUE
killall Finder

reference:

Monday, June 23, 2014

Network resources exhausted - TCP/IP ports are in a TIME_WAIT status

Lately on old Windows 2008 R2 servers I had some network problems.
So I connected to the server via VNC or Remote Desktop and after hours spent without a clue, I tried a "netstat -n" command from DOS prompt and I got an infinite list of TCP/IP ports are in a TIME_WAIT status...

So, what is happening? It seems that there is a strange bug that sometimes Windows does not reuse socket ports in TIME_WAIT status, so when it reaches the maximum port number (65000 or so), the server cannot anymore create new sockets (beware that listening sockets are Ok, so You can connect to the server and all inbound connections actually work, only outbound are rejected).

At this point the only solution is the reboot of the server.

Microsoft has a bug fix but it needs reboot as well:
http://support.microsoft.com/kb/2553549/en-us

TCP/IP ports that are in a TIME_WAIT status 

TCP/IP ports that are in a TIME_WAIT status 

Friday, October 18, 2013

Linux: cannot set LC_CTYPE locale or related problems

To make it permanent just edit the file “/etc/environment” and add the line:
LC_ALL=C
or in
/etc/profile
add
export LC_ALL=C

Wednesday, October 9, 2013

Simple access SVN Subversion repository behind proxy

Uncommenting and set the following lines: 

[global]
http-proxy-host=my.proxy
http-proxy-port=80
http-proxy-username=[username]
http-proxy-password=[password]

in file
~/.subversion/servers

Wednesday, October 2, 2013

Simple essential TAR usage

create archive:
tar -cvf test.tar /home/test/
extract archive:
tar -xvf test.tar
list archive content:
tar -tvf test.tar

Thursday, August 29, 2013

QNAP: Automatically run a script at startup

Running Your Own Application at Startup
QPKG-based method (new)
This method consists of declaring a dummy QPKG which launches your script at startup.

Log into your QNAP device using SSH or Telnet, for instance by using Putty

Edit QPKG config file:
# vi /etc/config/qpkg.conf

Declare a new dummy package by adding something like that in this file:

[autorun]
Name = autorun
Version = 0.1
Author = neomilium
Date = 2013-05-06
Shell = /share/MD0_DATA/.qpkg/autorun/autorun.sh
Install_Path = /share/MD0_DATA/.qpkg/autorun
Enable = TRUE

As you can see, Shell is the interesting variable: at boot-time, QNAP OS will launch each QPKG's Shell variable content.

Note: if your NAS doesn't have /share/MD0_DATA (i.e. is a one-drive NAS), put the right directory into the Shell and Install_Path variables and adapt the following commands to your needs.

Create the dummy package directory:
# mkdir /share/MD0_DATA/.qpkg/autorun

Create the autorun script with the contents of your choice:
# vi /share/MD0_DATA/.qpkg/autorun/autorun.sh
Note: don't forget "#!/bin/sh" at the beginning of script.

Set the execute bit:
# chmod +x /share/MD0_DATA/.qpkg/autorun/autorun.sh
Reboot and enjoy!

from

Wednesday, August 21, 2013

Check blackout length (for BeagleBone Black)

timer.sh:
root@beaglebone:~/Desktop# cat timer.sh

#!/bin/bash

KEEPALIVE=/home/root/Desktop/log.txt
#TARGET=/home/root/Desktop/log_$(date -r $SOURCE +"%Y-%m-%d_%H-%M-%S").txt
TARGET=/home/root/Desktop/log_$(date -d "today" +"%Y-%m-%d_%H-%M-%S").txt
BOOT=/home/root/Desktop/boot.txt


# se esiste bootfile salva log.txt con ora corrente
if [ -e $BOOT ]
then
echo "$BOOT exist"
mv $KEEPALIVE $TARGET
rm $BOOT
fi

echo $(date -d "today" +"%Y-%m-%d %H:%M:%S") > $KEEPALIVE

timerboot.sh:
root@beaglebone:~/Desktop# cat timerboot.sh

#!/bin/bash

TARGET=/home/root/Desktop/boot.txt

echo "boot" > $TARGET

crontab:
root@beaglebone:~/Desktop# crontab -l

30 * * * *    /usr/bin/ntpdate-sync silent
*/5 * * * * /home/root/Desktop/timer.sh
@reboot /home/root/Desktop/timerboot.sh

Linux scripting to save blackouts hours

In my house sometimes I got a blackout, don't know why yet, but it happens.
Now, I want to know for how long blackout lasted.
I made up some simple bash scripting for this; possible next actions, link this info to a nagios or ninjablock application to receive notifications:

timer.sh:
root@beaglebone:~/Desktop# cat timer.sh

#!/bin/bash
TARGET=/home/root/Desktop/log.txt
echo $(date -d "today" +"%Y-%m-%d %H:%M:%S") > $TARGET

timerdown.sh: 
root@beaglebone:~/Desktop# cat timerdown.sh

#!/bin/bash
SOURCE=/home/root/Desktop/log.txt
TARGET=/home/root/Desktop/log_$(date -r $SOURCE +"%Y-%m-%d_%H-%M-%S").txt
touch $TARGET
mv $SOURCE $TARGET

crontab:
root@beaglebone:~/Desktop# crontab -l

30 * * * * /usr/bin/ntpdate-sync silent
*/5 * * * * /home/root/Desktop/timer.sh
@reboot /home/root/Desktop/timerdown.sh

BeagleBone Black: setting the correct timezone

Set your localtime file according to your time zone

Next you need to set your /etc/localtime file according to your timezone.
If you go into the directory /usr/share/zoneinfo you will see a lot of different timezone files, e.g. 

root@beaglebone:/usr/share/zoneinfo# ls
Africa CET EST5EDT GMT Greenwich MST7MDT PST8PDT UCT WET America CST6CDT Etc GMT+0 HST NZ Pacific UTC Zulu Asia EET Europe GMT-0 MET NZ-CHAT ROC Universal iso3166.tab Australia EST GB GMT0 MST PRC ROK W-SU zone.tab

You can copy the file directly or use one of the presets. In my case, Irish time is the same as London time. So,

root@beaglebone:/usr/share/zoneinfo# cd Europe/
root@beaglebone:/usr/share/zoneinfo/Europe# ls -al

total 20 
drwxr-xr-x 2 root root 4096 Mar 18 2013 . 
drwxr-xr-x 9 root root 4096 Jan 1 11:42 .. 
-rw-r--r-- 1 root root 3661 Mar 19 2013 London
-rw-r--r-- 1 root root 1464 Mar 19 2013 Moscow
-rw-r--r-- 1 root root 2945 Mar 19 2013 Paris

So, I am going to use the London file – back to the /etc directory:

root@beaglebone:/etc# rm localtime
root@beaglebone:/etc# ln -s /usr/share/zoneinfo/Europe/London /etc/localtime

by setting a symbolic link from /etc/localtime to the timezone file. The advantage of this over copying the file is that you can see the timezone that was set when you ls:

root@beaglebone:/etc# ls -al|grep localtime 
lrwxrwxrwx 1 root root 33 Jan 1 12:05 localtime -> /usr/share/zoneinfo/Europe/London

root@beaglebone:/etc# ls -al localtime 
lrwxrwxrwx 1 root root 33 Jan 1 12:05 localtime -> /usr/share/zoneinfo/Europe/London

source

Tuesday, July 30, 2013

Automatic set proxy on boot on Linux

You can set the variable globally in /etc/profile or by creating a script for your variable in /etc/profile.d:

export http_proxy="http://\:@:"
export https_proxy="http://\:@:"

Use network proxy environment settings for "sudo" user on Linux

the trick is to add enviroment variables to sudoers config:
sudo nano /etc/sudoers
add these lines:
Defaults env_keep +="http_proxy"
Defaults env_keep +="https_proxy"
from ArchLinux wiki https://wiki.archlinux.org/index.php/Sudo#Environment_variables_.28Outdated.3F.29

Wednesday, April 13, 2011

Windows Network Adapters: Public change to Private network

Tested on Windows Server 2008 R2

I had a similar problem and have a solution, though, it might not be exactly
what is wanted, it has worked for me.
My network is identified as :"Unidentified Network" in Network and Sharing
Center, I ran the Securty Policy Editor (Start->Run "secpol.msc" )

Select Network List Policies under Security Settings and then select
:Unidentifed Network from the Network Names displayed, then
Action->Properties and then set the location type to Private. Since Vista
won't let me change the name of the network on my system is allways
Unidentifed and set to private, not something I would think you would want
to do with a network that is truly "unidentified".

from

Wednesday, April 6, 2011

Windows Server 2008 Slow network connectivity to Windows Server 2003

Windows Server 2008 Slow network connectivity to Windows Server 2003

So it would seem that Bonez had the answer in a manner of speaking. I didn't have to do anything with packet tagging, but I did install QoS on my Windows Server 2003 box and now the Windows Server 2008 box is able to browse network resources on the 2003 box lickity split. I did not have to run the netsh commands. I am betting that I could reverse those commands on my vista boxes and still be able to access the 03 box...

Thanks so much John and Bonez.

To be clear: The solution was to make sure that QoS was installed on the 2003 box.

BTTrayCE is not valid pocket pc application

After installing TomTom navigator 7.916 on Windows Mobile I soft reset the phone and I get an error saying " BTTrayCE is not valid pocket pc application".

Rename these 2 files in your windows directory on phone:
BtCoreIf.dll
BtSdkCE30.dll
(for example: "BtCoreIf.old" "BtSdkCE30.old")
then reset, it will fix them.

Tuesday, October 19, 2010

Add new user to Samba share

useradd
cat /etc/passwd

smbstatus
cd /etc/samba/
vi smb.conf
smbcontrol smbd reload-config

smbpasswd -a

Thursday, July 9, 2009

Tagsistant - A reasoning semantic filesystem for Linux and BSD

http://www.tagsistant.net/index.php

What is a semantic file system? Honestly, I don't know! Many people say that is something you can use to organize your contents using ontologies based on labels or tags. Others say it is related to relationship between files or "things". Others claim it has something to do with circles in fields! ;-)

To me, a semantic filesystem is basically a tool that allows one to catalogue files and to extract subsets using logical queries.

But why a filesystem and not a database or a desktop application? That's the most obvious but often hidden consideration a programmer should do! Software should be as interface neutral as possible. Interface neutral means that you should be able to communicate with this software easily and efficiently.

A desktop tool can be comfortable for the user, can be assistive and accessible. But other softwares will not be advantaged in interfacing with that tool. Perhaps other tools should be modified to apply to new API, requiring days of coding and possibly introducing new bugs! Universal, well known and well tested interfaces should be preferred against special, new, particular interfaces.

A filesystem is probably one (or the most) universal interface you can think of (especially on UNIX, and especially talking about files!). Later, someone will write a colorful and intuitive desktop application (or a series of) which will be appealing, but right now, with a 3 days hack, everyone can tag his/her files by simply using the filemanager interface he's used to.