Skip to content

Instantly share code, notes, and snippets.

@gomasaba
gomasaba / admin.py
Created July 11, 2019 17:36
BooleanDropdownFilter
# stdlib
# lib
from django.contrib.admin.filters import (
BooleanFieldListFilter,
)
# app
class BooleanDropdownFilter(BooleanFieldListFilter):
template = 'boolean_dropdown_filter.html'
# -*- coding: utf-8 -*-
# stdlib
import os
import glob
from contextlib import contextmanager
import shutil
icon_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'icons')
os.makedirs(icon_dir,exist_ok=True)
@gomasaba
gomasaba / chachall.yml
Created August 19, 2015 12:07
chachall postfix and RAINLOOP
- name: install packages
yum: name={{ item }}
with_items:
- postfix
- mail
- dovecot
- name: aliases.regexp
shell: echo "/(?!^root$|^catchall$)^.*$/ catchall" >> /etc/aliases.regexp creates=/etc/aliases.regexp
@gomasaba
gomasaba / gist:8769123
Created February 2, 2014 14:19
color_check_shell
<?php
App::uses('Shell', 'Console');
class ColorShell extends Shell {
public function main($command = null) {
$this->out("<emergency>emergency</emergency>");
$this->out("<alert>alert</alert>");
@gomasaba
gomasaba / fabfile.py
Created November 13, 2013 08:29
fabricでnrpeをインストールのメモ fab client_update -H ipアドレス --port=ポート -u ユーザー -i 鍵
# -*- coding: utf-8 -*-
import os
from fabric.api import *
from fabric.contrib.files import *
########################################
# クライアントにnrpeをインストール
########################################
def client_setup():
with settings(
hide('warnings', 'running'),
@gomasaba
gomasaba / gist:5844552
Created June 23, 2013 10:33
twitteroauthでツイート取得
<?php
/**
* twitter 表示
* 1時間60回
* 1分のキャッシュ
*/
require_once getenv('DOCUMENT_ROOT').'/../lib/twitteroauth/twitteroauth/twitteroauth.php';
$consumer_key = '';
$consumer_secret = '';
$access_token = '';
@gomasaba
gomasaba / gist:5160264
Created March 14, 2013 10:18
htmlタグの画像のパスを変える
/**
* 画像のパスを変える
* @param {[type]} $html [description]
* @return {[type]} [description]
*/
function convert($basedir,$html){
$img_pattern = '/<img .*?src="(.*?)".*?>/i';
$src_pattern = '/src="(.*?)"/';
/*----------------------------------------------
@gomasaba
gomasaba / LC_Page_Admin_Products_Product_Ex.php
Created January 11, 2013 11:34
ECCUBEで管理画面に前後の商品リンクメモ
/**
* 前後の商品
*
*/
public function neighbors($product_id){
$objQuery =& SC_Query_Ex::getSingletonInstance();
//prev
$objQuery->setOrder('product_id DESC');
$objQuery->setLimit('1');
#! /bin/sh
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/user/bin
NAME=nginx
DESC="nginx deamon"
DAEMON=/usr/sbin/$NAME
SCRIPTNAME=/etc/init.d/$NAME
@gomasaba
gomasaba / gist:1523835
Created December 27, 2011 14:37
vimの設定メモ
syntax on
set autoindent
set number
if has('gui_macvim')
set showtabline=2 " タブを常に表示
set imdisable " IMを無効に
set antialias " アンチエイリアスを有効に
set cindent " Cインデントを利用
set expandtab " タブを空白文字で