落絮飞雁

顺流而下,把梦做完

邮品收藏搭建笔记:Piwigo图片站

精力有限,又加上要考虑到之后的扩展性(如果采用扫描仪来录入整张明信片势必会导致图片大小成倍增加,到时必须采用CDN等等)。初步打算先用piwigo软件来管理这些戳片。

piwigo是一款开源的在线相册软件,支持通过标签来进行分类。对邮戳整理起来也比较方便。而且piwigo扩展性比较强,用户数量也比较大。查wiki问社区也会方便的多。


安装

piwigo的安装方法十分简单,下载解压设置好数据库即可完成。稍加配置,图片站就部署完成了。
随后可以通过web、软件或者FTP的方式来上传图片,非常方便。

需要注意的是,piwigo需要GD库依赖,而PHP5安装是默认是没有添加的。因此需要手动安装。
缺少GD库会出现缩略图不能生成的问题。

TODO

随着图片数量的增加,势必要添加CDN或图床。
除此之外,如何添加水印也是一个问题。尽管piwigo默认自带水印功能,但不支持按比例裁剪水印。导致缩略图中水印过大,而原图中水印过小的问题。

POJ3279:Fliptile——搜索、开关问题

约翰又来折腾牛了……
READ MORE →

POJ3276:Face The Right Way——开关问题、简单DP

牛头人约翰和牛的故事。
READ MORE →

OpenWRT设置访客网络

设置访客网络,保护内网安全。
READ MORE →

VPS建站的安全措施

提高网站安全性,避免站点被黑。
READ MORE →

普通用户如何设置SSH密钥访问

普通用户建立SSH密钥实现无密码登陆

VPS操作中更加推荐使用普通用户登录SSH(避免root远程登陆),但直接设置会造成权限问题(尤其是之前配置过root用户使用密钥认证)。本文简单介绍普通用户配置SSH密钥访问的方法,具体原理请参加末尾参考部分。


 

首先建立普通用户并设置密码(推荐使用密码生成工具生成高强度密码)

建立用户

useradd lxfy

生成密码

passwd lxfy

随后在root身份下创立普通用户ssh文件夹

mkdir -m 777 /home/lxfy/.ssh

切换回普通用户,并生成公钥私钥。
略~
导入公钥到authorized_keys

cat id_rsa.pub > authorized_keys

修改权限

chmod 600 ~/.ssh/authorized_keys

删除公钥私钥

rm -rf id_rsa.pub
rm -rf id_rsa

重启SSH服务即可~

参考文章:
普通用户如何设置SSH无密码访问
SSH keys (简体中文) Archwiki

HDOJ1733:Escape——网络流分层图

该来的总是会来的,写一道最头痛的网络流问题。
READ MORE →

HDOJ2127:Polish notation——表达式转换

Problem Description
Reverse Polish notation (RPN) is a method for representing expressions in which the operator symbol is placed after the arguments being operated on.
Polish notation, in which the operator comes before the operands, was invented in the 1920s by the Polish mathematician Jan Lucasiewicz.
In the late 1950s, Australian philosopher and computer scientist Charles L. Hamblin suggested placing the operator after the operands and hence created reverse polish notation.

RPN has the property that brackets are not required to represent the order of evaluation or grouping of the terms.
RPN expressions are simply evaluated from left to right and this greatly simplifies the computation of the expression within computer programs.
As an example, the arithmetic expression (3+4)*5 can be expressed in RPN as 3 4 + 5 *.

Reverse Polish notation, also known as postfix notation, contrasts with the infix notation of standard arithmetic expressions in which the operator symbol appears between the operands. So Polish notation just as prefix notation.

Now, give you a string of standard arithmetic expressions, please tell me the Polish notation and the value of expressions.

Input
There’re have multi-case. Every case put in one line, the expressions just contain some positive integers(all less than 100, the number of integers less than 20), bi-operand operators(only have 3 kinds : +,-,*) and some brackets'(‘,’)’.
you can assume the expressions was valid.

Output
Each case output the Polish notation in first line, and the result of expressions was output in second line.
all of the answers are no any spaces and blank line.the answer will be not exceed the 64-signed integer.

Sample Input
1+2-3*(4-5)
1+2*(3-4)-5*6

Sample Output
Case 1:
– + 1 2 * 3 – 4 5
6
Case 2:
– + 1 * 2 – 3 4 * 5 6
-31

题目考察表达式的转换将中缀表达式转换成前置表达式(波兰式),并计算出结果。可以直接套模板……需要注意表达式中空格的位置;字符串需要用__int64存贮。

关于前置表达式和后置表达式的转换方法可以参考这篇博文:波兰式、逆波兰式与表达式求值

参考代码:

#include 
#include 
#include 
using namespace std;

char stack[500];                    
int top;                        //栈顶指针       
char output[500], input[500];        
int outLen;

int priority(char op)           //定义运算符优先级     
{
    if (op=='+' || op=='-')
        return 1;
    if (op=='*' || op=='/')
        return 2;
    else
        return 0;
}

bool isOperator(char op)                
{
    return (op=='+' || op=='-' || op=='*' || op=='/');
}

void Polish(char *s,int len)            
{
    memset(output,'\0',sizeof output);    
    outLen = 0;
    for (int i=len-1; i >= 0; --i)        
    {
        if (isdigit(s[i]))                
        {
            output[outLen++] = s[i];    
            while (i-1 >= 0 && isdigit(s[i-1]))
            {
                output[outLen++] = s[i-1];
                --i;
            }
            output[outLen++] = ' ';        
        }
        if (s[i]==')')                    
        {
            ++top;
            stack[top] = s[i];
        }
        while (isOperator(s[i]))        
        {                                                
            if (top==0 || stack[top]==')' || priority(s[i]) >= priority(stack[top])) 
            {
                ++top;
                stack[top] = s[i];
                break;
            }
            else
            {
                output[outLen++] = stack[top];
                output[outLen++] = ' ';
                --top;
            }
        }
        if (s[i]=='(')                    
        {
            while (stack[top]!=')')
            {
                output[outLen++] = stack[top];
                output[outLen++] = ' ';
                --top;
            }
            --top;    
        }
    }
    while (top!=0)                        
    {
        output[outLen++] = stack[top];
        output[outLen++] = ' ';
        --top;
    }
}

char DstBuf[200];
char* OP(char* op1,char* op2,char op)
{
    __int64 res = 0;
    if (op=='+')
        res = _atoi64(op1) + _atoi64(op2);
    else if (op=='-')
        res = _atoi64(op1) - _atoi64(op2);
    else if (op=='*')
        res = _atoi64(op1) * _atoi64(op2);
    else if (op=='/')
        res = _atoi64(op1) / _atoi64(op2);
    _i64toa(res,DstBuf,10);
    return DstBuf;
}

char cSt1[200][80], cSt2[200][80];
__int64 calc(char *s)                
{
    int top1=0, top2=0, i;
    for (i=0; s[i]; ++i)
    {
        if (s[i] && s[i] != ' ')
        {
            ++top1;
            sscanf(s+i,"%s",cSt1[top1]);        
            while (s[i] && s[i] != ' ')
                ++i;
        }
    }
    while (top1 != 0)    
    {
        if (!isdigit(cSt1[top1][0]))    
        {
            OP(cSt2[top2], cSt2[top2-1], cSt1[top1][0]);
            memcpy(cSt2[top2-1],DstBuf,sizeof DstBuf);
            --top2;                    
            --top1;                        
        }
        else
        {
            ++top2;                        
            memcpy(cSt2[top2],cSt1[top1],sizeof cSt1[top1]);
            --top1;                        
        }
    }
    return _atoi64(cSt2[1]);
}
int main()
{
    int T = 1;
    while (gets(input))
    {
        Polish(input, strlen(input));
        reverse(output,output+outLen-1);
        output[outLen-1] = '\0';
        printf("Case %d:\n%s\n",T++,output);
        printf("%I64d\n",calc(output));//注意要__int64
    }
    return 0;
}

Ubuntu安装postfix的步骤

VPS上安装好WordPress之后,另一件要做的事就是配置邮件传输代理。 READ MORE →

写写VPS上搭建WordPress的注意事项

最近把网站搬到了阿里云。 READ MORE →