Skip to content

Instantly share code, notes, and snippets.

View momota10's full-sized avatar
🌴
On vacation

momota momota10

🌴
On vacation
View GitHub Profile
@momota10
momota10 / mailgun-tracking.rb
Created May 27, 2017 04:17
sample ruby code of mailgun tracking
require "time"
require 'active_support/all'
require 'rest-client'
require 'json'
def get_logs(start_time, end_time)
response = RestClient.get "https://api:key-***********"\
"@api.mailgun.net/v3/influencerone.jp/events",
:params => {
:'begin' => "#{start_time}",
{
"template": "elb_access_log*",
"mappings" : {
"elb_access_log" : {
"properties" : {
"backend" : {
"type" : "ip"
},
"backend_port" : {
"type" : "integer",
package main
import (
"fmt"
mailgun "github.com/mailgun/mailgun-go"
)
func main() {
mg := mailgun.NewMailgun(
@momota10
momota10 / file0.txt
Last active December 27, 2016 05:14
Redshiftのクラスタを再構築せざるを得なかった話 ref: http://qiita.com/momotasasaki/items/6a5e23b1ccdae79c2ead
Dear Customer,
Our systems have identified a potential hardware issue that may affect your
Amazon Redshift cluster {your_cluster_name} the {your_region_name} AWS region.
As a precaution, we recommend that you restore a new cluster from a snapshot
within the next 2-3 days and delete your existing cluster.
This will automatically provision you on healthy hardware and help you
avoid an unplanned outage. Please confirm receipt of this message.
//split
val url = "https://play.google.com/store/apps/details?id=com.expedia.bookings&hl=ja" //sample_url
val replacedUrl = url.replace("https://", "")
val splitUrl =replacedUrl.split("/")
println(replacedUrl) //play.google.com/store/apps/details?id=com.expedia.bookings&hl=ja
println(splitUrl(0)) //play.google.com
//pattern match
splitUrl(0) match {
case "itunes.apple.com" =>
##例外処理
scala> val n = try{"99".toInt} catch {case e:Exception => -99}
n: Int = 99
scala> val n = try{"999".toInt} catch {case e:Exception => -99}
n: Int = 999
scala> val n = try{ "momo".toInt } catch { case e:Exception => -99 }
n: Int = -99
@momota10
momota10 / sendEmail.scala
Last active January 18, 2016 09:37
play-mailerを使ったメール送信メソッド
def sendEmail = Action.async { implicit request =>
emailAddressForm.bindFromRequest.fold(
error => {
Future.successful(BadRequest("Your Aoolication"))
},
emailAddress => {
//mail transfer process
val email = Email(
"Simple email",
"title <[email protected]>",
module.exports = function() {
$(function() {
var num = 0
$('#add-birthday-setting').on('click', function() {
num = parseInt($("#birthday-table tbody tr:last").attr('id').match(/[0-9]/))
var tr = $('#birthday-setting\\['+num+'\\]')
num++
tr.clone(true)
.insertAfter(tr)
<table id="birthday-table">
<thead>
<tr>
<th>誕生月</th>
<th>誕生日</th>
<th>削除</th>
</tr>
</thead>
<tbody>
<tr id="birthday-setting[0]" >
Future.traverse(list) { listId =>
caRepository.findById(listId) filter {
case Some(c) => c.status match {
case Stopped => false
case _ => true
}
} map { cs =>
cs.get.id.get
}
}