NextJS添加图片弹窗提示

首先安装 npm i reactjs-popup

代码如下:

import React from ‘react’;
import Popup from ‘reactjs-popup’;
import ‘reactjs-popup/dist/index.css’;

export default function PopupGfg(){
return(
<div>
<h4>NextJs Popup</h4>
<Popup trigger={<button> Click to open popup </button>}
position=”right center”>
<div>GeeksforGeeks</div>
<Link href=”#”>{<Image src=”/myalipay.jpg” width={300} height={400} alt=”banner”/>}</Link>
</Popup>
</div>
)
};

 

注: Position Enums: ‘top left’ ‘top right’ ‘bottom right’ ‘bottom left’ ‘right center’ ‘left center’ ‘top center’ ‘bottom center’ ‘center center’

Rails 内存占满

最近搭建一个rss feed管理的rails应用,在使用一段时间后内存差不多就占满,就是pumasidekiq这两个进程占用。一种比较灵活的方式,使用像puma_worker_killer这样的监控程序,监控rails进程达到一定内存占用后将其重启,但这样使用体验不好。

由于ruby使用glibcmalloc进行内存分配,这是一个比较老旧的内存分配器,性能比较低分配时会产生大量碎片,所以切换jemalloc做为Ruby应用的内存分配器

# ruby -v

ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]

#apt-get install libjemalloc-dev

#apt-get install libcurl4 libcurl4-openssl-dev

# rvm reinstall 2.6.3 -C –with-jemalloc

python3包urllib和requests的变化

 

 

json_data = {
‘response_type’: ‘code’,
‘username’: ‘username’,
‘password’: ‘password’}

requests.post(‘https:/xxx/v1/api/users/token’), json=auth_data, params=auth_data)
#其中json,params参数都得填写json格式数据

 
import urllib
import urllib.request
urllib.request.urlopen(“https://www.baidu.com”).read().decode(‘utf-8’)
#记得导入urllib.request

ScalaPB生成scala的protobuf文件

环境: sbt, scala 2.10.4

 

1.

vi project/scalapb.sbt

addSbtPlugin(“com.thesamet” % “sbt-protoc” % “0.99.1”)

libraryDependencies += “com.trueaccord.scalapb” %% “compilerplugin” % “0.5.43”

 

2.

vi build.sbt

PB.targets in Compile := Seq(
scalapb.gen() -> (sourceManaged in Compile).value
)

// If you need scalapb/scalapb.proto or anything from google/protobuf/*.proto
//ScalaPB looks for protocol buffer files in src/main/protobuf, but this can be customized. Running the compile command in sbt will both generate Scala sources from your protos and compile them.

libraryDependencies += “com.trueaccord.scalapb” %% “scalapb-runtime” % com.trueaccord.scalapb.compiler.Version.scalapbVersion % “protobuf”

 

3.
mkdir src/main/protobuf

vi src/main/protobuf/hello.proto

syntax = “proto3”;
package example;

message HelloRequest {
string name = 1;
}

sbt assembly
生成的scala文件放在 target/scala-2.10/src_managed/main/example/hello/HelloRequest.scala

4.

使用如下
import hello._

val h = HelloRequest().withName(“hq”)
val hba = h.toByteArray
println(hba) //serialize
println(HelloRequest.parseFrom(hba).name) //unserialize

Clojure运行环境在windows上安装

环境:windows 7

有时需要在windows上环境上编写clojure代码,因此需要在这个环境上安装clojure运行环境

方法一:

1. 首先安装curl工具

2. 从https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein.bat 下载文件lein.bat

3. 设置环境变量
set HTTP_CLIENT=curl –proxy-ntlm –insecure -f -L -o
set HTTPS_PROXY=

3. 安装 lein.bat self-install

4. 进入交互环境
lein new project_name
lein.bat repl

方法二:

1. 直接下载clojure-x.x.x.jar文件

2. 启动交互环境
java -jar clojure-x.x.x.jar