Skip to content

Instantly share code, notes, and snippets.

import axios from 'axios';
/**
* @typedef { Object } UploadMeta
*/
/**
* @typedef { Object } UploadResponse
*/
/**
* @typedef { import('@uppy/core').Uppy<UploadMeta, UploadResponse> } TypedUppy
@hiromi2424
hiromi2424 / bulk_updatable.rb
Created June 13, 2023 10:32
Bulk Updatable
module BulkUpdatable
extend ActiveSupport::Concern
class_methods do
def bulk_update(attributes)
return true if attributes.empty?
attrs = attributes.map { |attribute| attribute.to_h.symbolize_keys }
fields = attrs.first.keys.map(&:to_sym) - [:id]
// ログインボタンを押した時のアクションは自分で設定する
@IBAction func twitterLoginButtonTapped(sender: AnyObject) {
MBProgressHUD.showHUDAddedTo(self.view, animated: true)
}
// Twitterログインボタン設定
func setupLoginWithTwitter() {
// Consumer Key, Consumer Secretの指定
NCMBTwitterUtils.initializeWithConsumerKey(kTwitterConsumerKey, consumerSecret: kTwitterConsumerSecret)
// Twitterログインボタン押下時の処理
<?php
App::uses('AppModel', 'Model');
class ArrayModel extends AppModel {
public $useDbConfig = 'array';
public $useTable = false;
public $records = [];
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
use Cake\Auth\DefaultPasswordHasher;
/**
* SiteAdminUser Entity.
*
* @property int $id
<?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 March 12, 2012 03:56
CakePHP Mass Assignment Vulnerability - common process
<?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 December 18, 2011 21:06
migrations with initial records
<?php
class M4ec9e1ac040840e8b4383c94d8a96c37 extends CakeMigration {
/**
* Records keyed by model name.
*
* @var array $records
*/
public $records = array(
@hiromi2424
hiromi2424 / BaseActionComponent.php
Created December 10, 2011 05:43 — forked from slywalker/BaseActionComponent.php
CakePHP2.0 BaseActionComponent
<?php
App::uses('Component', 'Controller');
App::uses('Inflector', 'Utility');
class BaseActionComponent extends Component {
public $components = array('Session');
public $Controller;
<?php
public $components = array(
'RequestHandler' => array(
// 'enabled' => false,
),
'DebugKit.Toolbar' => array(
'history' => 5,
'panels' => array(
'Interactive.interactive',
),