Skip to content

Instantly share code, notes, and snippets.

@s2kw
s2kw / isPrototypeAbleToReferenceThisKeyword.js
Last active December 18, 2015 08:59
is prototype able to reference 'this' ?
function obj1(){
this.param1 = 1;
this.param2 = 2;
}
obj1.prototype.ProtoMethod = function(){
this.param1 = 11;
this.param2 = 22;
}
@s2kw
s2kw / io.gs
Last active December 18, 2015 15:09
Google Spreadsheet. read / write test.
/*
App -> SpreadsheetFile -> aSheet -> Range -> Cell/Value
*/
function readObject() {
objectPool = SpreadsheetApp.openById(read_sheet_id).getSheetByName('sheet1').getRange(1,1,20,20).getValues();
}
function writeObject(){
SpreadsheetApp.openById(write_sheet_id).getSheetByName('sheet3').getRange(1,1,20,20).setValues(objectPool);
require "google_drive"
session = GoogleDrive.login( acc, pass) # セッションを取得
ss = session.spreadsheet_by_key('key') # keyはURLに入ってるパラメータ
ws = ss.worksheet_by_title('title') # googleはワークシートって言ってなかった気がするけどworksheetで取得する
p ws.rows # これで中身みれる
max_r = ws.max_rows()
max_c = ws.max_cols()
for rows in 1..max_r # cellにアクセスするので1から。配列なら0からだけど。
for cols in 1..max_c # 実際、0で開始するとエラーが出る。
p ws[rows, cols]
@s2kw
s2kw / subviews.rb
Created August 31, 2013 05:22
REPL
subview.methods.each do | method | p method end
@s2kw
s2kw / ButtonController.rb
Last active December 22, 2015 04:59
RubyMotion Test Tutorial.
class ButtonController < UIViewController
def viewDidLoad
super
@button = UIButton.buttonWithType(UIButtonTypeRoundedRect)
@button.setTitle( "Test me title!", forState:UIControlStateNormal )
# ここの文字列で検索がされる
@button.accessibilityLabel = 'Test me!'
@button.sizeToFit
@s2kw
s2kw / Base.cs
Last active February 3, 2016 08:07
Inherit Nested Class.
using UnityEngine;
using System.Collections;
public class Base : MonoBehaviour{
protected class State
{
const int cddc = 0;
}
}
@s2kw
s2kw / Question1Editor.cs
Created October 6, 2013 14:45
CodeIQ presents, Unity Editor Seminar. Question1. I checked How to use MenuItem's 2nd argument.
using UnityEngine;
using UnityEditor;
using System.Collections;
public class Question1Editor : Editor {
[MenuItem("Editor10/Question1")]
static void Question1_Basic(){}
[MenuItem("Editor10/Question1_ #&n",false)]
static bool Validateaaa()
using UnityEngine;
using UnityEditor;
using System.Collections;
public class Question2Editor : EditorWindow {
[UnityEditor.MenuItem("Editor10/Question2/EditorWindow #&w")]
static void Q2_Basic()
{
// CreateInstance<Class name>複数のウィンドウを作成する
@s2kw
s2kw / ImageLinkFromGoogleDrive.js
Created January 23, 2014 05:52
google drive に upload した image を right click -> open -> drive viewer で開き この bookmarklet を実行するだけで direct link uri が get できちゃいます。
javascript:
var reg = /^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
var m = location.href.match(reg);
var params = m[5].split("/");
var id = params[3];
window.alert("https://drive.google.com/uc?export=view&id=" + id);
@s2kw
s2kw / StaticGenericTest.cs
Last active January 4, 2016 07:59
staticでgenericなやつは都度生成される。的なコード。
using System;
using System.Collections.Generic;
namespace ConsoleApplication1
{
public static class SampleClass <T>
{
public static T Member {get;set;}
static SampleClass()
{