Skip to content

Instantly share code, notes, and snippets.

@howtomakeaturn
howtomakeaturn / repo
Created July 25, 2014 07:49
repository
<?php
require_once('Article.php');
require_once('ArticleDataMapper.php');
require_once('ArticleCategory.php');
class ArticleRepository{
protected $CI;
protected $dm;
function solution($A) {
asort($A);
$B = array();
foreach($A as $value){
$B[] = $value;
}
foreach($B as $index => $value){
if (($B[$index+1] != ($value+1)) && ($B[$index+1] != $value)) {
return $value + 1;
}
@howtomakeaturn
howtomakeaturn / gist:fd4be8e8a4eb730a719d
Last active August 29, 2015 14:14
October CMS notes

File-based or database-based?

October themes are completely file-based and can be managed with any version control system, for example Git.

October syntax

The template paths are always absolute. If in a partial you render another partial from the same subdirectory you still need to specify the subdirectory name.

Template structure

Pages, partials and layout templates can include up to 3 sections: configuration, PHP code, and Twig markup. Sections are separated with the == sequence.

Wordpress
線上20-40人
記憶體
total used free shared buffers cached
Mem: 490 462 27 64 24 168
-/+ buffers/cache: 269 220
Swap: 999 40 959

#Common class names

Validator:

Presenter:

Factory:

Repository:

@howtomakeaturn
howtomakeaturn / gist:23608d2925ad3e29809f
Created June 14, 2015 12:00
Script Install WordPress
#!/bin/bash
clear
echo "============================================"
echo "WordPress Install Script"
echo "============================================"
echo "Wordpress Folder Name: "
read -e folder_name
echo "============================================"
echo "A robot is now installing WordPress for you."
echo "============================================"
/Accounting
/AccountEvent.php
/Entry.php
/EventType.php
/Coupons
/CouponFactory.php
/GeneralCouponRepository.php
/StandardCouponFactory.php
/Coupon.php
/PremiumCouponFactory.php
public function makeTrie($words)
{
$end = '_end_';
$root = [];
foreach($words as $word){
$currentDict = &$root;
$charArray = preg_split('//u',$word, -1, PREG_SPLIT_NO_EMPTY);
foreach($charArray as $char){
if(array_key_exists($char, $currentDict)){
$currentDict = &$currentDict[$char];
This file has been truncated, but you can view the full file.
{('B', 'y'): {u'\u8457': -4.685725582726946, u'\u4f86': -4.261911335950585, u'\u800c': -1.0846153684657418, u'\u54ce': -5.378872763286892, u'\u4fbf': -4.685725582726946, u'\u7f77': -1.3446321251344966, u'\u4e5f': -1.010128393085956}, ('E', 'h'): {u'\u4f4e': 0}, ('E', 'jn'): {u'\u897f': -0.40546510810816444, u'\u91cf': -1.0986122886681098}, ('B', 'k'): {}, ('B', 'qe'): {u'\u5146': 0}, ('E', 'vn'): {u'\u7981': -7.775924383972917, u'\u9000': -10.734877406023612, u'\u8b02': -12.526636875251667, u'\u5f85': -10.406373339051576, u'\u6d89': -11.140342514131776, u'\u5408': -4.511639980903365, u'\u5f0a': -10.367152625898294, u'\u8a0c': -11.140342514131776, u'\u5e8f': -9.42055654452881, u'\u9810': -8.83775742113773, u'\u905e': -9.20640855612318, u'\u6297': -6.7698403653098485, u'\u8fea': -9.864049048226214, u'\u6599': -8.781062077461185, u'\u731c': -13.625249163919776, u'\u53db': -9.775101562209718, u'\u9020': -5.863504179260864, u'\u9322': -11.833489694691721, u'\u7687': -10.224051782257622, u'\u7926': -9.2945158236334
{u'\u8000': [('E', 'v'), ('M', 'nr'), ('E', 'nr'), ('B', 'a'), ('S', 'v'), ('E', 'a'), ('M', 'nt'), ('B', 'i'), ('B', 'n'), ('B', 'ns'), ('B', 'nz'), ('E', 'n'), ('M', 'i'), ('S', 'vg'), ('M', 'nrfg'), ('M', 'n'), ('E', 'nrfg')], u'\u8604': [('S', 'g'), ('B', 'ns'), ('B', 'n'), ('M', 'nr'), ('E', 'nr')], u'\u6d89': [('B', 'v'), ('E', 'v'), ('S', 'vg'), ('B', 'vn'), ('B', 'n'), ('M', 'n'), ('E', 'i'), ('M', 'l'), ('M', 'i'), ('E', 'nr'), ('M', 'nr'), ('E', 'vn'), ('B', 'ns'), ('E', 'l'), ('S', 'j'), ('B', 'i')], u'\u4f0a': [('B', 'ns'), ('B', 'nz'), ('B', 'nr'), ('S', 'j'), ('B', 'nrt'), ('M', 'nr'), ('E', 'nr'), ('M', 'ns'), ('E', 'nrt'), ('M', 'nrt'), ('B', 'n'), ('B', 'v'), ('M', 'nz'), ('E', 'n'), ('M', 'nt'), ('E', 'ns'), ('B', 'nt'), ('E', 'nz'), ('B', 'j'), ('M', 'l'), ('E', 'm'), ('M', 'i')], u'\u9810': [('B', 'v'), ('B', 'vn'), ('B', 'n'), ('S', 'd'), ('E', 'v'), ('B', 'd'), ('E', 'vn'), ('M', 'l'), ('E', 'nr'), ('B', 'b'), ('M', 'nr'), ('M', 'n'), ('M', 'b'), ('B', 'nz'), ('M', 'i'), ('B', 'j'), ('B'