Skip to content

Instantly share code, notes, and snippets.

View watagashi's full-sized avatar
🏠
Working from home, except for the weekend.

WADA Takashi watagashi

🏠
Working from home, except for the weekend.
View GitHub Profile
@watagashi
watagashi / string.js
Created September 8, 2011 14:04
#tkbjs p.101-
// p.101
// String
var name= 'Curly';
var initial = name.charAt(0);
var s = 'C'.concat('a', 't');
var text = 'Mississippi';
var p = text.indexOf('ss');
p = text.indexOf('ss', 3);
@watagashi
watagashi / method.js
Created September 8, 2011 13:15
Online Study TokyoBouldering.js – Lingr http://lingr.com/room/tkbjs/
Function.prototype.method = function (name, func) {
if (!this.prototype[name]) {
this.prototype[name] = func;
return this;
}
};
String.method('entityify', function () {
var character = {
'<' : '&lt;',
function press(e) {
if (e != 1) key_press_detected = true;
if (e != 1 && (e.keyCode != 13 && e.keyCode != 10 ||
!decr_enter && (e.ctrlKey || e.shiftKey) || decr_enter && !(e.ctrlKey || e.shiftKey)) )
return true;
var st = document.frm.status;
if (!key_press_detected) st.value = st.value.replace(/\n/g, "");
if (st.value == '') {
update();
return false;
registerPlugin({
newMessageElement: function(elem, tw) {
tw = tw.retweeted_status || tw;
if (tw.entities && tw.entities.media) {
for (var i = 0; i < tw.entities.media.length; i++) {
if (tw.entities.media[i].type == "photo") {
addThumbnail(elem,
tw.entities.media[i].media_url + ":thumb",
tw.entities.media[i].media_url + ":large");
}
@watagashi
watagashi / measuresapierror.js
Created July 28, 2011 15:23
twicli plugin, measures againt API errror
function twAuthFallback() {
// verify_credentials API is unavailable?
re_auth = true;
xds.load_default(twitterAPI + "users/show.json?suppress_response_codes=true&screen_name="+myname, twAuth);
}
function auth() {
if (use_ssl)
twitterAPI = twitterAPI.replace('http', 'https');
var name = readCookie('access_user');
if (name) {
var n = [4, 8, 15, 23, 42];
n.sort();
n.sort(function(a, b) {
return a-b;
});
var m = ['aa', 'bb', 'a', 4, 8, 15, 16, 23, 42];
m.sort(function(a, b) {
if (a === b) {
return 0;
}
var a = ['a', 'b', 'c'];
var b = ['x', 'y', 'z'];
var c = a.concdat(b,true);
a.push('d');
var c = a.join('');
var a = ['a', 'b', 'c'];
var c = a.pop();
Function.prototype.method = function (name, func) {
if (!this.prototype[name]) {
this.prototype[name] = func;
return this;
}
};
Array.method('reduce', function (f, value) {
var i;
for (i = 0; i < this.length; i+= 1) {
// Merged to master
// https://github.com/NeoCat/twicli/commit/24f73ae0ea054a33ed3e5ff83da28aaab641a061
powershell.exe -Command "& {Get-ChildItem|Where-Object{$_.Name -notmatch '^\.hg'}|Remove-Item -Recurse}"