Skip to content

Instantly share code, notes, and snippets.

Avatar

Satoh, Hiroh cho45

View GitHub Profile
View 00README.md

問題・目的

  • 特定のスプレッドシートだけを外から更新したい
  • OAuth は大変めんどうかつ、特定のスプレッドシートのみ権限を与えることができない
  • Google Spread Sheet の XML API が全力で面倒

方法

  1. いじりたいスプレッドシートで [ツール] → [スクリプトエディタ…] を開く (Google ドライブの新規作成から、スクリプトを選んでもいい)
  2. スクリプトエディタに code.gs の内容をはっつける。
View set_default_browser.swift
#!/usr/bin/xcrun swift
import Cocoa
struct ProgramOption {
var list : Bool = false
var set : String? = nil
var help : Bool = false
}
View parseIRCMessage.js
function parseIRCMessage (text) {
var fg = 0;
var bg = 0;
var fl = 0;
var ss = text.split(parseIRCMessage.re);
var ret = [];
var state = {};
for (var i = 0, len = ss.length; i < len; i++) {
text = ss[i];
if (!text) continue;
View hatena.diary.for-writing.user.js
// ==UserScript==
// @name Hatena::Diary: for writing
// @namespace http://lowreal.net/
// @include http://d.hatena.ne.jp/*gihyo/*
// @require https://gist.github.com/3239.txt#createElementFromString
// @require https://gist.github.com/3238.txt#$X
// @require https://github.com/cho45/jsdeferred/raw/master/jsdeferred.userscript.js
// ==/UserScript==
// つかいかた:
//
View uneval.js
if (typeof uneval != "function") {
uneval = function (o) {
switch (typeof o) {
case "undefined" : return "(void 0)";
case "boolean" : return String(o);
case "number" : return String(o);
case "string" : return '"' + o.replace(/[^a-z]/gi, function (_) { return '\\u' + (0x10000 + _.charCodeAt(0)).toString(16).slice(1) }) + '"';
case "function" : return "(" + o.toString() + ")";
case "object" :
if (o == null) return "null";
View format-number-with-si-prefix.js
function formatN (n) {
const unitList = ['y', 'z', 'a', 'f', 'p', 'n', 'u', 'm', '', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
const zeroIndex = 8;
const nn = n.toExponential(2).split(/e/);
let u = Math.floor(+nn[1] / 3) + zeroIndex;
if (u > unitList.length - 1) {
u = unitList.length - 1;
} else
if (u < 0) {
u = 0;
View NyanCat.pm
=pod
Nyan Cat TAP Formatter
1. Save this file into your PERL5LIB
2. Run prove with option like following:
$ prove --formatter NyanCat
http://www.mattsears.com/articles/2011/11/16/nyan-cat-rspec-formatter
View sine.js
//#!node
const sleep = (n) => new Promise( (resolve) => setTimeout(resolve, n) );
const asciichart = require('asciichart')
const screen = {
clear: function () {
console.log('\x1b[2J');
},
View ITU-T G.227.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View niz-sketch.rb
#!/usr/bin/env ruby
require "hid_api" # gem install hid_api
require "pp"
COMMAND_READ_ALL = 0xf2
COMMAND_VERSION = 0xf9
COMMAND_READ_COUNTER = 0xe3
COMMAND_INITIAL_CALIB = 0xdb
COMMAND_PRESS_CALIB = 0xdd
#COMMAND_WRITE_ALL = 0x00