//optional ssh-keygen # passphrase can be empty and then generate keys in `~/.ssh` # put *.pub (public key) to your server (~/.ssh/) and excute `cat id_rsa.pub >> authorized_keys` to merge Previous file # now rsa keys are ready
1 2 3 4 5 6 7
Host alias HostName 8.888.88.8 User root IdentityFile ~/.ssh/id_rsa RSAAuthentication yes PubkeyAuthentication yes PasswordAuthentication no
To access the notebook, open this file in a browser: file:///home/jovyan/.local/share/jupyter/runtime/nbserver-6-open.html Or copy and paste one of these URLs: http://896bb1e66101:8888/?token=fda8565a9b5cd5b8c621b45322ee72f716fd7ddea089fb51 or http://127.0.0.1:8888/?token=fda8565a9b5cd5b8c621b45322ee72f716fd7ddea089fb51
some web only use markdown and can’t upload pictures,such as v2ex.com
some pics you don’t want to give it to others for long time,such as your interesting story
give your blog’s can speed when download bigger pics
and so on
Picture Bed can offer you a excellent platform to share your pictures and protect them, however it has a problem that you need a server to run the service,even though you can use 七牛云,alioss,weibo for free.
why
Chevereto is aim what I find
dockerhub has chevereto images
Combined with ShareX (only for windows😢),chevereto can write markdown essay easily
it has api ,you can make it stronger
Chevereto Free v1.2.2 now
Something others you can discover by yourself
how
Chevereto is a php project , I use docker to run it
1 2 3 4 5 6 7 8 9 10
docker pull nmtan/chevereto:latest
//use docker-compose.yml(next block)
// or docker run docker run -it --name chevereto -d -p 8000:80 -v "/home/xxx/images":/var/www/html/images -e "CHEVERETO_DB_HOST=127.0.0.1" -e "CHEVERETO_DB_USERNAME=root" -e "CHEVERETO_DB_PASSWORD=rootpass" -e "CHEVERETO_DB_NAME=chevereto" -e "CHEVERETO_DB_PREFIX=chv_" nmtan/chevereto //-v save photos in server instead of container //-e mysql:5.7.31 host,username,password,db_name(db must exist first) //open chrome and input 127.0.0.1:8000
// start command nohup docker-compose up &> run.log & disown
You maybe run into a stone wall when you first visit 127.0.0.1:8000
Before you can use docker exec -it chevereto bash into container /var/www/html
no permission write phots to /home/xxx/images,you can use chmod -R 777 /home/xxx/images
no permission update chevereto from 1.1.4 to1.2.2 ,no update possible: /app/install/update/temp/ path,that is no temp folder in /app/install/update/ under version 1.2.0,you can mkdir temp and then chmod -R 777 ./temp and then refresh the webpage ,the prics bed will update successfully
So , you can use ip address to visit your chevereto . However , we usually use domain name such as example.com to visit web, a https isn ecessary as well
1.Use aliyun to apply a free ssl license for a domain name such as pics.example.com
2.Download pem and keys to your server and put it in nginx conf folder
That‘s my story that building pics bed ,and hope to help you.
2020-09-28 append
use picgo,upload pictures in typora to chevereto
GitHub download picgo,mac use .dmp,and then install it
open 插件设置,search chevereto and install chevereto 1.0.0
Open 图床设置>Chevereto Uploader and put in params,
Url is your upload service ip/domain
Key is chevereto api in Dashboard>Settings>API>API v1 key
param is not in use now
1 2
Url:https://example.com/api/1/upload Key:xxx
Click 确定 and 设为默认图库
make sure server is on PicGo设置>设置Server>点击设置,if it is on ,noting should be done
and then we modify config in typaro
Open Typora and open ‘preferences>Images`
Choose Upload images in when Insert and check apply above rules to local images and apply above rules to online images in option, and I suggest you check both of them to approve all pics managed by chevereto
Choose PicGo.app in images Uploader and click Test Uploader to test your upload pictures automatically
--name containername -e RABBITMQ_DEFAULT_USER 参数用户名,密码同理 -p 端口映射,主机:容器,15672-UI,5672-service rabbitmq:management image's name
2.Usage
1.open chrome and input ‘localhost:15672’ or ‘192.168.1.1:15672’ then you can touch rabbitmq UI
Overview–the queued msg, msg rate in your server, some global counts, your nodes stats (if u use the above method,you only see one node in the screen ),you also can build a cluster with more nodes
Connections–
Channels–
Exchanges–direct,fanout,headers,match,trace,topic
Queses–
Admin–users management with passport && permission
if (mode == UV_RUN_ONCE) { /* UV_RUN_ONCE implies forward progress: at least one callback must have * been invoked when it returns. uv__io_poll() can return without doing * I/O (meaning: no callbacks) when its timeout expires - which means we * have pending timers that satisfy the forward progress constraint. * * UV_RUN_NOWAIT makes no guarantees about progress so it's omitted from * the check. */ // UV_RUN_ONCE 至少有一个回调执行,不然该循环就空转了,满足前进要求 // 这也是[文章](https://zehai.info/2020/04/10/2020-04-10-eventloop/)中写到: // poll为空,eventloop将检查timer是否有快到的,如果需要执行,eventloop将要进入timers阶段来顺序执行timer callback uv__update_time(loop); uv__run_timers(loop); }
r = uv__loop_alive(loop); if (mode == UV_RUN_ONCE || mode == UV_RUN_NOWAIT) break; }
/* The if statement lets gcc compile it to a conditional store. Avoids * dirtying a cache line. */ if (loop->stop_flag != 0) loop->stop_flag = 0;
// 不行了,看不懂了 voiduv__io_poll(uv_loop_t* loop, int timeout){ structpollfd events[1024]; structpollfd pqry; structpollfd* pe; structpoll_ctl pc; QUEUE* q; uv__io_t* w; uint64_t base; uint64_t diff; int have_signals; int nevents; int count; int nfds; int i; int rc; int add_failed;
if (loop->nfds == 0) { assert(QUEUE_EMPTY(&loop->watcher_queue)); return; }
add_failed = 0; if (w->events == 0) { pc.cmd = PS_ADD; if (pollset_ctl(loop->backend_fd, &pc, 1)) { if (errno != EINVAL) { assert(0 && "Failed to add file descriptor (pc.fd) to pollset"); abort(); } /* Check if the fd is already in the pollset */ pqry.fd = pc.fd; rc = pollset_query(loop->backend_fd, &pqry); switch (rc) { case-1: assert(0 && "Failed to query pollset for file descriptor"); abort(); case0: assert(0 && "Pollset does not contain file descriptor"); abort(); } /* If we got here then the pollset already contained the file descriptor even though * we didn't think it should. This probably shouldn't happen, but we can continue. */ add_failed = 1; } } if (w->events != 0 || add_failed) { /* Modify, potentially removing events -- need to delete then add. * Could maybe mod if we knew for sure no events are removed, but * content of w->events is handled above as not reliable (falls back) * so may require a pollset_query() which would have to be pretty cheap * compared to a PS_DELETE to be worth optimizing. Alternatively, could * lazily remove events, squelching them in the mean time. */ pc.cmd = PS_DELETE; if (pollset_ctl(loop->backend_fd, &pc, 1)) { assert(0 && "Failed to delete file descriptor (pc.fd) from pollset"); abort(); } pc.cmd = PS_ADD; if (pollset_ctl(loop->backend_fd, &pc, 1)) { assert(0 && "Failed to add file descriptor (pc.fd) to pollset"); abort(); } }
w->events = w->pevents; }
assert(timeout >= -1); base = loop->time; count = 48; /* Benchmarks suggest this gives the best throughput. */
for (;;) { nfds = pollset_poll(loop->backend_fd, events, ARRAY_SIZE(events), timeout);
/* Update loop->time unconditionally. It's tempting to skip the update when * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the * operating system didn't reschedule our process while in the syscall. */ SAVE_ERRNO(uv__update_time(loop));
if (nfds == 0) { assert(timeout != -1); return; }
if (nfds == -1) { if (errno != EINTR) { abort(); }
if (timeout == -1) continue;
if (timeout == 0) return;
/* Interrupted by a signal. Update timeout and poll again. */ goto update_timeout; }
if (w == NULL) { /* File descriptor that we've stopped watching, disarm it. * * Ignore all errors because we may be racing with another thread * when the file descriptor is closed. */ pollset_ctl(loop->backend_fd, &pc, 1); continue; }
/* Run signal watchers last. This also affects child process watchers * because those are implemented in terms of signal watchers. */ if (w == &loop->signal_io_watcher) have_signals = 1; else w->cb(loop, w, pe->revents);
nevents++; }
if (have_signals != 0) loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN);
//lib/internal/process/task_queues.js // `nextTick()` will not enqueue any callback when the process is about to // exit since the callback would not have a chance to be executed. // 意思就是nextTick在进程快要结束时不会排队callback,因为没有机会执行 // 你们看引用的文档吧,我看不下去了😭 // 主要的思路是JS执行process.nexTick(),然后将callback交给c++执行 functionnextTick(callback) { if (typeof callback !== 'function') thrownewERR_INVALID_CALLBACK(callback);
This phase allows a person to execute callbacks immediately after the poll phase has completed. If the poll phase becomes idle and scripts have been queued with setImmediate(), the event loop may continue to the check phase rather than waiting.
setImmediate() is actually a special timer that runs in a separate phase of the event loop. It uses a libuv API that schedules callbacks to execute after the poll phase has completed.
Generally, as the code is executed, the event loop will eventually hit the poll phase where it will wait for an incoming connection, request, etc. However, if a callback has been scheduled with setImmediate() and the poll phase becomes idle, it will end and continue to the check phase rather than waiting for poll events.
fs.readFile 的回调函数执行完后:
注册 setTimeout 的回调函数到 timer 阶段
注册 setImmediate 的回调函数到 check 阶段
event loop 从 pool 阶段出来继续往下一个阶段执行,恰好是 check 阶段,所以 setImmediate 的回调函数先执行
TypeError: Chaining cycle detected for promise #<Promise> at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:667:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:607:3
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.
Examples:
s = "leetcode" return 0.
s = "loveleetcode", return 2. Note: You may assume the string contain only lowercase letters.
solution
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/** * @param {string} s * @return {number} */ var firstUniqChar = function(s) { for(var i=0;i<s.length;i++){ var flag = false; for(var j=0;j<s.length;j++){ if(i==j)continue; if(s[i]==s[j])flag=true; } if(!flag)return i; } return -1; };
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
class Solution { public int firstUniqChar(String s) { HashMap<Character, Integer> count = new HashMap<Character, Integer>(); int n = s.length(); // build hash map : character and how often it appears for (int i = 0; i < n; i++) { char c = s.charAt(i); count.put(c, count.getOrDefault(c, 0) + 1); } // find the index for (int i = 0; i < n; i++) { if (count.get(s.charAt(i)) == 1) return i; } return -1; } }