Skip to content

Instantly share code, notes, and snippets.

Avatar

Atsushi Nagaki nagaki

View GitHub Profile
@nagaki
nagaki / Vagrantfile
Created May 11, 2017
vagrant-ubuntu-oracle-xeの共有フォルダ、タイムゾーン設定変更
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
@nagaki
nagaki / gmaps.js
Created Aug 24, 2015
Google Maps JavaScript APIのスタイルカスタム
View gmaps.js
var map;
window.initMap = function() {
var myLatLng = {
lat: <%= data.corp.latitude.value %>,
lng: <%= data.corp.longitude.value %>
};
var mapOptions = {
@nagaki
nagaki / markdown.rb
Last active Jan 28, 2016
MarkdownをHTMLにするスクリプト
View markdown.rb
# coding: utf-8
require 'rubygems'
require 'bundler/setup'
require 'redcarpet'
require 'pygments'
# マークダウンのファイル名をkey
# タイトルをvalueとしてセット
@names = {
index: "ホーム",
View get_services.rb
require 'open-uri'
require 'nokogiri'
doc = Nokogiri::HTML(open('http://www.heartrails.com'))
doc.search('//td[@class="services_table"]').each do |s|
p '------------------------------'
p s.search('p').text
p s.search('a')[0].attributes["href"].value
end
@nagaki
nagaki / com.brew.update.plist
Created Aug 4, 2014
Automatic brew update by Launchd Agent
View com.brew.update.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.brew.update</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
@nagaki
nagaki / best_before_date.js
Created Jul 16, 2014
Adobe PDFのフォームに賞味期限を自動で入力する
View best_before_date.js
var f = this.getField("BestBeforeDate");
var d = new Date();
d.setYear(d.getFullYear() + 2);
f.value = util.printd("yyyy.m.d", d);
@nagaki
nagaki / console.js
Last active Aug 29, 2015
気象庁の天気データ「日ごとの値」から、JavaScriptでデータを取得する
View console.js
// 気温
var a = []; jQuery.each($('#tablefix1')[0].rows, function(i, val){ if(i > 3){a.push(parseFloat(val.cells[7].innerHTML));}}); console.log(a);
// 天気
var a = []; jQuery.each($('#tablefix1')[0].rows, function(i, val){ if(i > 3){var s = val.cells[20].innerHTML[0]; var p; switch(s){ case "晴": case "快": p = 1; break; case "曇": p = 2; break; case "雨": case "雪": case "大": p = 3; break; default: p = 2;} a.push(p);}}); console.log(a);
@nagaki
nagaki / python-simplehttpserver
Last active Aug 29, 2015
ワンライナーでサーバーを起動する
View python-simplehttpserver
python -m SimpleHTTPServer 8888 &
@nagaki
nagaki / create-db-and-user.md
Last active Dec 24, 2015
MySQLでDatabaseを追加して、Databaseユーザーを追加するやり方
View create-db-and-user.md

Create database

CREATE DATABASE SAMPLEDB;

Add Database User

GRANT ALL ON SAMPLEDB.* TO 'admin'@'localhost' IDENTIFIED BY 'password';
@nagaki
nagaki / example.html
Created Oct 1, 2013
SVG FontのXML書式とスタイルシートからの呼び出し方
View example.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>Example</title>
<style>
@font-face {
font-family: 'Example Sans Serif';
src: url(g.svg) format('svg');
font-weight: normal;