小编far*_*jad的帖子

如何在node.js模块中实现继承?

我正在编写nodejs应用程序.它基于expressjs.我对在nodejs模块中进行继承感到困惑.我想要做的是创建一个模型基类,让我们说my_model.js.

module.exports = function my_model(){
  my_model.fromID = function(){
    //do query here
  }
}
Run Code Online (Sandbox Code Playgroud)

现在我想在我的其他模型类中的my_model中使用这些方法.让我们说user_model.js如何在user_model中继承my_model?

node.js

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

帮助我进行XOR加密

我写了这段代码C#用密钥加密字符串:

private static int Bin2Dec(string num)
{
    int _num = 0;

    for (int i = 0; i < num.Length; i++)
        _num += (int)Math.Pow(2, num.Length - i - 1) * int.Parse(num[i].ToString());

    return _num;
}

private static string Dec2Bin(int num)
{
    if (num < 2) return num.ToString();

    return Dec2Bin(num / 2) + (num % 2).ToString();
}

public static string StrXor(string str, string key)
{
    string _str = "";
    string _key = "";
    string _xorStr = "";
    string _temp = ""; …
Run Code Online (Sandbox Code Playgroud)

c# encryption encryption-symmetric

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

如何使用ZwQueryInformationProcess在内核驱动程序中获取ProcessImageFileName?

我正在为我的应用程序编写一个简单的内核驱动程序(想想一个非常简单的反恶意软件应用程序.)

我已经迷上了ZwOpenFile()并且习惯于PsGetCurrentProcess()获得调用者进程的句柄.

它返回一个PEPROCESS结构:

PEPROCESS proc = PsGetCurrentProcess();
Run Code Online (Sandbox Code Playgroud)

我使用ZwQueryInformationProcess()来获取PIDImageFileName:

DbgPrint("ZwOpenFile Called...\n");
DbgPrint("PID: %d\n", PsGetProcessId(proc));
DbgPrint("ImageFileName: %.16s\n", PsGetProcessImageFileName(proc));
Run Code Online (Sandbox Code Playgroud)

并尝试以FullPath这种方式获得过程(但我得到了BSOD):

WCHAR strBuffer[260];
UNICODE_STRING str;

//initialize
str.Buffer = strBuffer;
str.Length = 0x0;
str.MaximumLength = sizeof(strBuffer);

//note that the seconds arg (27) is ProcessImageFileName
ZwQueryInformationProcess(proc, 27, &str, sizeof(str), NULL);

DbgPrint("FullPath: %wZ\n", str.Buffer);
Run Code Online (Sandbox Code Playgroud)

DbgView输出

如你所见,str.Buffer是空的或充满垃圾.填充str通道时缓冲区溢出可能ZwQueryInformationProcess()会触发BSOD.

替代文字

任何帮助,将不胜感激.

c++ hook driver wdk

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

express.js路线说明

我正在查看源代码,以了解它如何将命名的路由参数映射到req.params属性.

对于那些不知道的人,在express.js中你可以用命名参数定义路由,使它们成为可选的,只允许具有特定格式的路由(以及更多):

app.get("/user/:id/:name?/:age(\\d+)", function (req, res) {
    console.log("ID is", req.params.id);
    console.log("Name is", req.params.name || "not specified!");
    console.log("Age is", req.params.age);
});
Run Code Online (Sandbox Code Playgroud)

我意识到这个功能的核心是一个pathRegexp()lib/utils.js中定义的方法.方法定义如下:

function pathRegexp(path, keys, sensitive, strict) {
    if (path instanceof RegExp) return path;
    if (Array.isArray(path)) path = '(' + path.join('|') + ')';
    path = path
        .concat(strict ? '' : '/?')
        .replace(/\/\(/g, '(?:/')
        .replace(/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?(\*)?/g, function (_, slash, format, key, capture, optional, star) {
            keys.push({ name: key, optional: !! optional });
            slash …
Run Code Online (Sandbox Code Playgroud)

javascript regex node.js express

9
推荐指数
1
解决办法
2437
查看次数

在程序关闭时使用批处理文件更改壁纸.可能?

我正在尝试创建一个批处理文件,该程序将在Windows 7上关闭程序时更改我的背景.我尝试使用它,但它不起作用,即使我注销并重新登录:

@echo off
reg /add HKCU\Control Panel\Desktop\WallPaper /v wallpaper /t REG_SZ /d c:\images\wallpaper.bmp
Run Code Online (Sandbox Code Playgroud)

background batch-file wallpaper windows-7

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

将 docx 文件转换为 WPF 流文档

我正在尝试将一堆Microsoft Word文档(包含几张图片和多行文本和标题)转换为Flow Documents

我发现这篇文章很有用,但我无法将docx文件中的图像正确添加到Flow Documents

示例代码或一些指导将不胜感激。

c# wpf docx flowdocument

5
推荐指数
1
解决办法
8101
查看次数

HTTP状态400 - 必需字符串参数"xx"不存在

我正在尝试制作一个简单的Spring MVC应用程序.

这是我的 HelloController

package com.springapp.mvc;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;


@Controller
@RequestMapping("/")
public class HelloController {
@RequestMapping(method = RequestMethod.GET)
public String printWelcome(ModelMap model,@RequestParam(value = "xx",required
=true)String xx) {

        model.addAttribute("message", "Hello Mahdi");

    return "hello";
}
}
Run Code Online (Sandbox Code Playgroud)

JSP文件:

<html>
<body>
<h1>${message}</h1>
<form action="/" method="GET">
    <input type="text" name="xx">
    <button type="submit">submit</button>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我尝试运行该应用程序时收到以下错误:

HTTP Status 400 - Required String parameter 'xx' is not present
Run Code Online (Sandbox Code Playgroud)

我是Spring MVC的新手,请帮忙.

java jsp spring-mvc

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

如何在div中包装CKEditor内容?

我正在使用CKEditor 4,

为了支持RTL语言(比如波斯语),我需要将其内容包含在一个divwith dir属性设置为rtl:

<div dir="rtl">
    <!-- Content goes here -->
</div>
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.

html javascript jquery ckeditor

3
推荐指数
1
解决办法
1669
查看次数

如何在Mac OS X中监听应用程序启动事件?

我写了一个AppleScript安装SparseBundle图像,我希望它在Time Machine启动时完全执行.

现在,我定期检查Time Machine是否使用AppleScriptusing on idle语句运行:

on idle
    ....
    return <interval>
end idle
Run Code Online (Sandbox Code Playgroud)

这不是一种强有力的方式.在我看来,为Application Launch事件添加事件触发器将是一种更好的方法.

能否请你帮忙?

一个Objective-CPython示例代码(我更喜欢Python)非常受欢迎.

macos pyobjc objective-c

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

在动态加载的第三方程序集中使用静态类

我遇到的情况是我必须在签名的应用程序中使用未签名的第三方.NET DLL.所以我决定在运行时动态加载该库:

var asm = Assembly.LoadFrom("THIRDPARTYASSEMBLY.DLL");
Run Code Online (Sandbox Code Playgroud)

DLL中有一个静态类,我在我的应用程序中定义了一个接口,用于GetUninitializedObject()加载类:

var obj = FormatterServices.GetUninitializedObject(asm.GetType("NAMESPACE.CLASS")) as IMyInterface;
Run Code Online (Sandbox Code Playgroud)

虽然我试图加载的类不是抽象的(它是一个public static类)我在运行时遇到这个错误:

System.MemberAccessException未处理:无法创建抽象类.

显然我不能使用CreateInstance方法,因为静态类没有任何构造函数.

那么你会建议什么?我想要:

  • public static从该库调用方法.(我现在正在使用InvokeMember().)
  • 获得一处Custom Type房产.
  • Custom Events在我的应用程序中处理一些.

提前致谢.

.net c# reflection dll static

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