Skip to content

Instantly share code, notes, and snippets.

View twitter_login.swift
// ログインボタンを押した時のアクションは自分で設定する
@IBAction func twitterLoginButtonTapped(sender: AnyObject) {
MBProgressHUD.showHUDAddedTo(self.view, animated: true)
}
// Twitterログインボタン設定
func setupLoginWithTwitter() {
// Consumer Key, Consumer Secretの指定
NCMBTwitterUtils.initializeWithConsumerKey(kTwitterConsumerKey, consumerSecret: kTwitterConsumerSecret)
// Twitterログインボタン押下時の処理
View ArrayModel.php
<?php
App::uses('AppModel', 'Model');
class ArrayModel extends AppModel {
public $useDbConfig = 'array';
public $useTable = false;
public $records = [];
View SiteAdminUser.php
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
use Cake\Auth\DefaultPasswordHasher;
/**
* SiteAdminUser Entity.
*
* @property int $id
View gist:e282b41494b0b25f7e80
<?php
foreach (range(1, 10) as $n) {
echo "calculating $n connection...\n";
$c = new Connection($n, $n === 1 ? null : $c);
echo 'got answer. connection patterns: ', count($c->answers), "\n";
}
class Connection {
@hiromi2424
hiromi2424 / Post.php
Created Mar 12, 2012
CakePHP Mass Assignment Vulnerability - common process
View Post.php
<?php
// モデルの場合。
// 以下と相似なヘルパーメソッドを作れば、いちいち同じようなメソッドを大量生産しなくて済むよ!
class Post extends AppModel {
public function edit($id, $data) {
$this->create(false);
$this->set($data);
$this->set('id', $id);
@hiromi2424
hiromi2424 / migration1.php
Created Dec 18, 2011
migrations with initial records
View migration1.php
<?php
class M4ec9e1ac040840e8b4383c94d8a96c37 extends CakeMigration {
/**
* Records keyed by model name.
*
* @var array $records
*/
public $records = array(
@hiromi2424
hiromi2424 / BaseActionComponent.php
Created Dec 10, 2011 — forked from slywalker/BaseActionComponent.php
CakePHP2.0 BaseActionComponent
View BaseActionComponent.php
<?php
App::uses('Component', 'Controller');
App::uses('Inflector', 'Utility');
class BaseActionComponent extends Component {
public $components = array('Session');
public $Controller;
View app_controller.partof.php
<?php
public $components = array(
'RequestHandler' => array(
// 'enabled' => false,
),
'DebugKit.Toolbar' => array(
'history' => 5,
'panels' => array(
'Interactive.interactive',
),
View ChatController.php
<?php
class ChatController extends AppController {
public $components = array(
'WebSocket',
);
public function send() {
$this->autoRender = false;
@hiromi2424
hiromi2424 / categorize.php
Created Sep 2, 2011
preferable example for getting data method for model(behaviorized)
View categorize.php
<?php
/**
* Available find keys:
* 'category': adding creteria with name of category.
*/
class CategorizeBehavior extends ModelBehavior {
public $defaultSettings = array(
'key' => 'category',