Skip to content

Instantly share code, notes, and snippets.

View maimai-swap's full-sized avatar

S. Ishimaru maimai-swap

  • individual
  • Japan
View GitHub Profile
@maimai-swap
maimai-swap / IdmappingID.php
Last active August 29, 2015 14:10
app/models/IdmappingID.php
<?php
use Illuminate\Queue\Jobs\Job;
use Aws\S3\S3Client;
use Aws\DynamoDb\DynamoDbClient;
use Aws\DynamoDb\Model\BatchRequest\WriteRequestBatch;
use Aws\DynamoDb\Model\BatchRequest\PutRequest;
use Aws\DynamoDb\Enum\Type;
use Illuminate\Support\Facdes\Log;
class IdmappingID {
@maimai-swap
maimai-swap / json
Created November 22, 2014 11:16
aws ec2 describe-instances --output json
{
"Reservations": [
{
"OwnerId": "XXXXXXXXXXXX",
"ReservationId": "r-XXXXXXXX",
"Groups": [],
"Instances": [
{
"Monitoring": {
"State": "disabled"
@maimai-swap
maimai-swap / mailsend.sh
Created March 3, 2014 06:35
mutt mail send with a attached file of text.
#!/bin/sh
dir=/home/ec2-user/tmp
filepath=$dir/testfile.csv
Err(){ echo "$1">&2; exit 1; }
mail_to='[email protected]'
mime=`file --mime $filepath | cut -d' ' -f2`
@maimai-swap
maimai-swap / initialize.js
Last active August 29, 2015 13:56
いきなり実行するJavascriptを生Javascriptで
(function () {
var appPrefix = {};
appPrefix.app = function () {
function _init() {
// ここに何か書く。
console.log("hogehoge start");
}
return {
@maimai-swap
maimai-swap / upload_s3.php
Created February 4, 2014 01:11
Laravel 4 で s3に htmlファイルを アップロードして、content-typeとcharsetもutf8で設定する。
<?php
// ControllerとかCommandとかのなかに適当に以下を書く
$image = Image::findOrFail($ad->image_id);
$content_type = explode(";",$image->spec)[0];
$spec_ext = explode("/", $content_type)[1];
$ad_array = $ad->toArray();
$display_text = "あああ表示文字";
@maimai-swap
maimai-swap / snipet.php
Created January 25, 2014 09:20
Wordpress / show Another RSS feed / from http://mypacecreator.net/blog/archives/2021
<?php
// from http://mypacecreator.net/blog/archives/2021
//以下3行の項目を任意に変更
$display_posts_count = 10; //実際に表示したい記事件数
$get_posts_count = 20; //取得する記事件数(PR記事を含むので$display_posts_countより少し多めに設定)
$feed = fetch_feed('http://rssblog.ameba.jp/conboy/rss20.xml'); //取得したいRSS
//以下は必要なければ変更しなくてOK
$counter = 0; //ループ回数カウンター
include_once(ABSPATH . WPINC . '/feed.php');
@maimai-swap
maimai-swap / getjobfile.sh
Last active December 23, 2015 14:39
リモートのディレクトリで番号が新しくて無い奴をローカルにつくってファイルを持ってくる。
#!/bin/sh
LOCAL_JOB_HOME=/home/myname/downloader
REMOTE_JOB_HOME=/data/downloader/job
ls -1 $LOCAL_JOB_HOME/wait | sort -n > $LOCAL_JOB_HOME/wait_local
ssh myname@remotehost ls $REMOTE_JOB_HOME/wait | sort -n > $LOCAL_JOB_HOME/wait_remote
remote=`comm -3 $LOCAL_JOB_HOME/wait_remote $LOCAL_JOB_HOME/wait_local | awk -F"\t" '{print $1}' | grep "[0-9]"`
@maimai-swap
maimai-swap / aws-ec2-sample.php
Last active November 4, 2016 19:30
aws sdk php2, ec2 describe and start and stop.
<?php
/**
* Created by JetBrains PhpStorm.
* User: ishimaru
* Date: 2013/07/05
* Time: 17:31
* To change this template use File | Settings | File Templates.
*/
require 'vendor/autoload.php';
@maimai-swap
maimai-swap / config.rb
Created July 2, 2013 03:51
aws s3 file upload upload_file.rb の XXXXXX に自分のバケット名を入れる。config.yml に access_key_id:secret_access_key: を入れる。これは、https://console.aws.amazon.com/iam/home?#usersから取得できるはず。 ruby upload_file.rb /Users/maimai-swap/tmp/userdic.csv ってやったら bucket 直下に userdic.csvのファイルがアップロードされる。
# Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
@maimai-swap
maimai-swap / router.php
Created June 16, 2013 10:06
li3_serverの変更。いつも忘れるので。
<?php
// app/libraries/li3_server/config/router.php
// app/libraries/li3_server においたとき…
$webroot = dirname(dirname(dirname(__DIR__))).'/webroot/';
if (file_exists($webroot . $_SERVER['REQUEST_URI'])) {
return false;
} else {
include_once $webroot.'/index.php';
}