Skip to content

Instantly share code, notes, and snippets.

@dingyaguang117
dingyaguang117 / pdfformfiller.go
Last active October 18, 2022 20:01
Fill pdf form with pdfcpu
View pdfformfiller.go
package render
import (
"bytes"
"fmt"
"math"
"github.com/pdfcpu/pdfcpu/pkg/api"
"github.com/pdfcpu/pdfcpu/pkg/pdfcpu"
"github.com/pdfcpu/pdfcpu/pkg/pdfcpu/validate"
@dingyaguang117
dingyaguang117 / yearning_token_refresh.js
Created April 5, 2021 09:38
Yearning Token 过期刷 新油猴脚本
View yearning_token_refresh.js
// ==UserScript==
// @name Yearning 自动刷新 Token
// @description 自动刷新 Yearning Token, 测试于 Yearning 2.1.6
// @author Yaguang Ding
// @namespace https://yearning.yourcompany.com/
// @version 0.1
// @include https://yearning.yourcompany.com/*
// @content self
// @require tampermonkey://vendor/jquery.js
// @grant GM_notification
View gist:c81fc1e0ee7cd28aa843292e4bfbfbca
root@xx:~/data# iptables -L
Chain INPUT (policy DROP)
target prot opt source destination
ufw-before-logging-input all -- anywhere anywhere
ufw-before-input all -- anywhere anywhere
ufw-after-input all -- anywhere anywhere
ufw-after-logging-input all -- anywhere anywhere
ufw-reject-input all -- anywhere anywhere
ufw-track-input all -- anywhere anywhere
View xpath syntax
1. 获取后面的节点
//div[@class="drop-features"]/following-sibling::p/text()
2. lxml 节点tostring
from lxml import etree
etree.tostring(Element)
@dingyaguang117
dingyaguang117 / gist:74dbe459a2b31e2e5213
Created December 12, 2015 10:45
ubuntu 使用dm-crypt 加密目录,并且开机自动加载
View gist:74dbe459a2b31e2e5213
=========== 文件磁盘========
---- init ----
#安装依赖
sudo apt-get install cryptsetup
#虚拟磁盘并格式化
sudo fallocate -l 512M /root/home
sudo cryptsetup -y luksFormat /root/home
View gevent-pool-requests.py
#coding=utf-8
__author__ = 'ding'
from gevent import monkey
monkey.patch_all()
from gevent.pool import Pool
import requests
sites = [u'0i4t.com', u'0757dk.com', u'0007ka.com', u'003782.com', u'0735.com', u'04336789.com', u'078078.com', u'0851qy.com', u'008321.com', u'0427d7.se', u'010sf.com', u'0476com.com', u'0470a.com', u'0163.com', u'00992.com', u'0759job.com', u'0437t.com', u'057191.com', u'0932.info', u'0311xinhua.cn', u'041pao.com', u'009997.com', u'018tk.com', u'099cf.com', u'0576qq.com', u'0101010.info', u'001lv.org', u'0771pc.com', u'0734kj.com', u'076665.cn', u'001123.com', u'08kkkk.com', u'0416hlw.com', u'0452e.com', u'001ni.com', u'001dd.com', u'012666.com', u'010tk.com', u'0579h.com', u'0851yifu.com', u'06049.com', u'044944.com', u'0752oa.net', u'003003.net', u'050gg.com', u'02325.org', u'0744y.com', u'0523114.com', u'0449aa.com', u'0597house.com', u'0411house.com', u'099333.com', u'001lv.com', u'050q.com', u'067.cc', u'02kkk.com', u'050ww.com', u'0437.gov.cn', u'073311.com', u'024www.net', u'0
View nginx.conf
# 把形如 /article/ 变成 /article/index.php
location ~ ^/article[^.]*/$
{
rewrite ^(.*)$ $1index.php last;
}
# 之所以没有用$fastcgi_script_name是因为,$fastcgi_script_name会带上/article前缀,导致404,所以我自己获取了脚本的路径
# 应该有更正确的方式去掉/article?
location ~ ^/article/(.*)$ {
alias /usr/local/nginx-1.6.2/html/wordpress/;
View sqlalchemy
__author__ = 'ding'
from sqlalchemy import Column, Sequence, ForeignKey
from sqlalchemy.types import CHAR, Integer, String, DateTime
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from webservice.conf import mysql_engine
BaseModel = declarative_base()
@dingyaguang117
dingyaguang117 / gist:7110990
Created October 23, 2013 01:26
cap deploy出错
View gist:7110990
capify .
cap -v
@dingyaguang117
dingyaguang117 / gist:7097992
Created October 22, 2013 09:53
Java图片裁剪合并
View gist:7097992
/*
* 2012/12/11
* ding
* */
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;