Search This Blog

Thursday, June 18, 2020

Blender - delete dissolve difference

  • Delete: removes vertices/edges/faces and leaves nothing/a hole in their place.

  • Dissolve: combines faces into one big face (ngon) or removes edges only as a separator between faces.

  • Limited dissolve: dissolves (combines into big NGons) all faces that have a certain angle between them (less than 5° by default).

Friday, July 5, 2019

MongoDB - Pipelines

[
  {
    '$addFields': {
      'Month': {
        '$month': {
          '$dateFromString': {
            'dateString': '$job.ActionDateTime',
            'format': '%d/%m/%Y %H.%M.%S'
          }
        }
      },
      'Year': {
        '$year': {
          '$dateFromString': {
            'dateString': '$job.ActionDateTime',
            'format': '%d/%m/%Y %H.%M.%S'
          }
        }
      },
      'MonthYear': {
        '$dateToString': {
          'format': '%m:%Y',
          'date': {
            '$dateFromString': {
              'dateString': '$job.ActionDateTime',
              'format': '%d/%m/%Y %H.%M.%S'
            }
          }
        }
      }
    }
  }, {
    '$facet': {
      'Totals': [
        {
          '$group': {
            '_id': null,
            'averageRain': {
              '$sum': 1
            },
            'maxRain': {
              '$max': '$Rainfall'
            },
            'totalRain': {
              '$sum': '$Rainfall'
            }
          }
        }
      ],
      'Monthly': [
        {
          '$group': {
            '_id': '$Month',
            'averageRain': {
              '$sum': 1
            },
            'Rainfall': {
              '$sum': '$Rainfall'
            },
            'maxRain': {
              '$max': '$Rainfall'
            }
          }
        }, {
          '$sort': {
            '_id': 1
          }
        }
      ]
    }
  }
]

Tuesday, May 24, 2016

Linux: copy multiple files without asking overwrite confirmation

Linux: copy multiple files without asking overwrite confirmation

To always overwrite without prompt use a backslash:
$ \cp *.jpg ../

Linux: how to rename multiple files at once

Linux: how to rename multiple files at once

Very easy:

rename from to files...
rename JPG jpg *.JPG

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