小编Bri*_*rns的帖子

在Emacs键映射值中显示键

当我查询keymap的当前值时,例如with M-: (current-local-map),它向我展示了这些内容:

Value: 
(keymap
 (S-mouse-2 . muse-follow-name-at-mouse-other-window)
 (mouse-2 . muse-follow-name-at-mouse)
 (33554445 . muse-follow-name-at-point-other-window)
 (S-return . muse-follow-name-at-point-other-window)
 (13 . muse-follow-name-at-point)
 (return . muse-follow-name-at-point)
 keymap
 (67108924 . muse-decrease-list-item-indentation)
 (67108926 . muse-increase-list-item-indentation)
 (M-return . muse-insert-list-item)
 (33554441 . muse-previous-reference)
 (S-iso-lefttab . muse-previous-reference)
 (S-tab . muse-previous-reference)
 (S-mouse-2 . muse-follow-name-at-mouse-other-window)
 (mouse-2 . muse-follow-name-at-mouse)
 (33554445 . muse-follow-name-at-point-other-window)
 (9 . muse-next-reference)
 (tab . muse-next-reference)
 (3 keymap
    (19 . muse-search)
    (2 . muse-find-backlinks)
    (tab . muse-insert-thing)
    (9 . muse-insert-thing)
    (16 . muse-project-publish)
    (6 . muse-project-find-file)
    (61 . …
Run Code Online (Sandbox Code Playgroud)

emacs elisp

26
推荐指数
5
解决办法
5076
查看次数

在Python中的psycopg2中执行.sql模式

我有一个存储在.sql文件中的PostgreSQL架构.它看起来像:

CREATE TABLE IF NOT EXISTS users (
    id INTEGER PRIMARY KEY,
    facebook_id TEXT NOT NULL,
    name TEXT NOT NULL,
    access_token TEXT,
    created INTEGER NOT NULL
);
Run Code Online (Sandbox Code Playgroud)

连接数据库后如何运行此模式?

我现有的Python代码适用于SQLite数据库:

# Create database connection
self.connection = sqlite3.connect("example.db")

# Run database schema
with self.connection as cursor:
    cursor.executescript(open("schema.sql", "r").read())
Run Code Online (Sandbox Code Playgroud)

但是psycopg2 executescript在光标上没有方法.那么,我怎样才能做到这一点?

python postgresql schema psycopg2

22
推荐指数
2
解决办法
2万
查看次数

如何从gmaps RECTANGLE(Overlay)获取4个顶点坐标?

如何从gmaps RECTANGLE(Overlay)获得4个顶点坐标?

我只能得到NE和SW lat selectedShape.getBounds()

我需要一个4顶点矩形来进行MySQL php函数的后期处理检查.

javascript google-maps

21
推荐指数
1
解决办法
7958
查看次数

如何使用Firebase存储将"直接链接"存储到图像

我需要通过直接链接访问存储在Firebase存储上的图像,例如

http://myfirebasehost.com/storage/imgIwant.png
Run Code Online (Sandbox Code Playgroud)

据我所知,它只能使用协议的这种类型的URL gs://,但是,它不能通过链接访问,只能在SDK api中访问.

我需要一个完全如上所述的使用Firebase平台的解决方案,如果不可能,接受其他建议.

我的代码有常量,是指向图像的链接.事实证明,如果我想更新这张图片,我必须进行新的部署.相反,我想在同一个URL更新图像.使用firebase(据我所知)这是不可能的,因为Storage提供的URL不能通过链接访问.

另一种方法是将图像转换为Base64并存储在数据库中,但将是非常广泛的和不切实际的.

firebase firebase-storage

19
推荐指数
4
解决办法
1万
查看次数

Angular 4无法绑定到<property>,因为它不是<component>的已知属性

我正在尝试在Angular 4中创建自己的指令.但是,当将类的属性绑定到组件模板时,我得到了这个错误.

控制台错误:

Unhandled Promise rejection: Template parse errors: Can't bind to
'data' since it isn't a known property of 'tree'. ("<tree [ERROR
->][data]="data"></tree>"):
Run Code Online (Sandbox Code Playgroud)

我的tree-view-component.ts:

@Component({
    selector: 'app-tree-view',
    template: '<tree [data]="data"></tree>'
})
export class TreeViewComponent implements OnInit {

    @Input() data: any[];

    constructor() {
        this.data = [
        {
            label: 'a1',
            subs: [
                {
                    label: 'a11',
                    subs: [
                        {
                            label: 'a111',
                            subs: [
                                {
                                    label: 'a1111'
                                },
                                {
                                    label: 'a1112'
                                }
                            ]
                        },
                        {
                            label: 'a112'
                        }
                    ]
                },
                {
                    label: 'a12', …
Run Code Online (Sandbox Code Playgroud)

typescript angular2-directives angular

16
推荐指数
2
解决办法
3万
查看次数

next-auth 中弹出登录

是否可以在下一个身份验证的弹出窗口中进行社交登录?或者只能重定向到提供商身份验证页面?

我这样问是因为我不想在重定向到提供程序页面后丢失所有应用程序状态。

我不想将内容保存在数据库或浏览器存储中。


export default NextAuth({
  // Configure one or more authentication providers
  providers: [
    Providers.Facebook({
      clientId: process.env.FACEBOOK_ID,
      clientSecret: PROCESS.ENV.FACEBOOK_SECRET
    }),
    Providers.Google({
      clientId: process.env.GOOGLE_ID,
      clientSecret: process.env.GOOGLE_SECRET,
      authorizationUrl: 'https://accounts.google.com/o/oauth2/v2/auth?prompt=consent&access_type=offline&response_type=code',
    }),
    Providers.Credentials({
      name: "credentials",
      async authorize(credentials, req) {
        const user = { email: req.body.email }
        return user
      },
    }),
    // ...add more providers here
  ],
  jwt: {
    signingKey: process.env.SIGNINING_KEY,
  },
  callbacks: {
    async signIn(user, account) {
      const { name, email } = user;
      const { provider } = account
  
      try {
        
        
        // …
Run Code Online (Sandbox Code Playgroud)

oauth reactjs next.js next-auth

15
推荐指数
2
解决办法
6963
查看次数

使用Python Imaging Library(PIL),如何使用alpha通道组合图像而不是另一个图像?

我有两个图像,都有alpha通道.我想将一个图像放在另一个图像上,从而生成带有alpha通道的新图像,就像它们在图层中呈现一样.我想用Python Imaging Library做到这一点,但是其他系统中的建议会很棒,即使原始数学也是一个好处; 我可以使用NumPy.

python image-processing python-imaging-library

14
推荐指数
3
解决办法
2万
查看次数

是否有Python PIL的抗锯齿方法?

对于PIL中的线条和椭圆,图像很粗糙.

我只在resize和缩略图中找到了抗锯齿.

绘制直线或椭圆时有没有办法做抗锯齿?

python antialiasing python-imaging-library

14
推荐指数
2
解决办法
1万
查看次数

如何在Google Maps V3上的每个折线段上绘制箭头

我正在寻找stackoverflow上的这个问题的解决方案,但由于我找不到准确的解决方案,我最终自己解决它并在此发布,希望它有所帮助.

Google地图为您提供折线功能,该功能基于坐标列表可以绘制一系列连接所有线条的线条.

您可以使用以下代码使用单个箭头绘制折线:

     var allCoordinates = [
        new google.maps.LatLng(26.291, 148.027),
        new google.maps.LatLng(26.291, 150.027),
        new google.maps.LatLng(22.291, 153.027),
        new google.maps.LatLng(18.291, 153.027)
    ];

     var polyline = new google.maps.Polyline({
            path: allCoordinates,
            strokeColor: color,
            strokeOpacity: 1.0,
            strokeWeight: 2,
            geodesic: true,
            icons: [{
                icon: {path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW},
                offset: '100%'
            }]
        });
Run Code Online (Sandbox Code Playgroud)

这里的问题是箭头将仅在最后一段中绘制,如下图所示,但有时路线可能不那么简单,我们需要在每个段上添加一个箭头.

图标定义中的"重复"属性可能是另一种选择,但只允许以像素为单位定义度量,并且definelty与折线上的每个方向变化都不匹配.

图片1

因此,我发现实现这一目的的一种方法是制作多条折线,每个线段允许一条线,在这种情况下允许在每条线上绘制箭头.这是代码:

     var allCoordinates = [
        new google.maps.LatLng(26.291, 148.027),
        new google.maps.LatLng(26.291, 150.027),
        new google.maps.LatLng(22.291, 153.027),
        new google.maps.LatLng(18.291, 153.027)
    ];

    for (var i = 0, n = allCoordinates.length; i < n; i++) {

        var coordinates = …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps segment polyline google-maps-api-3

13
推荐指数
1
解决办法
1万
查看次数

当我将测试放在一个单独的目录中时,pytest找不到包

我有一个非常基本的Python包示例和我正在尝试使用pytest运行的测试

package
 \--
   __init__.py
   spam.py
   spam_test.py
Run Code Online (Sandbox Code Playgroud)

__init__.py为空,spam.py定义单个函数func(),spam_test.py并且:

import package.spam

def test_func():
    assert(package.spam.func() == 5)
Run Code Online (Sandbox Code Playgroud)

在我运行的根目录中py.test,一切正常,返回一个通过测试.

以为我也可以用这种方式构建东西:

package
 \--
   __init__.py
   spam.py
tests
 \--
   spam_test.py
Run Code Online (Sandbox Code Playgroud)

但现在当我py.test在根中运行时,我得到:

============================= test session starts =============================
platform win32 -- Python 3.6.0, pytest-3.0.5, py-1.4.32, pluggy-0.4.0
rootdir: C:\Users\MattUser\Documents\m_drive\notebooks\testing, inifile:
collected 0 items / 1 errors

=================================== ERRORS ====================================
_____________________ ERROR collecting tests/spam_test.py _____________________
ImportError while importing test module 'C:\Users\MattUser\Documents\m_drive\not
ebooks\testing\tests\spam_test.py'.
Hint: make sure your test modules/packages …

pytest python-3.x

11
推荐指数
1
解决办法
3867
查看次数