This file contains 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
# Get a URL's content to play with | |
content = contents[contents.keys.first] | |
# => [#<Nokogiri::XML::Element:0x48a9a86 name="p" children=[#<Nokogiri::XML::Text:0x48a9810 "The autobiography of Yohwan Lim, ">, #<Nokogiri::XML::Element:0x48a96ee name="i" children=[#<Nokogiri::XML::Text:0x48a9536 "Crazy As Me">]>, #<Nokogiri::XML::Text:0x48a931a " was released in Korea by BookRoad Publishers in October 25, 2004. This is my translation of the book, except the following four sections which were translated by BinaryStar of Teamliquid.net, which I have made minor changes: \"Hope on the Road Not Taken,\" \"Chapter One: The Game-crazed Kid,\" \"The Birth of the Emperor,\" and \"The Little Prince with Three Sisters.\"">]>, #<Nokogiri::XML::Element:0x48a9194 name="p" children=[#<Nokogiri::XML::Text:0x48a9022 "As of October 4, 2004:">]>, #<Nokogiri::XML::Element:0x48a8e92 name="p">, #<Nokogiri::XML::Element:0x48a8ce4 name="p" children=[#<Nokogiri::XML::Text:0x48a8af0 "The addition of e-sports organizations to major compani |
This file contains 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
client.on('message', message => { | |
if (!message.content.startsWith(prefix) || message.author.bot) return | |
let user = message.mentions.users.first() | |
const args = message.content.slice(prefix.length).split(/ +/) | |
const command = args.shift().toLowerCase() | |
if (command === 'marry') { | |
if (!user) return |
This file contains 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
const { details } = resp.Result | |
const keyMatch = i => | |
`InternetGatewayDevice.TraceRouteDiagnostics.RouteHops.${i}.HopErrorCode` | |
for (let i = 1; i < details.length; i++) { | |
let resp2 = details.find(x => x.key == keyMatch(i)).value | |
return resp2 | |
} |
This file contains 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
function extractParamStrings(s) { | |
if (s[0] === '?') s = s.slice(1, s.length) | |
return s.split('&') | |
} | |
const extractParamKeyValPair = paramString => | |
paramString.split('=').map(decodeURIComponent) | |
const addParam = (toObj, [key, val]) => { | |
toObj[key] = val |
This file contains 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
export function fromUrlQuery(str) { | |
if (!str) return {} | |
if (str[0] === '?') str = str.slice(1, str.length) | |
return str.split('&').reduce((acc, vars) => { | |
const [key, val] = vars.split('=').map(decodeURIComponent) | |
acc[key] = val | |
return acc | |
}, {}) |
This file contains 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
const ret = str.split('&').reduce((acc, vars) => { | |
const [key, val] = vars.split('=').map(decodeURIComponent) | |
console.log('fromURLQuery', { key, val }) | |
acc[key] = val | |
return acc | |
}, {}) |
This file contains 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
for (let i = 0; i < vars.length; i++) { | |
let pair = vars[i].split('=').map(decodeURIComponent) | |
ret[pair[0]] = pair[1] | |
console.log('fromURLQuery', pair) | |
} |
This file contains 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
export function fromURLQuery(str) { | |
console.log('fromURLQuery BEGIN', str) | |
if (!str) { | |
console.log('fromURLQuery return empty', ret) | |
return {} | |
} |
This file contains 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
export function fromURLQuery(str) { | |
console.log('fromURLQuery BEGIN', str) | |
let ret = {} | |
if (!str) { | |
console.log('fromURLQuery return empty', ret) | |
return ret | |
} | |
if (str[0] === '?') str = str.slice(1, str.length) |
This file contains 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
export function fromURLQuery(str) { | |
console.log('fromURLQuery BEGIN', str) | |
let ret = {} | |
if (!str) { | |
console.log('fromURLQuery return empty', ret) | |
return ret | |
} | |
if (str[0] === '?') str = str.slice(1, str.length) | |
let vars = str.split('&') | |
for (let i = 0; i < vars.length; i++) { |
NewerOlder