Skip to content

Instantly share code, notes, and snippets.

View matsubo's full-sized avatar

Yuki Matsukura matsubo

View GitHub Profile
@koko1000ban
koko1000ban / nested_query_in_arel.rb
Last active August 29, 2015 13:58
Nested query in Arel
limit = 200
post_table = Post.arel_table
visibility_ids = PostVisibility.select(:post_id).where(user_id: 1).order(id: :desc).limit(limit).arel.as('t')
inner_query = Arel::Table.new(:tmp).project(:post_id).from(visibility_ids.to_sql)
Post.where(post_table[:is_public].eq(true).or(post_table[:id].in(inner_query))).limit(limit)
<VirtualHost *:80>
RewriteEngine on
RewriteRule ^/(.*) blah [R=503]
</VirtualHost>
@Craftworks
Craftworks / mymemcheck
Created December 8, 2010 15:14
MySQL memory configuration check tool
#!/usr/bin/env perl
use strict;
use warnings;
my @GLOBAL_BUFFERS = qw(
key_buffer_size
innodb_buffer_pool_size
innodb_log_buffer_size
innodb_additional_mem_pool_size
@kinopyo
kinopyo / rspec_shared_context_example.rb
Created October 13, 2011 10:08
rspec shared_context sample codes.
shared_context "shared stuff" do
before { @some_var = :some_value }
def shared_method
"it works"
end
let(:shared_let) { {'arbitrary' => 'object'} }
subject do
'this is the subject'
end
end
@tanakahisateru
tanakahisateru / gist:1344162
Created November 7, 2011 04:18
PHP5.4 configure with MacPorts besides existing PHP
./configure \
--prefix=/opt/local/php/5.4 \
--bindir=/opt/local/bin \
--with-config-file-path=/opt/local/php/5.4/etc \
--with-config-file-scan-dir=/opt/local/php/5.4/var/db \
--mandir=/opt/local/php/5.4/share/man \
--infodir=/opt/local/php/5.4/share/info \
--program-suffix=-5.4 \
--with-apxs2=/opt/local/apache2/bin/apxs \
--enable-pdo \
@matsubo
matsubo / 01_Wikipediaをソースとした整理.md
Last active October 11, 2016 03:59
権利周りの用語と法律を整理
  • 知的財産権
    • 特許権
    • 商標権
    • 著作権
      • 著作者人格権 (人格的な権利)
      • (狭義の)著作権(財産的な権利)(一般的な著作権はこちらを指す)
        • 使用
          • 専用使用(排他)
          • 通常使用(共有)
  • 利用
@mzdakr
mzdakr / ServerMonitoringWithGAS.js
Last active January 29, 2018 02:12
Google Apps Script を使って簡易的にWEBサーバの死活監視をするスクリプトです。 外部からURL叩いて 200 が返ってこなかったらメールをするだけのとてもシンプルなコードです。 Google Apps Scriptを採用した理由は 1) JSで書けてお手軽 2)Google Apps Scriptで定期実行が可能 3) Google Apps の基盤上で動かせるので可用性が高い の3つです。 毎分スクリプトを動かすことができるので便利なのと死活監視自体が死んでるということを極力回避できるというのはポイント高いと思います。死活監視の死活監視なんて新たな死活監視を産むだけです。 Google Apps Scriptはかなり便利なので使ってみてください。
var url = 'http://www.example.com/';
var to = 'foo@example.com';
var sub = 'サーバ障害報告';
var body = "監視中の サーバが停止した模様です。サーバの状態を確認してください。\n" + url ;
function myFunction()
{
if(check_server(url) != 200){
MailApp.sendEmail(to, sub, body);
@brundage
brundage / database.yml
Created November 16, 2012 22:05
Use sqlite in-memory database for rspec testing
test:
adapter: sqlite3
encoding: utf8
pool: 5
timeout: 5000
database: ":memory:"
verbosity: quiet
@kissrobber
kissrobber / graph_database_memo.md
Last active April 16, 2018 02:36
Graph Database memo
@michaelcox
michaelcox / xdr.js
Created May 10, 2012 18:56
Adds XDomainRequest IE CORS support to jQuery
// Based on https://github.com/jaubourg/ajaxHooks/blob/master/src/ajax/xdr.js
(function( jQuery ) {
if ( window.XDomainRequest && !jQuery.support.cors ) {
jQuery.ajaxTransport(function( s ) {
if ( s.crossDomain && s.async ) {
if ( s.timeout ) {
s.xdrTimeout = s.timeout;
delete s.timeout;