小编Xia*_*lin的帖子

用于更改postgresql用户密码的bash脚本

我可以用这种方式更改postgresql用户密码(2个步骤):

$ su - postgres -c 'psql -U postgres -d postgres'
# Alter user postgres with password 'password';
Run Code Online (Sandbox Code Playgroud)

现在我想使用单行命令(1步)来更改密码,例如:

su - postgres -c 'psql -U postgres -d postgres -c "alter user postgres with password ''password'';"'
Run Code Online (Sandbox Code Playgroud)

我听说使用双单引号来逃避单引号所以我添加了双引号'.但是显示错误消息:

ERROR:  syntax error at or near "password"
LINE 1: alter user postgres with password password;
Run Code Online (Sandbox Code Playgroud)

有人能让我知道如何使用一行命令来做到这一点吗?

postgresql bash shell command

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

ffmpeg捕获当前帧并覆盖图像输出文件

我试图每秒从RTSP流URL中提取图像文件(也可能每1分钟)并覆盖此图像文件.

我的下面的代码工作,但它输出到多个图像jpg文件: img1.jpg, img2.jpg, img3.jpg...

ffmpeg -i rtsp://IP_ADDRESS/live.sdp -f image2 -r 1 img%01d.jpg
Run Code Online (Sandbox Code Playgroud)

如何在Linux中使用ffmpeg或bash脚本来覆盖相同的图像文件,同时连续提取图像的频率不高,比如1分钟或10秒?

bash ffmpeg

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

Mediawiki在新窗口中打开外部链接

我想在Mediawiki中的新窗口函数中启用打开外部链接.我试图根据以下说明修改"LocalSettings.php"文件:

http://www.mediawiki.org/wiki/Manual:Opening_external_links_in_a_new_window
Run Code Online (Sandbox Code Playgroud)

但我仍然无法让它发挥作用.当我在上面的链接"讨论"维基页面中查找时,我发现了更多困扰我的信息.知道如何以简单直接的方式设置这项工作吗?

mediawiki

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

Heatmap.js可点击按钮

我使用Heatmap.js创建一个带有按钮的热图.单击按钮可以正确显示我的热图,但chrome js控制台中有一条错误消息.

我的代码:

$(document).ready(function() {
var mapOptions = ...
var myLatlng = ...
var map = new google...

$('button#toggleTca').click(function(){
        drawHeatmap();
    });

  function drawHeatmap() {
        // heatmap layer
        heatmap = new HeatmapOverlay(map, 
        {
            // radius should be small ONLY if scaleRadius is true (or small radius is intended)
            "radius": 0.00005,
            "maxOpacity": 1, 
            // scales the radius based on map zoom
            "scaleRadius": true, 
            // if set to false the heatmap uses the global maximum for colorization
            // if activated: uses …
Run Code Online (Sandbox Code Playgroud)

jquery onclick heatmap

5
推荐指数
0
解决办法
684
查看次数

Mongoose 使用通配符查询 Where 子句

我有一个猫鼬查询如下

Computer
    .find()
    .where('OS').equals('Windows')
    .exec(function(err, items) {

  });
Run Code Online (Sandbox Code Playgroud)

它返回操作系统的所有computer记录Windows

现在我想用一个变量 osType来替换equals参数更灵活。

*可以为osType变量提供通配符吗?我测试了它,它不起作用。

var osType = '*';

Computer
    .find()
    .where('OS').equals(osType)
    .exec(function(err, items) {

  });
Run Code Online (Sandbox Code Playgroud)

或者有什么替代方法可以实现这一目标?

请不要删除该where条款,因为我希望它用于osType=windows, linux ...等......

javascript mongoose node.js

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

Postgresql 将选择查询分配给函数中的变量

我正在使用 Postgresql 9.3 并编写了一个函数,如下所示:

    create or replace function test(building text,floor text) returns void as $$
    Declare
    id integer;
    num integer := 0;
    Begin

    num=num+100

    id :=select to_number(
          (select 
              (select code from buildings where name=building) || floor 
              || (select num::text)),'99999999'
    );

    update table set col1=id;

    End;
    $$
    language plpgsql;
Run Code Online (Sandbox Code Playgroud)

我想到的是,我的id变量将被分配一个数值example: 12502100select to_number(...)查询。

但是我收到以下错误

ERROR:  syntax error at or near ":="
LINE 10: source :=(select code from buildings where name='I3')
Run Code Online (Sandbox Code Playgroud)

如何将查询结果(带有一些字符串操作)分配到变量 id 中?

我的Select Into …

postgresql variables function

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

如何使用awk将列插入CSV文件

我想使用sed将一些列添加到具有默认值的下面的csv文件中.

我的文件是这样的:

40,2012-05-30,London,61,Sunny
41,2012-02-22,Moscow,11,Snow
54,2012-04-10,Tokyo,02,Sunny
Run Code Online (Sandbox Code Playgroud)

我希望输出为:

40,2012-05-30,NULL,London,NULL,NULL,61,Sunny,Tom
41,2012-02-22,NULL,Moscow,NULL,NULL,11,Sunny,Tom
54,2012-04-10,NULL,Tokyo,NULL,NULL,02,Sunny,Tom
Run Code Online (Sandbox Code Playgroud)

获得所需输出的最佳sed或awk命令是什么?

csv awk sed

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

VI从一行到另一行替换或删除第一个字符

在vi中,如果是指定的字符,如何从第一行替换或删除第一个字符#.

line 1
...
...
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
#   fastcgi_split_path_info ^(.+\.php)(/.+)$;
#   # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
#   # With php5-cgi alone:
#   fastcgi_pass 127.0.0.1:9000;
#   # With php5-fpm:
#   fastcgi_pass unix:/var/run/php5-fpm.sock;
#   fastcgi_index index.php;
#   include fastcgi_params;
#}
...
end of line
Run Code Online (Sandbox Code Playgroud)

vi vim

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

标签 统计

bash ×2

postgresql ×2

awk ×1

command ×1

csv ×1

ffmpeg ×1

function ×1

heatmap ×1

javascript ×1

jquery ×1

mediawiki ×1

mongoose ×1

node.js ×1

onclick ×1

sed ×1

shell ×1

variables ×1

vi ×1

vim ×1