Skip to content

Instantly share code, notes, and snippets.

@mogya
mogya / nannohi.gs
Created November 4, 2021 13:17
Google Spread Sheet Twitter bot
function tweetTodaysData(){
const today = new Date();
const range = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("data").getDataRange();
for (let r = 1; r < range.getNumRows()+1; r++) {
const date = range.getCell(r, 1).getValue();
if (typeof date.getMonth !== 'function') { continue; }
if (date.getMonth() == today.getMonth() && date.getDate() == today.getDate()){
tweetText(range.getCell(r, 6).getValue());
}
}
@mogya
mogya / gist:3781468
Created September 25, 2012 12:24
An idea to convert dp to/from pixel on TitaniumMobile Android
// convert dp to pixel.
function dpToPixel(dp) {
return ( parseInt(dp) * (Titanium.Platform.displayCaps.dpi / 160));
}
// convert pixel to dp.
function pixelToDp(px) {
return ( parseInt(px) / (Titanium.Platform.displayCaps.dpi / 160))+'dp';
}
@mogya
mogya / docker-compose.yml
Last active November 11, 2018 02:35
start jordan/rundeck with JST timezone.
version: '2'
services:
volume:
image: alpine:latest
entrypoint: /bin/true
volumes:
- ./etc/rundeck:/etc/rundeck
- ./var/rundeck:/var/rundeck
- ./var/lib/rundeck/.ssh:/var/lib/rundeck/.ssh
- ./var/lib/rundeck/logs:/var/lib/rundeck/logs
@mogya
mogya / gist:77bacad211389f739a3d
Last active August 31, 2017 03:38 — forked from kennyj/gist:4966002
ハイフン付き電話番号に分割
# encoding: utf-8
module TelSplitter
MAP = {
# 市外局番 , 市内局番の桁数のマップ
# http://www.soumu.go.jp/main_sosiki/joho_tsusin/top/tel_number/number_shitei.html のデータを利用
# 固定電話以外の桁数は適当です...
'050' => 4, # IP電話
'070' => 4, # 携帯電話/PHS
'080' => 4, # 携帯電話
@mogya
mogya / CircularLED.cpp
Last active March 5, 2017 09:40
http://wiki.seeedstudio.com/wiki/Grove_-_Circular_LED をNefryで動かすためにトライ中のコード。Wikiに上がっていたサンプルから、unsigned int をuint32_tに変更、CircularLED.inoはNefryで動くように関数を変えたり、ポートを変更したりしたものです。
/*
2012 Copyright (c) Seeed Technology Inc.
Author: LG
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
@mogya
mogya / wget_scraper.rb
Created February 24, 2016 02:32
Wgetをラップして使うスクレイパー
# -*- encoding: utf-8 -*-
require 'lib/scraper.rb'
require "uri"
require "kconv"
#WEBページを取得する際、キャッシュやアクセス時間の間隔などを配慮するためのクラス
class WgetScraper < Scraper
include DebugLog
CACHE_DIR = '/tmp/WgetScraper/'
COOKIE_FILE = '/tmp/WgetScraper/cookie.txt'
@mogya
mogya / app.js
Created September 29, 2012 17:53
[titanium] webview which open any url on the web browser
var win = Titanium.UI.createWindow({
navBarHidden : true,
exitOnClose:true
});
var webView = Ti.UI.createWebView({
width:'100%'
});
webView.addEventListener('beforeload',function(e){
if (e.url.match(/^file:\/\//) ){
#!/usr/bin/env ruby
require 'rubygems'
require 'selenium-webdriver'
caps = Selenium::WebDriver::Remote::Capabilities.iphone
caps.version = "5.0"
caps.platform = :MAC
caps[:name] = "Testing Selenium 2 with Ruby on Sauce"
# -*- encoding: utf-8 -*-
require "rubygems"
require "selenium-webdriver"
require "test/unit"
module HtmlTestSuppeter
def element_present?(how, what)
@driver.find_element(how, what)
true
rescue Selenium::WebDriver::Error::NoSuchElementError
(function(){
Window = require('map_view');
var win = new Window({
title:'map'
});
win.open();
})();