Skip to content

Instantly share code, notes, and snippets.

@alexmcpherson
Created September 25, 2014 18:15
Show Gist options
  • Save alexmcpherson/1a8cce1f8c0f0330f117 to your computer and use it in GitHub Desktop.
Save alexmcpherson/1a8cce1f8c0f0330f117 to your computer and use it in GitHub Desktop.
markov
var util = require('util');
function Markov(){
this.chain = {};
};
Markov.prototype = {
digest: function(corpus) {
var currentWord, words = corpus.split(/\s+/);
for (var i = 0; i < words.length; i++) {
currentWord = words[i];
nextWord = words[i + 1];
this.chain[currentWord] = this.chain[currentWord] || [];
this.chain[currentWord].push(nextWord);
}
},
pick: function(seedWord) {
var potentialWords = this.chain[seedWord] ?
this.chain[seedWord] :
this.chain[this.getRandomWord()];
return potentialWords[Math.floor(Math.random() * potentialWords.length)];
},
getRandomWord: function() {
var keys = Object.keys(this.chain);
return keys[keys.length * Math.random() << 0];
},
generate: function(length, seedWord) {
var currentWord = seedWord || this.getRandomWord();
var output = [];
for (var i = 0; i < length; i++) {
output.push(currentWord);
currentWord = this.pick(currentWord);
}
return output.join(' ');
}
};
var m = new Markov();
// m.digest("Also, because we use this to determine resourcing and have conversations with clients regarding start dates of projects, it is important that you remember to add your PTO to the Team Calendar once it's approved. If you don't have access to the team calendar, please let Amanda know and she'll get you set up. Hey team, I wanted to quickly let you know about a change I've made to the dev resource spreadsheet in case you happen to look at it and wonder what's going on. Weeks where people have any PTO scheduled are now marked in black, and the days that person is out will be indicated in parenthesis. So for example, the screenshot below shows someone out on Wednesday, Thursday, Friday and Monday of the following week. Hey peeps, Skud and I are stuck in traffic on 93 that isn't moving. And it hasn't moved much in the last 20 minutes. So we're both available via email and slack if you're looking for us. Hey team! I wanted to shoot out some great news on the hiring front. We put out 3 offers for consulting developers this week and all 3 accepted. Mike Kauffman (gSchool grad) will be starting September 8th Keri Clowes (gSchool grad) will be starting September 15th Michael Phillips (engineer coming from Crush & Lovely in NYC) will be starting September 22nd Let me know if anyone has questions! Thanks, - JC I'm back in the saddle and WFH the rest of the week after leg surgery. It was more complicated than they thought once they opened my leg up and saw the ligament damage. They ended up having to add more hardware, specifically a really cool stabilization wire that runs directly through both the tibia and the fibula. I'm supposed to keep it elevated above my heart for the first week, so that's what I'm doing. I'll go back next Tuesday morning and they will take off the closed splint they put me in and I'll likely be back in a boot at that time. I'm renting one of those wheelie things so I can get around better, and I'm shooting for next Wednesday to be back in Boulder on a regular basis. I cancelled my Portland trip this week, but will try to get out there in a couple weeks or so. Hit me up on any of the normal channels if you need me. I wanted to clarify some things around hiring, since I know some of you have been working to send referrals our way (which we love, thank you!!). While we're nearing the magical 49 person goal that we set for this year, we're ready and willing to grow beyond that number if the pipeline warrants it! We're always looking for awesome talent, so keep those referrals coming and don't hesitate to spread the word that Quick Left is always looking for top talent. In this business, we always have to be conscientious about hiring and the sales pipeline, and we're constantly balancing things to make sure we have the team we need to deliver for our clients. Do things get more complicated once a business goes past 49 employees? Yes. But we're ready to make that leap if we need to.");
// m.digest("@aroc I can show you if need be, but I'd recommend first looking at structuring your tests such that you don't need fakeServer. I found a way around that in sprint.ly Yep. @aroc: Yes... the first answer is probably don't. If that's not good enough I can point you towards some things, but why are you trying to do XHR inside node? @chrisforrette: I never have, no What about splits involving irrational numbers? :stuck_out_tongue: Jump • @blair: ^^ Jump • I could be down for, well any of those Nice. ^^bbonifield The commit sha is stored as a blob so I think `git show HEAD:path/to/submodule` should work, but my memory is flaky. I should write this test... maybe later right. Best if one actually writes the tests at some point :stuck_out_tongue: If you put in an 'it()' block in the tests but don't provide an implementation it treats it as pending. Agreed... but at least they set the grunt-cli up such that all it does is look up the grunt installed in the local project and launch it. nicholasserra: `npm i -g grunt-cli` if you don't wan't to type out the full path alex++ That's pretty awesome Mon, 1Gbps is pretty standard, higher is rare (except maybe specialized SANs and datacenters) Mon, Sure it *can* but not at any normal price points. Mon, In the name of pedantry (apologies in advance) it should be Mbps... MB or Mb wouldn't be a internet speed, just an amount of data. Now 10GB I can't even figure out what's intended, except for maybe 10GB/hour :stuck_out_tongue: sambreed: I always think that features cool... and then promptly forget about it. And I opened a pull request this morning. @chrisforrette: yep! `npm install --save-dev git+http://github.com/h/node-source-map-support.git and add `require('source-map-support').install();` to test suite. It only works in chrome, so firefox/IE bugs will stick suck :disappointed: @aroc: @chrisforrette FYI in addition to the solution I help chris setup for command line stack traces there's a npm mode node-source-map-support that fixes the stack traces display when running in chrome. I ended up forking it because of a a performance issue @aroc: window is usually fine (unless the reference it in weird ways like using `this`) what get's me is when the file I'm trying to pull in was built in such a way that there are statements that browserify tries to process as requires and blows up on... yet to find a good way to handle that other than bypassing browserify @aroc: I will say browserify-shim doesn't always work... between that and blair's point probably best to get mocha-phanomtjs working but thought I'd point it out. Yup that's the one @aroc: Two things,. First as an aside have you looked into pulling in your vender js with browserify-shim instead of through HTML? Second look at mocha-phantomjs there are wrappers for both gulp and grunt @aroc: I've done some stuff like that... looking for advice or running into trouble? I think it's a bad sign when angular best practices seem to become: don't use angular for most of your code. qbot vote 2 Thu, @justinabrahms: I think I've read about algorithms for doing calculations on encrypted data without decrypting it... pretty sure it's still completely impractical, but crazy. Thu, I'm going to agree with @nonsensery on the pedantry... google drive has point to point encryption and I'd assume they also have encryption at rest (though I can't verify that), but those things do not make end-to-end encryption. @bbonifield: That sounds less contradictory with experience, but still makes no sense. @Thu, Oh wow, these slides go on forever Cool... you also missed the date, I'll fill it in and hand it off As if I needed more reasons to fear require.js... @justinabrahms The PDF you sent has no printed name (the form is admittedly missing the field). Want me to put it on or would you like to send one with it somewhere. Suddenly nervous about someone recording network traffic in the office")
m.digest("I find it upsetting oh? I'ma take dat If someone who borrowed my keyboard could give it back, um, then I would have one. you'll still want to use those tools to manage ruby, rather than apt feel free to (and you'll probably have to) install rvm rbenv globally on your machine/server/whatever as-such, ruby packaged by ubuntu is probably not packaged by rubyists basically ,the ruby community has refused to support efforts by os vendors to ship rubies because the problem is already solved since it's a 'property' of an object and ruby doesn't really allow you to do that without a method but there are a lot of missing optional parenthesis, there I don't actually know if alpha is going to ship on the 30th as deadline isn't a word that has strong meaning, as far as I understand Ok, I don't think it will be 11th hour -- I'd reach out to Ann-Marie and confirm that they don't need me to help close out alpha I know we've had this conversation a few times is a smell that you are not communicating effectively or using a persistent medium for those conversations. Id size that at a 3 -- I can probably help you with that. Also, given recent revelations, I would just mark it as done, or toss it back to Jenn to see if she actually wants it at all. Sounds like a reason not to drive a subaru Im realizing that after 6 months of answering the questions what does Did you have to escalate any issues last week? actually mean for me at Dātu")
// console.log(util.inspect(m, {showHidden: false, depth: null}));
console.log(m.generate(50));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment