2019年1月11日 星期五

Windows Shutdown Hourly Shutdown Reboot Servers


https://www.quora.com/When-the-Windows-server-2012-trial-version-expires-will-it-affect-the-functionality-Will-it-affect-the-group-policy-and-users-and-what-not

All evaluation versions are fully functional during the evaluation period, although booting to Safe mode is not available. The Windows Server 2012 Standard and Windows Server 2012 Datacenter editions come with the activation key pre-installed. After the 180-day evaluation period elapses, the server warns you in various ways depending on the edition:
Windows Server 2012 Standard; Windows Server 2012 Datacenter:
  • The following warning appears on the Desktop: Windows License is expired
  • When you log on to Windows, you are prompted with the following options:Activate nowAsk me later
  • The system shuts down every hour.
  • The only updates that can be installed are security updates.
  • Event ID 100 from source WLMS “The license period for this installation of Windows has expired. The operating system will shut down every hour.” appears in the Application log.
Windows Server 2012 Essentials: you receive warnings on the Desktop and on the dashboard, but the server does not shut down.




Same issue, I've disabled windows software protection service and that's it.

HKLM/SYSTEM/CurrentControlSet/Services/sppsvc

Change value of Start from 2 to 4

2019年1月8日 星期二

Change iTune Backup Location to D drive



https://www.fonepaw.com/solution/change-itunes-backup-location.html

C:\Users\Ricky\AppData\Roaming\Apple Computer\MobileSync>mklink /J "%APPDATA%\Apple Computer\MobileSync\Backup" "D:\ricky\Backup"
Junction created for C:\Users\Ricky\AppData\Roaming\Apple Computer\MobileSync\Backup <<===>> D:\ricky\Backup


mklink /J

C:\>mklink /?
Creates a symbolic link.

MKLINK [[/D] | [/H] | [/J]] Link Target

        /D      Creates a directory symbolic link.  Default is a file
                symbolic link.
        /H      Creates a hard link instead of a symbolic link.
        /J      Creates a Directory Junction.
        Link    Specifies the new symbolic link name.
        Target  Specifies the path (relative or absolute) that the new link

2019年1月3日 星期四

InfluxDB InfluxQL Examples

SELECT "bid" FROM "quotes"."autogen"."quotes" WHERE time > '2019-01-03 00:00:00' and time > '2019-01-03 00:00:01' AND "symbol" =~/AUDUSD*/ GROUP BY "symbol"

SELECT symbol, "bid" FROM "quotes" WHERE symbol =~ /AUDUSD*/ and time > now()-1s

SELECT symbol, "bid" FROM "quotes" WHERE symbol =~ /AUDUSD*/ and time > '2019-01-02 23:00:00' and time < '2019-01-02 23:01:00'

2018年11月20日 星期二

Winsock 2 Windows Socket Programming

https://www.tenouk.com/Winsock/Winsock2example.html

Create empty solution
Add input to ws2_32.lib

define _WINSOCK_DEPRECATED_NO_WARNINGS


2018年11月19日 星期一

Git on Windows Shared drive

On Server:
172.16.18.77
3389
git
git
C:\git
share read write to ricky

On your desktop:
map \\172.16.18.77\git to Z:
git clone Z:\MT4Managers

2018年10月18日 星期四

Redis on Windows Visual Studio C++



https://blog.csdn.net/LG1259156776/article/details/54645745


https://github.com/MicrosoftArchive/redis
Download and extract redis-3.0.zip
Open redis-3.0\msvs\RedisServer.sln with Visual Studio Community 2017 v15.8.3
Compile hiredis and Win32_interop projects to generate hiredis.lib and Win32_Interop.lib in redis-3.0\msvs\x64\Debug
Visual Studio > New > Visual C++ > Empty Project > Project1

1. Copy hiredis.lib and Win32_Interop.lib to Project1 folder
2. Copy *.h from redis-3.0\deps\hiredis\ to Project1\deps\hiredis

async.h
dict.h
fmacros.h
hiredis.h
net.h
sds.h
win32_hiredis.h
zmalloc.h

3. Overwrite fmacros.h from redis-3.0\src\fmacros.h to Project1\deps\hiredis\fmacros.h
4. Copy *.h from redis-3.0\src\Win32_Interop\ to Project1\src\Win32_Interop\
5. Copy win32fixes.c from redis-3.0\src\Win32_Interop\win32fixes.c to Project1\win32fixes.c
6. Select x64, Project1 > Properties > C/C++ > General > Additional Include Directories > .\deps\hiredis\;.\src\;

7. create a.cpp and compile


#include <stdio.h>  
#include <stdlib.h>  
#include <string.h>  
#include <ctime>

#include "hiredis.h"
#define NO_QFORKIMPL // must add this line
#include "Win32_Interop\win32fixes.h"
#pragma comment(lib,"hiredis.lib")  
#pragma comment(lib,"Win32_Interop.lib")  

int main() {

 using namespace std;

 unsigned int j;
 redisContext *c;
 redisReply *reply;

 struct timeval timeout = { 1, 500000 }; // 1.5 seconds  
 c = redisConnectWithTimeout((char*)"127.0.0.1", 6379, timeout);
 if (c->err) {
  printf("Connection error: %s\n", c->errstr);
  exit(1);
 }

 reply = (redisReply *)redisCommand(c, "AUTH foobared");
 printf("AUTH: %s\n", reply->str);
 freeReplyObject(reply);

 clock_t begin = clock();
 for (int i = 0;i<1000; ++i) {
  reply = (redisReply *)redisCommand(c, "publish redisChat %d", i);
  //printf("publish: %s\n", reply->str);
  freeReplyObject(reply);
 }
 clock_t end = clock();
 double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
 printf("elapsed_secs = %f\n", elapsed_secs); // 0.1s for 1000 commands

 /* PING server */
 reply = (redisReply *)redisCommand(c, "PING");
 printf("PING: %s\n", reply->str);
 freeReplyObject(reply);

 /* Set a key */
 reply = (redisReply *)redisCommand(c, "SET %s %s", "foo", "hello world");
 printf("SET: %s\n", reply->str);
 freeReplyObject(reply);

 /* Set a key using binary safe API */
 /*reply = (redisReply *)redisCommand(c, "SET %b %b", "bar", 3, "hello", 5);
 printf("SET (binary API): %s\n", reply->str);
 freeReplyObject(reply);*/

 /* Try a GET and two INCR */
 reply = (redisReply *)redisCommand(c, "GET foo");
 printf("GET foo: %s\n", reply->str);
 freeReplyObject(reply);

 reply = (redisReply *)redisCommand(c, "INCR counter");
 printf("INCR counter: %lld\n", reply->integer);
 freeReplyObject(reply);
 /* again ... */
 reply = (redisReply *)redisCommand(c, "INCR counter");
 printf("INCR counter: %lld\n", reply->integer);
 freeReplyObject(reply);

 /* Create a list of numbers, from 0 to 9 */
 reply = (redisReply *)redisCommand(c, "DEL mylist");
 freeReplyObject(reply);
 for (j = 0; j < 10; j++) {
  char buf[64];

  sprintf_s(buf, 64, "%d", j);
  reply = (redisReply *)redisCommand(c, "LPUSH mylist element-%s", buf);
  freeReplyObject(reply);
 }

 /* Let's check what we have inside the list */
 reply = (redisReply *)redisCommand(c, "LRANGE mylist 0 -1");
 if (reply->type == REDIS_REPLY_ARRAY) {
  for (j = 0; j < reply->elements; j++) {
   printf("%u) %s\n", j, reply->element[j]->str);
   getchar();
  }
 }
 freeReplyObject(reply);

 return 0;

}

Design Data Structure in Redis


Redis Setup
https://redislabs.com/blog/redis-on-windows-10/
Install Ubuntu on Windows by "Windows Feature" GUI or by command line:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

> sudo apt-get update
> sudo apt-get upgrade
> sudo apt-get install redis-server
> redis-cli -v

> $ sudo vi /etc/redis/redis.conf
requirepass foobared

> sudo service redis-server restart

127.0.0.1:6379> get foo
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth foobared
OK
127.0.0.1:6379> get foo
"bar"


Data Structure

class Summary : public Item {
double orders;
double buyVolume;
double buyPrice;
double sellVolume;
double sellPrice;
double profit;
};
class Quote : public Item {

double bid;
double ask;
};

std::unordered_map<std::string, Summary> items;
std::unordered_map<std::string, Quote> items;

Redis Hashes
https://www.tutorialspoint.com/redis/redis_data_types.htm
Redis hashes are key-value pairs.
redis 127.0.0.1:6379> HMSET user:1 username tutorialspoint password 
tutorialspoint points 200 
OK 
redis 127.0.0.1:6379> HGETALL user:1  
1) "username" 
2) "tutorialspoint" 
3) "password" 
4) "tutorialspoint" 
5) "points" 
6) "200"

The above represents

class User {
std::string username;
std::string password;
int points;
};
std::unordered_map<std::string, User> users;
users["1"] = User{"name", "password", 200};


Python get set

import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0, password='foobared')
r.set('foo', 'bar')
print(r.get('foo'))


Python subscribe to Redis
import redis

def main():
    try:
        r = redis.StrictRedis(host='localhost', port=6379, db=0, password='foobared')
        p = r.pubsub()
        p.subscribe('redisChat')
        done = False
        while not done:
            message = p.get_message()
            if message:
                data = message['data']
                if isinstance(data, bytes):
                    print(data)
    except Exception as e:
        print(e)

if __name__=='__main__':
    main()



The End

2007 to 2023 HP and Dell Servers Comparison

  HP Gen5 to Gen11  using ChatGPT HP ProLiant Gen Active Years CPU Socket Popular HP CPUs Cores Base Clock Max RAM Capacity Comparable Dell ...