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;
#!/usr/local/bin/python2.7
import random
input_list = ['A', 'B', 'C', 'D', 'E']
lists = [[], [], []]
random.shuffle(input_list)
while input_list:
@howtomakeaturn
howtomakeaturn / Google_SDK_notes.md
Last active October 19, 2016 04:57
Google Drive SDK notes

Google Drive SDK筆記

儲存觀念

上傳檔案時,一律會是原始檔儲存。 若是用Google文件app開啟檔案,會新增一個轉成Google文件格式的檔案。

(所以會看到多出一個檔案,別嚇到了。)

(仔細看,兩個檔案乍看一樣,其實前面的icon不同。)

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];