Skip to content

Instantly share code, notes, and snippets.

@yuuan
yuuan / httpd-writable-on-selinux.zsh
Created December 2, 2015 05:40
SELinux が有効な環境で、指定したディレクトリに対して HTTPD が書き込みできるようにするスクリプト。
#!/bin/zsh -eu
function writable {
TARGET=$*
echo -e "\e[37m'$TARGET'\e[m のパーミッションを変更します。"
/usr/bin/sudo /usr/bin/chmod -R a+w "$TARGET"
echo -e "\e[37m'$TARGET'\e[m に \e[32m'httpd_sys_rw_content_t'\e[m を付与します。"
/usr/bin/sudo /usr/sbin/semanage fcontext -a -t httpd_sys_rw_content_t "$TARGET(/.*)?"
@yuuan
yuuan / configure-vim.sh
Created November 4, 2015 07:24
Configure vim on Fedora
#!/bin/sh
./configure --enable-multibyte --with-features=huge --disable-selinux \
--prefix=/usr/local \
--enable-luainterp=yes --with-luajit \
--enable-perlinterp=dynamic \
--enable-rubyinterp=dynamic \
--enable-pythoninterp=dynamic --enable-python3interp=dynamic \
--enable-fail-if-missing
// ==UserScript==
// @name Translate DateTime in GitLab
// @namespace http://www.yuuan.net/item/1054
// @description 英語で書かれた日付を数字に変える
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
// @include http://gitlab.com/*
// @version 0.1
// @grant none
// ==/UserScript==
(function($) {
<?php
/**
* `@param` で渡された変数が宣言されていないときに、
* `debug` モードならエラーを出し、そうでなければ宣言して null を代入する
*
*/
Blade::extend(function($view, $compiler)
{
$pattern = $compiler->createMatcher('param');
@yuuan
yuuan / color-scheme-for-view-source.css
Last active August 29, 2015 14:15
Firefox で `ページのソースを表示` したときのデザインを上書きするためのスタイルシート
@-moz-document url-prefix(view-source) {
body {
margin: 0;
}
#viewsource {
font-family: "Ricty";
font-size: 10pt;
line-height: 135%;
}
#line1:before {
@yuuan
yuuan / AppModel.php
Created August 21, 2014 08:43
CakePHPで `created` の代わりに `created_at` を使うようにするために AppModel を強引にいじってみた。
<?php
/**
* Application model for Cake.
*
* This file is application-wide model file. You can put all
* application-wide model-related methods here.
*
* @link http://cakephp.org CakePHP(tm) Project
* @package app.Model
* @since CakePHP(tm) v 0.2.9
#This configuration has been tested on GitLab 6.0.0 and GitLab 6.0.1
#Note this config assumes unicorn is listening on default port 8080.
#Module dependencies
# mod_rewrite
# mod_ssl
# mod_proxy
# mod_proxy_http
# mod_headers
# This section is only needed if you want to redirect http traffic to https.
@yuuan
yuuan / centos.conf
Created April 3, 2014 02:04
Config file for CentOS 6.5 on coLinux.
#
# This is an example for a configuration file that can
# be passed to colinux-daemon in this manner:
#
# colinux-daemon @example.conf
#
# Note that you can still prepend or append configuration and
# boot parameters before and after '@', or you can use more
# that one '@ to load several settings one after another.
#
@yuuan
yuuan / services-portion.php
Created February 13, 2014 09:53
Phalcon の project/app/config/services.php を編集して Volt に date フィルターを追加してみた。
<?php
// ...
/**
* Setting up the view component
*/
$di->set('view', function () use ($config) {
$view = new View();
@yuuan
yuuan / log.php
Created January 5, 2014 14:43
PHPでログに出力するクラス
<?php
class Log {
const LOG_FILE = 'log/console.log';
public static function warn($message = '', $toError = true) {
if ($toError) {
return user_error("$message", E_USER_WARNING);
}
else {
// 呼び出し元のファイル名と行番号とか出したい