Skip to content

Instantly share code, notes, and snippets.

View dtinth's full-sized avatar
🎶
𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪

Thai Pangsakulyanont dtinth

🎶
𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪
  • @bemusic                 @creatorsgarten                 @eventpop                 @showdownspace                 @spacetme                @wonderfulsoftware                
  • Krungthepmahanakhonamonrattanakosinmahintharayutthayamahadilokphopnoppharatratchathaniburiromudomratchaniwetmahasathanamonphimanawatansathitsakkathattiyawitsanukamprasit (Bangkok), Thailand
  • YouTube @dtinth
View GitHub Profile
a[aria-label^="Review required"] {
background: #cb2431 !important;
color: white !important;
padding-left: 3px;
padding-right: 3px;
display: inline-block;
}
a[aria-label$="requesting changes"] {
color: orange !important;
}
@dtinth
dtinth / ioc.diff
Created January 29, 2017 17:43
Use an IoC container
function main () {
return Promise.coroutine(function * () {
- const logger = log4js.getLogger('main')
-
- logger.info('Loading certificate...')
- const JWT_CERTIFICATE_URL = requiredEnv('JWT_CERTIFICATE_URL')
- const certificate = (yield axios.get(JWT_CERTIFICATE_URL)).data
-
- logger.info('Connecting to MongoDB...')
- const DEFAULT_MONGO_URL = 'mongodb://127.0.0.1:27017/bemuse'
@dtinth
dtinth / unwieldy.js
Last active January 29, 2017 15:21
I think I need an IoC container…
function main () {
return Promise.coroutine(function * () {
const DEFAULT_MONGO_URL = 'mongodb://127.0.0.1:27017/bemuse'
const suppliedMongoUrl = process.env.MONGO_URL || process.env.MONGODB_URI
const db = yield connectMongo(suppliedMongoUrl || DEFAULT_MONGO_URL)
const factory = new MongoDBRepositoryFactory({ db })
const port = +process.env.PORT || 8008
const app = createApiServer({
logger: log4js.getLogger('HTTP'),
legacyUserApiKey: requiredEnv('LEGACY_USER_API_KEY'),

โจทย์หลักที่ต้องการแก้

เลขสามหลัก.filter(n => เงื่อนไข.every(ใช้ได้กับ(n)))

แก้ปัญหาย่อย

  • เลขสามหลัก
<!DOCTYPE html>
<style>
body {
background: black;
color: white;
font: 16px Courier New;
}
#header {
height: 32px;
position: relative;
<!DOCTYPE html>
<body style="background:url(./bg-devfest.jpg) center center no-repeat;background-size:cover;color:white;">
<div style="position:absolute;top:0;right:0;bottom:0;left:0;
background:url(./out-curve-1.svg) center right no-repeat;
background-size:contain;"></div>
<table cellpadding="0" cellspacing="0" style="position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%">
<tr>
<td width="25%" align="center">
<img src="./logo-devfest.png" width="85%">
</td>
require 'midilib'
name = ARGV[0]
raise "#{name} not exist" unless File.exist? name
parts_count = ARGV[1].to_i
raise "#{parts_count} must be more than 0" unless parts_count > 0
out_name = name.sub(/(?:_src)?(?:\.\w+)?$/, '')
const 管 = (a, f) => f(a)
const plus = (n) => (x) => x + n
const times = (n) => (x) => x * n
const ops = [ plus(1), times(2) ]
ops.reduce(管, 9) // 20
ops.reduceRight(管, 9) // 19
'use strict'
console.log('| items | Embedded literal | Runtime JSON.parse |')
console.log('| -----:| ----------------:| ------------------:|')
for (let n = 1; n <= 65536; n <<= 1) {
test(n)
}
function test (items) {
const data = generateTestData(items)
'use strict'
// Factory, correctly-refactored implementation:
const AutoMaker = {
// Use function literal to make this function constructable.
Car: function (bundle) {
// No one uses `this` to access static properties (e.g. bundle).
return Object.create(AutoMaker.bundle[bundle || 'premium']);
},