Monday, September 2, 2019

delete OEM system partition win 10

Windows Disk Management tool will not let you delete/merge the OEM partition. You will have to use the built-in command line tool called Diskpart.
Be careful before you decide to run the commands, lest you mess up – you should know what you are doing:
  • Open the Run prompt, type diskpart, and hit Enter.
  • Type, and enter list disk to list the disks.
  • Select the disk you want to manage – say it is Disk Z
  • Then type select disk z and hit Enter.
  • Enter list partition and hit Enter to display all the volumes.
  • Type select partition x and hit Enter. Here x stands for the partition you want to delete.
  • Finally, type delete partition override and hit Enter to delete it.
  • Now type Extend to merge the OEM partition with the adjoining value.
If you want only to merge part of the partition, then use extend [size=]  command. To extend size by 5GB, type-
Extend size=5000
Here size is the size you choose from the OEM partition.  It will extend the selected volume by size in megabytes (MB). So like you can see, delete and merge partition commands work hand to hand. You need first to delete it and then merge it existing partition.

Tuesday, August 6, 2019

siteSucker setting



https://github.com/microsoft/USBuildingFootprints

download zip file only, all default, except path constraint, setting customzied path.

file type choose zip archive not works

centos transfer file use winSCP

centos transfer file use winSCP

Friday, August 2, 2019

add user to admin group windows

https://superuser.com/questions/171917/force-a-program-to-run-without-administrator-privileges-or-uac



Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\forcerunasinvoker]
@="Run without privilege elevation"

[HKEY_CLASSES_ROOT\*\shell\forcerunasinvoker\command]
@="cmd /min /C \"set __COMPAT_LAYER=RUNASINVOKER && start \"\" \"%1\"\""
Save this text in .reg and add it to the Windows Registry. (Double-clicking on it should do the trick.)
Afterwards, right-click the app you'd like to run without administrative privileges and select "Run without privilege elevation".
In some cases - small amount 0.1% of programs may ask twice about UAC prompt.


========================================================


right click c:\apache2.4
properties ---- security,  ---- add user to full control


Monday, July 8, 2019

sqlite

mysql convert to sqlite

https://www.rebasedata.com/convert-mysql-to-sqlite-online

==================================



sql.js load sqlite file from server

https://stackoverflow.com/questions/28066570/read-sqlite-database-from-the-disk-using-sql-js








=================================


https://stackoverflow.com/questions/3890518/convert-mysql-to-sqlite

------------------

may not work, not try yet

https://gist.github.com/esperlu/943776


--------------------

convert tools

https://www2.sqlite.org/cvstrac/wiki?p=ConverterTools



Friday, May 24, 2019

Untrack files already added to git repository based on .gitignore


Let’s say you have already added/committed some files to your git repository and you then add them to your .gitignore; these files will still be present in your repository index. This article we will see how to get rid of them.

Step 1: Commit all your changes

Before proceeding, make sure all your changes are committed, including your .gitignore file.

Step 2: Remove everything from the repository

To clear your repo, use:
git rm -r --cached .
  • rm is the remove command
  • -r will allow recursive removal
  • –cached will only remove files from the index. Your files will still be there.
  • The . indicates that all files will be untracked. You can untrack a specific file with git rm --cached foo.txt (thanks @amadeann).
The rm command can be unforgiving. If you wish to try what it does beforehand, add the -n or --dry-run flag to test things out.

Step 3: Re add everything

git add .

Step 4: Commit

git commit -m ".gitignore fix"
Your repository is clean :)

Push the changes to your remote to see the changes effective there as well.

Thursday, April 25, 2019

geohub hub opendata arcgis api


  https://geohub.lacity.org/data.json








---------------------------------------------------------------------------------------
https://community.esri.com/thread/226451-arcgis-open-data-api


I'm looking for a simple way to get the total number of datasets of an instance under *.opendata.arcgis.com.
The only way I found till now is to call data.json and then iterate through all its results/pages, e.g. https://alcaldiadeguarne-guarne.opendata.arcgis.com/data.json where there are 40 datasets.
I was wondering if could call e.g. api/v2/datasets and provide a filter with a parameter URL like this
Can you help me on this?
Thanks.

Hi Andreiwid,

You can return total datasets by a given source by filtering on the source field and looking at the aggregation values at the bottom of the json document. For example, if you call https://opendata.arcgis.com/api/v2/datasets?filter[source]=Municipio%20de%20Guarne and collapse the data field, you should see something like this:





After testing a lot of possibilities, I ended up making a sequence of 3 APIs in order to get the number of datasets of a given installation:

  1. ‘data.json’ – returns a list of the first 1,000 datasets of an installation. This API is necessary to extract at least one dataset ID to be use in next request.
  2. ‘/api/v2/datasets/{:id}’ – returns further details about a dataset where it is possible to access the standardized field ‘Owner’ necessary to make next request.
  3. ‘/api/v2/datasets’ – returns all the datasets to a given ‘Owner’ of an installation as well as the nested attribute ‘meta.stats.totalCount’ in the resulting JSON dictionary which finally specifies the number of existing datasets.

My experiments reported the API sequence 1 returns an empty dataset array for some installations. If you are curious about that, see https://data-brookhavenga.opendata.arcgis.com/data.json and https://data-eastlongmeadow.opendata.arcgis.com/data.json.

Saturday, April 13, 2019

ipfs auto restart


https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html#//apple_ref/doc/uid/10000172i-SW7-BCIEDDBJ



https://medium.com/@chetcorcos/a-simple-launchd-tutorial-9fecfcf2dbb3


this sh file is locate at :/Users/sirius/ipfs_auto_restart.sh

to run this file once:
     sh /Users/sirius/ipfs_auto_restart.sh

create this file:

   sudo vim /Users/sirius/ipfs_auto_restart.sh

then, copy past below script
then
  1. Open the terminal application in Linux or Unix
  2. Next, open a file in vim / vi, type: vim filename
  3. To save a file in Vim / vi, press Esc key, type :w and hit Enter key
  4. One can save a file and quit vim / Vi by pressing Esc key, type :x and hit Enter key

---------------------


#!bin/bash
#Start  only if it is not running
SERVICE="ipfs"
if pgrep -x > "$SERVICE" >/dev/null
then
 "$SERVICE is running"
else
 ipfs daemon
 echo "$SERVICE stopped, but re-started...."
fi


------------------

========  create a plist file =================

sudo vim /Library/LaunchDaemons/com.ipfs.auto.restart.plist

copy below xml and past, then exit

  1. Open the terminal application in Linux or Unix
  2. Next, open a file in vim / vi, type: vim filename
  3. To save a file in Vim / vi, press Esc key, type :w and hit Enter key
  4. One can save a file and quit vim / Vi by pressing Esc key, type :x and hit Enter key



ProgramArguments              touch         /tmp/helloworld    









    Label
    com.ipfs.daemon
        ProgramArguments

                 
              sh
              /Users/sirius/ipfs_auto_restart.sh
      

    KeepAlive
        StartInterval   
    10











    Label
    com.ipfs.daemon
    Program
    /Users/sirius/ipfs_auto_restart.sh
    KeepAlive
   

    StartInterval   
    10





 ...............................................................................
Before run
                          ipfs add -r xxxx

must close all ipfs daemon from task manager

clean close all process.

 get error:

siriuss-mini:~ sirius$ ipfs add -r /Volumes/original-1/fileRestAPI/Los_Angeles_County_Land_Records
Error: cannot connect to the api. Is the deamon running? To run as a standalone CLI command remove the api file in `$IPFS_PATH/api`


you have to go d:\ipfs_repo
to delete api file and repo.lock file,
because when you force quit ipfs desktop, those 2 file left un-closed,
you must manually delete them.

--------------------------------------------------------------------------------------------------------------------

Tuesday, April 9, 2019

VectorTileServer vtpk


(VectorTileServer)


sample


https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services?f=html


https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Esri_Childrens_Map/VectorTileServer?f=jsapi

https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Esri_Childrens_Map/VectorTileServer/tile/{z}/{x}/{y}.pbf


https://gis.stackexchange.com/questions/270827/create-image-from-esri-vectortileserver-using-script







openlayers - sample
https://openlayers.org/en/latest/examples/vector-tile-info.html




esri-doc


https://developers.arcgis.com/rest/services-reference/vector-tile-service.htm



https://www.arcgis.com/home/search.html?t=content&q=tags%3AVTPK&start=1&num=20

Tuesday, April 2, 2019

Launch multiple instances of application in Mac

Open Terminal and type:
open -n -a "APPLICATION NAME"

-n: new instance window
-a: application name


---------------------

How to Launch GUI Applications from the Terminal

Feb 1, 2007 - 30 Comments
terminalWe all know how to launch applications from the GUI with a double-click on the icon or clicking on the app in the Dock, and there are numerous ways to do so, and they’re all relatively speedy. If you spend a decent amount of time with the command line though, it’s nice to be able to launch Mac apps directly from there as well. Also, the Terminal has a fair share of applications that run in text based mode, but maybe you wanted to edit a text file in the OS X GUI app TextWrangler rather than the text based nano or vim.
We’re going to demonstrate how to launch any graphical Mac app from the command line of OS X, including how to open specific files from the command line with a GUI app, and how to edit and open those files with root access if it’s necessary.

Opening Mac OS X Applications from the Command Line

The Terminal command to launch OS X gui apps is appropriately called ‘open’ and here is how it works at it’s most simple:
open -a ApplicationName
That will open the defined app named “ApplicationName”.
But open is much more powerful than that. If you just type ‘open’ at the command prompt, you’ll return the basic help file with details on how to properly use the command with a variety of flags and syntax. While the open command exists in all versions of Mac OS X, the abilities vary somewhat depending on what version of OS X the Mac is running. Nonetheless, in modern releases this is what you’ll see:
$ open
Usage: open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-b ] [-a ] [filenames] [--args arguments]
Help: Open opens files from a shell.
By default, opens each file using the default application for that file.
If the file is in the form of a URL, the file will be opened as a URL.
Options:
-a Opens with the specified application.
-b Opens with the specified application bundle identifier.
-e Opens with TextEdit.
-t Opens with default text editor.
-f Reads input from standard input and opens with TextEdit.
-F --fresh Launches the app fresh, that is, without restoring windows. Saved persistent state is lost, excluding Untitled documents.
-R, --reveal Selects in the Finder instead of opening.
-W, --wait-apps Blocks until the used applications are closed (even if they were already running).
--args All remaining arguments are passed in argv to the application's main() function instead of opened.
-n, --new Open a new instance of the application even if one is already running.
-j, --hide Launches the app hidden.
-g, --background Does not bring the application to the foreground.
-h, --header Searches header file locations for headers matching the given filenames, and opens them.
In other words, example simple command syntax could look like the following, opening “ApplicationName” with the file located at the path ‘/file/to/open’:
open -a ApplicationName /file/to/open
You’ll note you don’t need the full path to the application name, but you would need the full path to a file name.
The usage is likely self explanatory to those who have experience in the command line environment, but for those who are new to the Terminal, don’t be too confused, it is easy to use and we’ll explain. For example, if you want to edit /etc/motd with TextWrangler to change your Message of the Day, but you hate the command line editors nano and vi, here is what you’d type:
$ open -a TextWrangler /etc/motd
Now you can edit these files in the familiar GUI. open is smart enough to know that when you apply the -a flag, you are launching an application so you don’t need to type in its full path. Obviously, it’ll still need the full path to the file you’re editing though.
There are many other usages for the open command rather than just editing text files, so use your imagination and get creative. open could be particularly useful to system administrators who utilize it in a shell script, perhaps to launch a specific GUI application at a scheduled time.
Also worth noting is that if you are launching an application with spaces in its name, you’ll want to add a backslash after each word, opening Adobe Photoshop CS would look like this:
$ open -a Adobe\ Photoshop\ CS

Launching GUI Apps as root from the Command Line

You can even open files with sudo by using the open command if you need to edit a file as root, for example:
sudo open -a TextEdit /tmp/magicfile
This will launch the target file into the desired application as root user, giving full root privileges to edit and modify the file, which is quite helpful for editing many system files. Of course, don’t modify any system file if you don’t know what you’re doing.

Creating Shell Aliases for Frequently Launched GUI Apps

So it’s kind of a pain in the butt to type a full command repeatedly, or to type out all that out over and over again, right? Well let’s make it easier by assigning an alias to an application that gets frequently launched. We’ll take the aforementioned Adobe Photoshop app as an example since the file name is lengthy, so here’s how we’ll do this with the Mac OS X default Bash shell:
First launch the profile or .bash_profile into a text editor:
$ nano .profile
or
$ open -e .profile
Ignoring whatever else may be in this file (it could be empty also), add the following to a new line:
alias photoshop="open -a Adobe\ Photoshop\ CS"
This creates an alias, so that the “open -a Adobe\ Photoshop CS” command is now shortened to simply ‘photoshop’. Save .profile, and you’re on your way! You can use the alias command in conjunction with open for virtually anything, just be sure to pick an alias to a command that doesn’t already exist.
The open command is really handy as you can see, if you have any other great uses for it in OS X, be sure to let us know in the comments.

Friday, March 15, 2019

ipfs cluster



----------------------- firewall port open -----------------------
A small amount of firewall management is needed to get IPFS cluster service communicating between peers. 4001 and 8080 should already be open for IPFS. 9094, 9095 and 9096 are used by the cluster service
 ---------------------------------------------------------------------





Windows:

init cluster to your folder 


     F:\ipfs\ipfs-cluster-service>ipfs-cluster-service --config F:\ipfs_cluster init
          12:36:00.873  INFO     config: Saving configuration config.go:411
           ipfs-cluster-service configuration written to F:\ipfs_cluster\service.json







Mac:


https://medium.com/@rossbulat/using-ipfs-cluster-service-for-global-ipfs-data-persistence-69a260a0711c



https://medium.com/mvp-workshop/ipfs-publishing-and-ipfs-cluster-cff3a099993a
download and unzip,

first must 


1.
       export PATH="/Volumes/ipfs-1tb/ipfs-cluster-service"

to make it available, export only works 1 time, after reboot or terminal exit, it no longer works.

So better to just copy executable file to usr/bin at:

        copy ipfs-cluster-service  to /usr/local/bin




2.

sudo nano .bash_profile ( works after reboot, )

add:
       
       export CLUSTER_SECRET="1c9b744ad2cb0146ee3c2f975e10bd9e7293b0e1d96c57f1e72afdefd8f1974e"




    
    ipfs-cluster-service init
 
( this will create a folder at:  [ your-user/.ipfs-cluster  ] 
 check service.json file, make sure 'secret' is same as above, all peer should share the same secret.



 
ipfs-cluster-service daemon --bootstrap /ip4/10.78.11.145/tcp/9096/ipfs/QmSCtkrL1SDzogQD5VeSSuUZxzqiA8KdoZbXHwHum4Sh5a 

Tuesday, February 26, 2019

Set up IPFS node on the server


https://michalzalecki.com/set-up-ipfs-node-on-the-server/


Install and setup IPFS

I am going to use AWS EC2 to spin up my server with Amazon Linux 2 using the default VPC. A t2.micro instance will not cost you a dime during the free tier and is good enough for IPFS node and you a few web services.
Install Golang and IPFS. Make sure to use the latest version.
sudo yum update -y
sudo yum install -y golang

wget https://dist.ipfs.io/go-ipfs/v0.4.17/go-ipfs_v0.4.17_linux-amd64.tar.gz
tar -xvf go-ipfs_v0.4.17_linux-amd64.tar.gz
./go-ipfs/install.sh
If the installation fails, then you can move executable to your bin path manually.
sudo mv ./go-ipfs/ipfs /usr/local/bin
Initialize local IPFS configuration and add your first file.
> ipfs init --profile server
echo "

Michal

" > index.html > ipfs add index.html added Qma1PYYMwbgR3GBscmBV7Zx8YgWdhBUAY6z27TznhrBet9 index.html > ipfs cat Qma1PYYMwbgR3GBscmBV7Zx8YgWdhBUAY6z27TznhrBet9

Michal

Congratulation! You've just added a file to IPFS repository. Although you can fetch it, it works only locally. To join the network, you should run the IPFS daemon.
ipfs daemon
If your firewall does not block connection, then you should be able to fetch your files from the remote node or use a public gateway like https://ipfs.io/ipfs/.

Run IPFS daemon on start

It would be better to start IPFS daemon as a service instead of the terminal attached process. Let's define a simple unit file responsible for running IPFS daemon service.
sudo vi /etc/systemd/system/ipfs.service
Copy and paste the unit file definition. Make sure to change the User, so it corresponds to the account you have on your server.
[Unit]
Description=IPFS Daemon
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=simple
ExecStart=/usr/local/bin/ipfs daemon --enable-namesys-pubsub
User=ec2-user

[Install]
WantedBy=multi-user.target
Running daemon with --enable-namesys-pubsub benefits from nearly instant IPNS updates. IPNS is IPFS naming system that allows for mutable URLs. After editing a unit file, reload the daemon, enable service to start on boot and start the service.
sudo systemctl daemon-reload
sudo systemctl enable ipfs
sudo systemctl start ipfs
You can now reboot your instance and make sure whether IPFS is back and running.
sudo systemctl status ipfs

Make gateway publicly accessible

If you want to, you can make your IPFS gateway publicly accessible. Change gateway configuration to listen on all available IP addresses.
In ~/.ipfs/config change
"Gateway": "/ip4/127.0.0.1/tcp/8080"
to
"Gateway": "/ip4/0.0.0.0/tcp/8080"

Conclusion

I am running IPFS nodes on EC2 and GCP Compute Engine VM for some time now and I did not have any major problems with it. You can use scp to copy files over ssh to your remote server. For programmatic access, you can make your IPFS gateway writable and use IPFS HTTP API. There are plenty of creative use cases for IPFS!

How to run several IPFS nodes on a single machine?



Usually, when you start with IPFS, you will use ipfs init, which will create a new node. The default data and config stored for that particular node are located at ~/.ipfs. Here is how you can create a new node and config it so it can run besides your default node.

1. Create a new node

For a new node you have to use ipfs init again. Use for instance the following:
IPFS_PATH=~/.ipfs2 ipfs init
This will create a new node at ~/.ipfs2 (not using the default path).

2. Change Address Configs

As both of your nodes now bind to the same ports, you need to change the port configuration, so both nodes can run side by side. For this, open ~/.ipfs2/configand findAddresses`:
"Addresses": {
    "API": "/ip4/127.0.0.1/tcp/5001",
    "Gateway": "/ip4/127.0.0.1/tcp/8080",
    "Swarm": [
        "/ip4/0.0.0.0/tcp/4001",
        "/ip6/::/tcp/4001"
    ]
}
To for example the following:
"Addresses": {
    "API": "/ip4/127.0.0.1/tcp/5002",
    "Gateway": "/ip4/127.0.0.1/tcp/8081",
    "Swarm": [
        "/ip4/0.0.0.0/tcp/4002",
        "/ip6/::/tcp/4002"
    ]
}
With this, you should be able to run both node .ipfs and .ipfs2 on a single machine.

Notes:
  1. Whenever you use .ipfs2, you need to set the env variable IPFS_PATH=~/.ipfs2
  2. In your example you need to change either your client or server node from ~/.ipfs to ~/.ipfs2
  3. you can also start the daemon on the second node using IPFS_PATH=~/.ipfs2 ipfs daemon &

Saturday, February 23, 2019

ipfs add : error too many files open, Mac only



Mac only,

 by default Mac allow 256 files open limit, you need to set this limit to 65536, 
otherwise, ipfs add -r path, will run into error due to "too many files opened..."


see current limit
launchctl limit maxfiles


set new limit
sudo launchctl limit maxfiles 65536 200000

add above to $user/.bash_profile, everytime reboot, it will auto reset,

$user:  nano .bash_profile

edit,

when finish, ctrl+x,  Y,  Enter,

Done 


Set this higher to prevent errors during high load


Overview

Operating systems (Linux and macOS included) have settings which limit the number of files and processes that are allowed to be open. This limit protects the system from being overrun. But its default is usually set too low, when machines had way less power. Thus a “gotcha” that is only apparent when “too many files open” crashes appear only under load (as in during a stress test or production spike).
man bash, the Bash manual says the ulimit command (common among Linux flavors) provides “control over the resources available to the shell and to processes started by it”.
  1. Obtain the current limit of file descriptors
    ulimit -n
    An example output: “256” or “10032”.
    PROTIP: On MacOS, the maximum number that can be specified is 12288.
  2. Obtain the current limit of processes
    ulimit -u
    An example output: “1418”.

On macOS

  1. Obtain the current limit:
    launchctl limit maxfiles
    The response output should have numbers like this:
    maxfiles    65536          200000
    The first number is the “soft” limit and the second number is the “hard” limit.
    Configuration changes are necessary if lower numbers are displayed, such as:
    maxfiles    256            unlimited
  2. If the soft limit is too low (such as 256), set the current session to:
    sudo launchctl limit maxfiles 65536 200000
    Some set it to 1048576 (over a million).
    Since sudo is needed, you are prompted for a password.
    PROTIP: Because this would go back to defaults on reboot, add this command in your ~/.bash_profile
    Alternately, install Facebook’s Watchman utility which watches and adjusts automatically.
    PROTIP: Take both a full/complete backup to ensure fall-back. Also run a benchmark performance measurement before and after changing the configuration to detect issues.
  3. Over several versions, Apple has been changing the way system-wide open file limits can be set upon restart.

    Yosemite and older

    NOTE: On older MacOSX Yosemite, to make the settings permanent, increase the limits, edit (or create) file /etc/launchd.conf to contain:
    limit maxfiles 65536 200000

    Sierra and newer versions

    Newer versions of macOS no not reference the file due to security considerations.
    On newer macOS Sierra and High Sierra, Dejan Kitic and this found that two plist files need to be added.
  4. Copy in folder /Library/LaunchDaemons/ plist files from a GitHub repository:

sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist
   sudo launchctl load -w /Library/LaunchDaemons/limit.maxproc.plist
The files’ ownership needs to be changed to “root:wheel”.
Their permissions need to be “-rw-r–r–”, set by sudo chmod 644.
  1. So how do you turn csrutil off? Google says sudo csrutil disable… Ummm, not so easy, can only be done in Recovery Mode. So, reboot, hold command + R to enter Recovery Mode, once there open terminal and do csrutil disable… Finally a breakthrough…disabled.
  2. Now you can adjust the process limit on Mac OS X Yosemite and El Capitan versions:
    sudo ulimit -n 65536 200000
    Since sudo is needed, you are prompted for a password.
  3. To increase the inotify watchers max limit, edit (or create) file /etc/sysctl.conf (inherited from BSD) to contain:
    kern.maxfiles=49152
    kern.maxfilesperproc=24576
    or
    kern.maxfiles=200000
    kern.maxfilesperproc=200000
    Alternately, run interactive commands:
    sudo sysctl -w kern.maxfiles=5242880
    The response:
    kern.maxfiles: 49152 -> 5242880
    sudo sysctl -w kern.maxfilesperproc=524288
    The response:
    kern.maxfilesperproc: 24576 -> 524288
  4. Restart the system for the new limits to take effect.
  5. After restarting, verify the new limits by running:

On RedHat and CentOS

  1. To enable PAM-based user limits so that non-root users, such as the riak user, may specify a higher value for maximum open files, edit (or create) file /etc/security/limits.conf to contain:
    * soft nofile 65536
    * hard nofile 200000
    If the file already exists, append the above to the bottom of the file.
  2. To activate limits, edit (or create) file /etc/pam.d/login to contain:
    session    required   pam_limits.so
  3. Restart the machine.
  4. Verify by “ulimit -a” again.
    ulimit -n
    ulimit -Hn # Hard limit
    ulimit -Sn # Soft limit
    If the response is “10032”