Skip to content

Instantly share code, notes, and snippets.

View dagezi's full-sized avatar

Takeshi Sasaki dagezi

View GitHub Profile

extension

return \ block extention function
original val apply also
block result run let

function

return \ block | extention | function

@dagezi
dagezi / yje.js
Created March 12, 2023 21:18
Yahoo JP estate bookmarklet
window.alert('name: ' + window.__SERVER_SIDE_CONTEXT__.page.property.StructureView.BuildingName)
def drawCube(x, y, scale = 1)
print <<-EOS
<g stroke="black" fill="none" transform="matrix(#{scale},0,0,#{scale},#{x},#{y})">
<rect x="50" y="100" width="90" height="90" />
<rect x="50" y="130" width="90" height="30" />
<rect x="80" y="100" width="30" height="90" />
@dagezi
dagezi / top.js
Created February 21, 2018 03:01
What's wrapping object?
console.log(this === global ? "global" : this)
var nstrict = function() {
console.log(this === global ? "global" : this)
}
var strict = function() {
"use strict";
console.log(this === global ? "global" : this)
@dagezi
dagezi / mtime_from_moi.rb
Created November 5, 2017 23:45
For Panasonic Videos.
# https://en.wikipedia.org/wiki/MOI_(file_format)
def get_date_from_moi(moi)
File.open(moi, "rb") { |file|
file.seek(6)
bytes = file.read(10)
y, mon, d, h, min, ms = bytes.unpack('nCCCCn')
return Time.new(y, mon, d, h, min, ms/1000)
}
end

Clean up a messy Git branch

It's very desired that every commit in the branch is organized well. One commit changes only one logical part. It shouldn't contain irrevant changes, such as one for UI and another for DB. Such changes must be separated into different commits.

  • It makes review easier.
  • It would help you dividing the big PR to a few logical PRs.
  • It makes easier to remove one logical change.
@dagezi
dagezi / Www.java
Last active September 14, 2017 06:33
Create WeakReferece out of the inner class!
import java.lang.ref.WeakReference;
public class Www {
public static void main(String args[]) {
Runnable r0 = create0();
Runnable r1 = create1();
System.gc();
r0.run();
r1.run();
# Trivial example: 2017-01-01 is part of the last week of 2016 because ISO week starts with the Monday.
irb(main):004:0> fd2017 = Date.new(2017,1,1)
=> #<Date: 2017-01-01 ((2457755j,0s,0n),+0s,2299161j)>
irb(main):005:0> fd2017.cweek
=> 52
irb(main):006:0> fd2017.cwday
=> 7 # Sunday
irb(main):007:0> fd2017.cwyear
=> 2016
@dagezi
dagezi / file0.txt
Last active April 17, 2017 10:13
VectorDrawableの穴を塞がないようにする ref: http://qiita.com/dagezi/items/3fd71a4c4c1cfd9cfcc0
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="40px" height="40px" viewBox="0 0 40 40" version="1.1" >
<path
d="M10,10 30,10 30,30 10,30 Z M15,15 25,15 25,25 15,25 Z"
fill="#ff0000" fill-rule="evenOdd" />
</svg>
@dagezi
dagezi / SubscribeLater.java
Created January 16, 2017 07:00
Why can "sub2" retrieve the first item of "src1"?
package hoge;
import rx.*;
import rx.schedulers.*;
import java.util.concurrent.TimeUnit;
// See the items in backpressure bufffer will be genereated
// for the observer who subscribed later?
public class SubscribeLater {