推荐

定制开发

成功案例

个性化博客互动平台

pic
pic
pic
pic
pic
pic
pic

有好想法, 懒得实现? 请联系 👉

Contact Me

更多

最新

Consul

Introduce

http://www.liangxiansen.cn/2017/04/06/consul/
http://thesecretlivesofdata.com/raft/

Raft

一套算法,用于解决分布式系统中数据状态的一致性.与其平行的是Paxos算法.

更多

Docker

image = {|bootfs|rootfs|app...(*COW*)|} --> Container

https://github.com/yeasy/docker_practice
https://yeasy.gitbooks.io/docker_practice/content/

  • Container进程运行在自己的namespaces(proc,net,kernel,mnt的隔离)
  • os使用cgroup来实现资源的管理

install

https://docs.docker.com/engine/install/centos/
https://docs.docker.com/compose/install/

更多

CodeIgniter

codeigniter

-- application
  -- cache
  -- config
  -- controllers
  -- core
  -- hooks
  -- models
  -- views
-- system
  -- core   :CI的基础核心,不要做任何修改,要扩展应通过Hooks
  -- fonts
  -- libraries

Basic

  • 任何一个url请求,ci都是先用网站根目录下的index.php来处理,然后再重定向.所以一般的请求格式是这样的:..index.php/..
    有一种方法可以使url中避免输入index.php,方式是使用.htaccess
  • url的格式是: example.com/controller1/method1/para1/para2
    访问上面的网址ci就会调用(需public): Controller1::method1($para1, $para2)
    如果访问的是example.com/controller1则默认调用: Controller1::index();
  • route
    application/config/routes.php
  • config
  // application/autoload.php
  $autoload['libraries'] = array('database', 'session');
  $autoload['helper'] = array('url');  // 辅助函数

controllers/hello.php

class Hello extends CI_Controller {
  function __construct() { // 默认是public,定义为private外界就不能访问了
    parent::__construct();  // 对应的有__destruct();
    // models/mod1/hello.php
    // 一般数据的来源是models里面的数据库.完了传递给view
    // TRUE: 模型在加载时自动按照数据库配置连接数据库.当然也可以给第三个参数传递一个$config['key']='value'的配置array!
    $this->load->model('mod1/hello', 'aliasname', TRUE);
    // 加载helper(),类库(libraries)
    $this->load->help(array('url'));
    $this->load->library(array('email', 'table'));
    $this->load->library('form_validation');  // 表单验证相关
    $this->load->library('pagination');  // 翻页
    $config['base_url'] = site_url('admin/..');
    $config['total_rows'] = 100;
    $config['per_page'] = 20;
    $this->pagination->initialize($config);
    $offset = ($this->pagination->cur_page - 1) * $perpage;
    
  }
  public function index() {
    // http://your-domain/index.php/hello
    // index方法表示默认的,无需特意指明/hello/index
  }
  public function welcome($name, $age) {
    $res = $this->aliasname->func();  // 默认就是模型的名字hello    
    $data['content'] = '123';
    $data['array'] = array('1', '2');
    $this->load->view('hello', $data);  // view/hello.php. 给视图传递一个数据$data.key名模板中被当做变量.
  }
  public function _remap($method, $params=array()) { // 如果想自定义uri中第2段的映射函数如此:    
    $method = 'process' . $method;
    if (method_exists($this, $method)) {
      return call_user_func_array(array($this,$method), $params);
    }
    show_404();
  }
}

models/mod1/hello.php

# 如果某个模型在app的整个生命周期内使用,可以让ci在系统初始化时自动加载,设置路径为:application/config/autoload.php
class Hello extends CI_Model {
  public function __construct() {
    parent::__construct();
    $this->db = $this->load()->database('dbname', TRUE);
  }
  public function func() {
    $res = $this->db->query('select....');
    foreach ($res->result_array() as $row) {
      $row['columnname'];
    }
    $this->db->update('tbname', array(...));
    return $res;
  }
  public function update_entry() {
    // 最好使用 $this->input->post('title');
    $this->title = $_POST['title'];
    $this->content = $_POST['content'];
    $this->date = time();
    $this->db->update('entries', $this, array('id'=>$_POST['id']));
  }
}

views/hello.php

<html>
<head></head>
<body>
  <h1><?php echo $content; ?></h1>
  <ul>
  <?php foreach ($array as $item): ?>
    <li><?php echo $item;?></li>
  <?php endforeach>
  </ul>
</body>
</html>

ssl

$priKey = 'rsa_private_key.pem';
$pubKey = 'rsa_public_key.pem';
extension_loaded('openssl') ordie('php needs openssl extention');
$pri = openssl_pkey_get_private(file_get_contents($priKey));  // 如果失败会返回false
$pub = openssl_pkey_get_private(file_get_contents($pubKey));
$oriData = 'hello';
$encData = '';
openssl_private_encrypt($oriData, $encData, $pri);  // bool
$decData = '';
openssl_public_decrypt($encData, $decData, $pub);

misc

/*
 * 自动文章第一个图片为特色图片
 */
function autoset_featured_image(){
    global $post;
    $already_has_thumb = has_post_thumbnail($post->ID);
    if (!$already_has_thumb){
        $attached_image = get_children("post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1");
        if ($attached_image) {
            foreach ($attached_image as $attachment_id => $attachment) {
                set_post_thumbnail($post->ID, $attachment_id);
            }
        } else { // 若没有图片使用素材库中的某个
            set_post_thumbnail($post->ID, '414');
        }
    }
}
add_action('the_post', 'autoset_featured_image');
add_action('save_post', 'autoset_featured_image');
add_action('draft_to_publish', 'autoset_featured_image');
add_action('new_to_publish', 'autoset_featured_image');
add_action('pending_to_publish', 'autoset_featured_image');
add_action('future_to_publish', 'autoset_featured_image');

// dg2: 验证码相关,处理验证码图片

// Smarty
// 主要还是为了实现前后端的分离.因为CI框架中的HTMLtemplate是直接嵌入的PHP代码.没有模板引擎.
// 这不利于前端人员撰写前端的界面. 势必要独立一套模板语言.以便达成双方沟通的桥梁!

更多

Aircrack Ng

目的

  • Wifi破解

wifi工具套装,如果有nVIDIA高性能显卡,可以选择安装Pyrit以加速破解

更多

PHP

绝大多数文档历史久远,可能具有10年以上的历史,此篇亦然. 请酌情参考. ⚠️

更多

Delphi

OP于1985年诞生于Apple,后于1995年由Borland公司继承.

更多

Intellij

use

https://gitee.com/pengzhile/ide-eval-resetter

配置文件恢复时需要选择性导入,全部导入可能不生效!

更多

Mac

一些破解软件的下载地址:

Common Software

Shortcuts(部分需自定义)

boot

  • option: 按住可选择启动的OS
  • shift: 按住以安全模式启动
  • command+s: 以单用户模式启动(comand+v:显示控制台讯息)
  • command+option+o+f: 开机进入OpenFirmware

Touchpad

  • 四指左右滑动: 切换不同的桌面
  • 四指下滑: 当前应用程序的所有窗口
  • 四指上推: MissionControl(多桌面)
  • 四指捏合: Launchpad(app-launcher)
  • 四指分开: desktop
  • 三指点击: 等价于空格键,快速预览!选中单词还可以快速翻译.
  • 三指拖动: 移动窗口
  • 两指点击: 右键

keyboard

F11: 显示桌面win+d
F12: Dashboard(仪表盘/控制面板)
space: 预览
ctrl + F2: 菜单
ctrl + F3: Dock(F5:焦点移动到窗口工具栏)
ctrl + Spa: Spotlight
ctrl + <-: 切换桌面或四指左右滑动
ctrl + shift + space: 笔画输入面板
ctrl + command + F: 切换全屏!
command + tab: 已打开程序切换
command + shift + 3: 截屏到桌面png; 4:区域截图(不用鼠标空格是窗口截图); +ctrl:存到剪贴板; u:实用工具
command + c: 复制;
command + option + v :移动;
command + option + shift + v: 无格式粘贴
command + q: 退出当前程序(command+o打开); command + w: 关闭窗口; 双击标题栏:隐藏; option+LClick:关闭所有
command + n: 建立新窗口; +shift:建立文件夹
command + ,: 偏好设置
command + +: 缩放;配合减号.
command + i: 简介(+option多个文件的公共简介)
command + e: Eject光驱或磁盘. command + space: 输入法
command + ctrl + space: 表情符号
command + option + t: 一些特殊符号
command + option + d: 显示/隐藏dock
command + option + h: 隐藏除当前程序外的其他程序窗口; command + option + Esc: 强制退出应用程序窗口
command + option + p: Finder显示/隐藏路径; y:幻灯片显示
command + shift + a: App Folder(c:computer, h:home, d:desktop, g:前往文件夹)
command + d: Duplicate
command + 1: 以图方式显示; 2:列表; 4:CoverFlow)
command + [: 上一文件夹, ]:下一文件夹
command + up: 上一层目录

更多

Lnmp

https://lnmp.org/install.html
https://github.com/licess/lnmp

  • phpmyadmin
    /home/wwwroot/phpmyadmin
  • defaultweb
    /home/wwwroot/default
  • nginxlog
    /home/wwwlogs

./addons.sh install memcached

更多