This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "yancya/php_sandbox", | |
| "authors": [ | |
| { | |
| "name": "yancya", | |
| "email": "[email protected]" | |
| } | |
| ], | |
| "require": { | |
| "mthaml/mthaml": "*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ROOMS = ['a', 'b'] | |
| rooms_order = ROOMS.map.with_index { |r, i| "WHEN '#{r}' THEN #{i} " }.join.yield_self { |s| "CASE room #{s} END"} | |
| Topic.where(room: ROOMS).order(rooms_order) | |
| #=> SELECT "topics".* FROM "topics" WHERE "topics"."room" IN ('a', 'b') ORDER BY CASE room WHEN 'a' THEN 0 WHEN 'b' THEN 1 END |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ROOMS = ['a', 'b'] | |
| rooms_table = ROOMS.map.with_index { |r, i| "('#{r}',#{i})" }.join(',').yield_self { |s| "(VALUES#{s}) as rooms(room, room_order)" } | |
| Topic.joins("join #{rooms_table} using(room)").order(:room_order) | |
| #=> SELECT "topics".* FROM "topics" join (VALUES('a',0),('b',1)) as rooms(room, room_order) using(room) ORDER BY "room_order" ASC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'pg' | |
| require 'tapp' | |
| def main(str) | |
| line_segments = str.split('/').flat_map { |sq| | |
| left, top, right, bottom = sq.chars.map { |i36| i36.to_i(36) } | |
| [ # ax ay bx by | |
| [left, top, right, top ], # top segment | |
| [right, top, right, bottom], # right segment | |
| [left, bottom, right, bottom], # bottom segment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TEMP TABLE "employees" ( | |
| "emp_code" text, | |
| "name" text, | |
| "valid_from" timestamp | |
| ); | |
| INSERT INTO "employees" VALUES | |
| ('001', 'Jane', '2019-01-10'), | |
| ('001', 'Tom', '2019-01-15'), | |
| ('001', 'Kevin', '2019-01-20'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // IE11 ใงใฏใใใใใๆธใใฆใใใชใใจ | |
| // 'ready page:load' ใฎใใใฏใๅใใชใไบใใใ | |
| // ็็ฑใฏใใใใชใ...... | |
| $(document).on('page:fetch', function() {}); | |
| $(document).on('page:restore', function() {}); | |
| $(document).on('page:change', function() {}); | |
| $(document).on('ready page:load', function() { | |
| // ็ฎๅฝใฆใฎๅฆ็ | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Array | |
| def +@ | |
| false | |
| end | |
| end | |
| class TrueClass | |
| def +(o) | |
| to_s + o.join(',') | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM ruby | |
| RUN apt-get update && apt-get install -y libpoppler-dev | |
| WORKDIR /var/app | |
| COPY Gemfile . | |
| RUN bundle # ใใใ | |
| # `RUN gem install poppler && bundle` ใ ใจๆๅใใ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| create temp table hoge(id integer, name text); | |
| with hoge_candidate(id, name) AS (values(1, 'hoge')) | |
| , inserted_hoge AS ( | |
| insert into hoge | |
| select hoge_candidate.* | |
| from hoge right outer join hoge_candidate using(id) | |
| where hoge.id is null returning *) | |
| select * from inserted_hoge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'open-uri' | |
| require 'nokogiri' | |
| require 'date' | |
| CALENDAR_ID = 'mem79137' | |
| today = Date.today | |
| 0.upto(5) do |n| | |
| month = today.next_month(n) |