Installing Composer Globally

curl -sS | php

sudo mv composer.phar /usr/local/bin/composer

chmod +x /usr/local/bin/composer

页面布局 grid,flex,绝对定位,圣杯及双飞翼布局


Get all files in a folder and sub-folders

function walkSync(currentDirPath, callback) {
  // attrib:

  fs.readdirSync(currentDirPath).forEach(function (name) {
    var filePath = path.join(currentDirPath, name);
    var stat = fs.statSync(filePath);
    if (stat.isDirectory()) {
      if (hasChildDirectories(filePath)) {
        walkSync(filePath, callback);
      callback(filePath, stat);


Has Child Directories?

function hasChildDirectories(currentDirPath) {
  let value = false;
  fs.readdirSync(currentDirPath).forEach(function (name) {
    var filePath = path.join(currentDirPath, name);
    var stat = fs.statSync(filePath);
    if (stat.isDirectory()) {
      value = true;
  return value;

Install maven Fedora

sudo nano /etc/profile
Add these commands at the end of the text file

export M2_HOME=/opt/apache-maven-3.3.9

export M2=$M2_HOME/bin

export PATH=$M2:$PATH

Reload profile by typing source /etc/profile in command line

Restart the system

Verify M2 by typing echo $M2 in command line

Verify PATH by typing echo $PATH in command line. Check if there is maven directory in the PATH variable or not.
Check maven version by typing mvn -version in command line


Episode 6
import java.util.ArrayList;

public class Main {

    public static void main(String[] args) {

        ArrayList<String> strings = new ArrayList<>(4); //Can add 4 elements without reallocation
        System.out.println(strings.size()); //Like .length()
        strings.add("Vehicle"); //Add elements
        strings.add("Jordan Peterson");
        strings.add(1, "New Dolphin"); //Choose WHERE to put the elements

        //Print out the contents of the array list

        //Remove elements too
        strings.remove("Jordan Peterson"); //Remove it by its value/object
        strings.remove(3); //Remove by index

        //Set capacity equal to the number of elements currently in the arraylist

        //Convert an arraylist to a regular array

Recibir un parametro por post en Laravel

function reciboPostDelFormulario(Request $request) {

En la vista supongamos que teníamos
<input type="text" name="nombre">


package main

import (

func main() {
    fmt.Printf("Current Unix Time: %v\n", time.Now().Unix())

    time.Sleep(2 * time.Second)

    fmt.Printf("Current Unix Time: %v\n", time.Now().Unix())

Useful SourceTree Commands

Adds your ssh key to the keychain
cd ~/.ssh/; ssh-add

Crear un nuevo controlador en Laravel, dentro de una subcarpeta

Copiado de []
php artisan make:controller frontend/SomeController

Usar la clase Db en Laravel para hacer consultas a la base de datos

Para poder realizar consultas a la base de datos, mediante la clase Db en Laravel, se necesita hacer el siguiente include
use Illuminate\Support\Facades\DB;


public class ContentServiceImpl implements ContentService {

	private JedisClient client;
	private TbContentMapper mapper;
	private String CONTENT_KEY;
	/* 同步缓存 */
	public TaotaoResult saveContent(TbContent content) {
		content.setCreated(new Date());
		try {
			client.hdel(CONTENT_KEY, content.getCategoryId()+"");
		} catch (Exception e) {
		return TaotaoResult.ok();
    /* 从缓冲中获取 */
	public List<TbContent> getContentListByCatId(Long categoryId) {
		//判断 是否redis中有数据  如果有   直接从redis中获取数据 返回
		try {
			String jsonstr = client.hget(CONTENT_KEY, categoryId+"");//从redis数据库中获取内容分类下的所有的内容。


import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.lang.reflect.ParameterizedType;
import java.util.Collections;
import java.util.List;

@Transactional // @Transactional可被继承,子类也有效
public class BaseDaoImpl<T> implements BaseDao<T> {

    private SessionFactory sessionFactory;

    // 如何获取字节码类型
    private Class<T> clazz;

    public BaseDaoImpl() {
        // 通过构造器获取字节码类型
        ParameterizedType pt = (ParameterizedType) this.getClass().getGenericSuperclass();
        this.clazz = (Class<T>) pt.getActualTypeArguments()[0];

    public void add(T t) {

    public void delete(Long id) {
        Object obj  = getSession().get(clazz, id);

    public void edit(T t) {


import java.util.List;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;

 * JSON转换工具类
public class JsonUtils {

    // 定义jackson对象
    private static final ObjectMapper MAPPER = new ObjectMapper();

     * 将对象转换成json字符串。
     * <p>Title: pojoToJson</p>
     * <p>Description: </p>
     * @param data
     * @return
    public static String objectToJson(Object data) {
    	try {
			String string = MAPPER.writeValueAsString(data);
			return string;
		} catch (JsonProcessingException e) {
    	return null;
     * 将json结果集转化为对象
     * @param jsonData json数据
     * @param clazz 对象中的object类型
     * @return
    public static <T> T jsonToPojo(String jsonData, Class<T> beanType) {
        try {
            T t = MAPPER.readValue(jsonData, beanType);


<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <!-- 页面分帧 -->
    <frameset rows="80,*">
        <frame name="top" src="#"></frame>
        <frameset cols="220,*">
            <frame name="menu" src="#"></frame>
            <frame name="main" src="#"></frame>