Skip to content

Instantly share code, notes, and snippets.

View NorihikoMoriyama's full-sized avatar

NorihikoMoriyama NorihikoMoriyama

View GitHub Profile
@NorihikoMoriyama
NorihikoMoriyama / TwitterApiComponent.php
Last active December 22, 2015 21:38
CakePHP2でTwitterのOAuthをしてみる[cakephp][twitter]
<?php
App::import('Vendor', 'Oauth', array('file' => 'OAuth'.DS.'OAuthClient.php'));
class TwitterApiComponent extends Component {
/**
* 使用するコンポーネント
*/
public $components = array('Session');
@NorihikoMoriyama
NorihikoMoriyama / 1.1.2.winscp_fileup.txt
Last active December 22, 2015 23:39
リモート・マシン間でファイルをコピーする
cd C:\Program Files\WinSCP
winscp.exe /console /script=C:\Users\***\winscp_fileup.txt
del C:\Users\***\images\*.jpg
@NorihikoMoriyama
NorihikoMoriyama / gist:6589219
Last active December 23, 2015 05:49
強制的にURLをhttpsに変更します。[.htaccess][cakephp]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /***/
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{REQUEST_URI} !^(.*\.(jpg|gif|png|jpeg|js|css))$ [NC]
RewriteRule ^(.*)?$ https://%{HTTP_HOST}/***/$1 [L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
@NorihikoMoriyama
NorihikoMoriyama / gist:6932357
Last active December 25, 2015 06:29
タブレットとスマフォの振り分け[.htaccess]
ErrorDocument 404 /****/notfound/index.html
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} Android.*Mobile
RewriteCond %{REQUEST_URI} !^/.*\.(gif|jpg)$
RewriteCond %{REQUEST_URI} !/sp/.*$
RewriteCond %{REQUEST_URI} !/notfound/.*$
RewriteRule ^(.*)$ /****/sp/$1 [R,L]
@NorihikoMoriyama
NorihikoMoriyama / ImportcsvShell.php
Last active December 28, 2015 15:38
[cakephp]cronを使ってみる
<?php
class ImportcsvShell extends AppShell
{
var $uses = array('Serials');
function main(){}
function index(){
$arg0 = $this -> args[0]; //コマンドで渡した引数の受取
@NorihikoMoriyama
NorihikoMoriyama / atagitaiwohsc.php
Last active May 14, 2023 09:21 — forked from oh-sky/atagitaiwohsc.php
PHPで <a> タグ以外をhtmlspecialcharsする関数
<?php
// <a> </a> タグ以外をhtmlspecialcharsする関数
function atagigaiwohsc($src,$flags = ENT_QUOTES){
// encode including <a></a>
$sanitized = htmlspecialchars($src,$flags);
// decode all <a>
if(preg_match_all('@&lt;a.*?&gt;@', $sanitized, $matches, PREG_SET_ORDER)){
foreach($matches as $match){