Skip to content

Instantly share code, notes, and snippets.

View lenconda's full-sized avatar
💻
Working and studying hard

Peng Hanlin lenconda

💻
Working and studying hard
View GitHub Profile
@lenconda
lenconda / index.php
Created July 6, 2017 07:03
这是添加用户的判断语句
if (isset($_POST['submit'])){
if ($_POST['name'] == '') {
echo "<script>alert('非法输入!')</script>";
}elseif ($_POST['pw'] == '') {
echo "<script>alert('非法输入!')</script>";
}elseif ($_POST['repw'] == '') {
echo "<script>alert('非法输入!')</script>";
}elseif ($_POST['pw'] == $_POST['repw']) {
$query = "insert into user (name,pw,role) values('{$_POST['name']}','{$_POST['pw']}','{$_POST['role']}')";
$result=mysqli_query($link, $query);
@lenconda
lenconda / profile.php
Created July 7, 2017 04:15
想要显示中文字符,这段语句相当重要
mysqli_query($link,"set NAMES 'UTF8'");
function getObjectURL(file) {
var url = null;
if (window.createObjectURL != undefined) {
url = window.createObjectURL(file)
} else if (window.URL != undefined) {
url = window.URL.createObjectURL(file)
} else if (window.webkitURL != undefined) {
url = window.webkitURL.createObjectURL(file)
}
return url
@lenconda
lenconda / normalize-advanced.css
Last active April 10, 2018 08:36
魔改的Normalize.css,解决了在移动端字体超大的问题
/*! normalize.css v5.0.0 | MIT License | github.com/necolas/normalize.css */
/**
* 1. Change the default font family in all browsers (opinionated).
* 2. Correct the line height in all browsers.
* 3. Prevent adjustments of font size after orientation changes in
* IE on Windows Phone and in iOS.
*/
/* Document
const baseUrl = window.isDevMode ? '/api' : 'https://os.ncuos.com/api'
// 信息提示框
/**
* @param {any} msg
* @param {any} isSucc
*/
const alertBox = function (msg, isSucc) {
msg = typeof msg !== 'undefined' ? msg : '操作失败'
try {
if (msg.indexOf('permission') >= 0) {
@lenconda
lenconda / get_subdomains.js
Last active December 31, 2018 08:01
获取子域名列表
const superagent = require('superagent');
const cheerio = require('cheerio');
const getSubdomains = (rootDomain) => {
return new Promise((resolve, reject) => {
superagent
.post('https://hackertarget.com/find-dns-host-records/')
.type('form')
.send({ theinput: rootDomain })
.send({ thetest: 'hostsearch' })
@lenconda
lenconda / mysql_mapping.sh
Created January 9, 2019 05:25
通过SSH端口转发将远程MySQL服务器映射到本地
IP=SERVER_ADDRESS
# LOCAL_PORT:IP:SERVER_PORT
ssh -fNg -L 3306:IP:3306 root@IP
@lenconda
lenconda / consumer.js
Created February 8, 2019 03:47
Basic Producer-Consumer model with Node.js and RabbitMQ
const amqp = require('amqp')
const conn = amqp.createConnection({
host: '127.0.0.1',
port: 5672,
login: 'guest',
password: 'guest',
connectionTimeout: 10000
})
@lenconda
lenconda / connect_db.js
Created February 8, 2019 13:38
MongoDB example
const mongoose = require('mongoose')
const {
DB_HOST,
DB_PORT,
DB_USER,
DB_PASSWORD,
DB_NAME } = require('../../config')
const getLogger = require('../utils/logger')
const logger = getLogger(__filename)
@lenconda
lenconda / redis_queue.js
Created February 8, 2019 14:09
A queue model based on Redis
const redis = require('redis')
const _db = Symbol('db')
class RedisQueue {
constructor () {
this[_db] = redis.createClient({
host: 'localhost',
port: 6379