21
Last post by tino - February 26, 2017, 06:50:11 pm
CREATE FUNCTION ts_round( timestamptz, INT4 ) RETURNS TIMESTAMPTZ AS $$ SELECT 'epoch'::timestamptz + '1 second'::INTERVAL * ( $2 * ( extract( epoch FROM $1 )::INT4 / $2 ) ); $$ LANGUAGE SQL;
22
Last post by tino - February 26, 2017, 06:49:51 pm
Download the new postgresql version untar , then ./configure make Stop the old server sudo /usr/local/pgsql/bin/pgsql.sh stop Move the old server directory mv /usr/local/pgsql /usr/local/pgsql-9.1.24 Now install the new server make install cd into the contrib/pg_upgrade directory. make make install cd into the contrib/pg_upgrade_support directory. make make install run the following, changing the directories to be the correct ones. old => new su postgres Create the new data directory /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data /usr/local/pgsql/bin/pg_upgrade -b /usr/local/pgsql-9.1.24/bin/ -B /usr/local/pgsql/bin/ -d /usr/local/pgsql-9.1.24/data -D /usr/local/pgsql/data Copy the pgsql.sh file to the new bin location. cp /usr/local/pgsql-9.1.24/bin/pgsql.sh /usr/local/pgsql/bin/ mkdir /usr/local/pgsql/log chown postgres:postgres /usr/local/pgsql/log edit the pg_hba.conf file and add the following to the end# Allow any user from host 192.168.1.x to connect to # any database if the user's password is correctly supplied. # TYPE DATABASE USER ADDRESS METHOD host all all 192.168.1.0/24 md5 start the server again.
23
Last post by tino - February 26, 2017, 06:48:37 pm
#include <avr/sleep.h> #include <avr/power.h> #include <avr/wdt.h> /* Watchdog Timer Prescale Select WDP3 WDP2 WDP1 WDP0 Number of WDT Typical Time-out at Oscillator Cycles VCC = 5.0V 0 0 0 0 2K (2048) cycles 16 ms 0 0 0 1 4K (4096) cycles 32 ms 0 0 1 0 8K (8192) cycles 64 ms 0 0 1 1 16K (16384) cycles 0.125 s 0 1 0 0 32K (32768) cycles 0.25 s 0 1 0 1 64K (65536) cycles 0.5 s 0 1 1 0 128K (131072) cycles 1.0 s 0 1 1 1 256K (262144) cycles 2.0 s 1 0 0 0 512K (524288) cycles 4.0 s 1 0 0 1 1024K (1048576) cycles 8.0 s */ unsigned int i = 0; void setup(void) { Serial.begin(57600); MCUSR &= ~(1 << WDRF); // reset status flag WDTCSR |= (1 << WDCE) | (1 << WDE); // enable configuration changes WDTCSR = (1<< WDP0) | ( 1 << WDP3); // set the prescalar = 9 WDTCSR |= (1 << WDIE); // enable interrupt mode } void loop(void) { set_sleep_mode(SLEEP_MODE_PWR_DOWN); // select the watchdog timer mode sleep_enable(); // enable the sleep mode ready for use sleep_mode(); // trigger the sleep Serial.print("Woken "); Serial.println(i++); Serial.flush(); sleep_disable(); // prevent further sleeps } ISR(WDT_vect) { }