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
require 'midilib'
seq = MIDI::Sequence.new()
File.open(ARGV[0], 'rb') { |file| seq.read(file) }
events = [ ]
id = 0
seq.tracks.each do |track|

Sort by (predicted) satisfaction

Based on an article: How Not To Sort By Average Rating

This code snippet sorts the restaurant listing in Foodpanda.co.th by using the equation from the above article.

Assumptions: Since the article is for binary rating (+/−), I’m going to make an assumption that the stars represent the proportion of delighted customers. For example, if a restaurant gets 4.5 stars and has 2,000 reviews, it is assumed that there are 1,800 delighted customers out of 2,000.

Usage:

@dtinth
dtinth / nwb.config.js
Created March 2, 2016 06:38
wonderstudio nwb config
'use strict'
module.exports = {
// Let nwb know this is a React app when generic build commands are used
type: 'react-app',
loaders: {
'stylus-css': {
query: {
modules: true,
localIdentName: '[name]の[local]/[hash:base64:7]',
require 'tmpdir'
require 'digest'
# Returns the MP3 file name and other meta information about a BMS.
# XXX: This should be split into two functions.
def get_name(file)
data = File.read(file, encoding: 'Shift_JIS')
attrs = { }
data.scan(/\n\s*?#(TITLE|GENRE|ARTIST|STAGEFILE)[ ]+(.+)/i) do
attrs[$1.downcase] = $2.encode('UTF-8').strip
export function Checkbox (props) {
return <div style={{ margin: '8px 16px' }}>
<MaterialCheckbox
label={props.label}
checked={props.checked}
onCheck={e => {
props.onPropChange('checked', !props.checked)
if (props.onchange) props.onchange(e)
}}
disabled={props.disabled}
// Wow cool hack to generate a manifest on-the-fly!!
var manifest = {
short_name: inferApplicationName({ app: this.props.app }),
icons: [
{
src: 'https://ss16-wonderstudio.firebaseapp.com/images/default_icon.png',
sizes: '144x144',
type: 'image/png'
}
],
@dtinth
dtinth / _README.md
Last active January 21, 2016 16:41
My Atom hack for speed coding (for CodeHew 2016)

My Atom hack (init script) for speed programming in Ruby. This code is very ugly but works.

Features

Upon saving,

  • Ruby code in the specified directory is run.
  • Test input data (after 1st __END__ but before 2nd __END__) is sent to the script via stdin.
  • Output and/or errors are displayed in a popup.
  • Program output is compared to test output data (after 2nd __END__). If it matches, then the popup becomes green.
function renote () {
var text = clipboard.readText()
var lines = text.trim().split(/\r\n|\r|\n/).slice(1)
var out = ['iBMSC Clipboard Data xNT']
var nextColumn = 5
var columns = { }
var moved = 0
var items = document.querySelector('#input').value
var COLUMN_MAP = {
a: 12,
# Requirements:
# 1. Install Ruby
# 2. gem install midilib
#
# To run:
#
# ruby split-notes.rb <file.mid> <number-of-parts>
require 'midilib'