Welcome

Hey there, welcome to my little space on the net.

Friday, December 18, 2020

javascript - throttles

I asked someone to write a throttle to restrict requests to the server and they didn't understand how. So I wrote this basic thing to show it. Sorry it's not pretty or anything, but here's two types of throttles in raw JS


// simplest lock - 1 request every x seconds


let timerLock = false; // this is the lock

const requestValues = []; // this is where all the data goes


var handleChange = (someValue) => {

  if(!timerLock){ timerLock = true; setTimeout(handleServerRequest, 4000) } // set the lock

  requestValues.push(someValue);

}


var handleServerRequest = () => {

  timerLock = false; // release the lock

  console.log(requestValues);

  console.log( 'fetch', requestValues.pop() )

  requestValues.length = 0; // clear the array

}

handleChange(1)

handleChange(2)

handleChange(3)

 

// fancier lock - trying to detect when the user stops typing

let timerLock = false; // this is the lock

const requestValues = []; // this is where all the data goes

let timerId = null;


var handleChange = (someValue) => {

  if(!timerLock){ timerLock = true; timerId = setTimeout(handleServerRequest, 300) } // set the lock

  else{

    clearTimeout(timerId); timerId = setTimeout(handleServerRequest, 300); // dont fire that request yet! set the timer again

  }

  requestValues.push(someValue);

}


var handleServerRequest = () => {

  timerLock = false; // release the lock

  console.log(requestValues)

  console.log( 'fetch', requestValues.pop() )

  requestValues.length = 0; // clear the array

}

handleChange(1)

setTimeout( () => { handleChange(2) }, 200 )

setTimeout( () => { handleChange(3) }, 400 )


Monday, August 3, 2015

Fish Oil + Magnesium Threonate

So after watching this..

http://fourhourworkweek.com/2015/07/21/charles-poliquin/

I finally decided to give magnesium a shot.  And then I just got sold on the fish oil at the same time.

Anyways, so my little story goes like this..

purchased these guys:

Designs for Health Omegavail Ultra with D3, K1, K2 Softgels, 120 Count -
http://www.amazon.com/gp/product/B00403DOR4

and

Vitacost Magtein Magnesium L-Threonate -- 2000 mg - 90 Vegetarian Capsules -
http://www.amazon.com/gp/product/B007VWBM2U

dinner ~ 9pm -> 1 serving of each -> video games -> slept at 11:30 (a little early)

The wife wakes me up to get milk for the baby.  I get up.. go about my routine and notice that I'm up an hour/an hour and a half earlier than normal and I'm feeling more awake than usual.

Caveats:
I've been doing 3 days of 2/5 style fasting and 2 days of slow carb for about a month and a bit.. I eat whatever I feel like for dinner but try to stay refined carb conscious and the weekends is whatever goes.

Continued results:
In general, I feel like the magnesium (or fish oil.. who knows) is getting me to bed slightly earlier and it feels like I'm getting an hour and a half or an hour of extra sleep a night (on top of the extra sleep)..

Although.. my eyes are burning in the morning.. so not sure how I feel about using it continually..

Wednesday, October 29, 2014

The state of Diablo 3: RoS 2.1 - skills and items

I've been playing Diablo 3 again casually since RoS came out, and I've recently decided to stop playing.. for the most part..

It's strange to see Diablo on the same general trajectory as WoW.. where each update opens up builds but manages to trivialize "content" at the exact same time. It's definitely disheartening when you can actually see the treadmill.

I'm the kind of player that likes to mess with odd-ball builds.. and this iteration re-establishes the major flaws in design direction.  I think it hurts just a bit more because I went with wizard for RoS

so.. what's wrong?

1. Certain class sets are too powerful.
A couple of points on this one.. Skill choice should be determined by equipment and vice versa.. but this is kind of ridiculous.  The skills are insignificant compared to the equipment now

2. Trinities (and the like) still exist even after legendary gems
Originally I had thought that legendary gems would open up new possibilities.. but the needle hasn't moved.. mostly because of sets determining gem choice

3. Extreme specialization is still king
I get that synergy is fun.. but heavy specialization in a game where only one specialization works.. is kind of sad.

4. The math.. just doesn't add up
Weapon damage % and dps calculation make it very obvious what skills/items are good or bad.. I'm not sure why these skills don't just see a big increase to make them viable.

Instead of complaining.. what would I like to see?

Let's make every skill awesome 
without having to obtain X pieces of legendary/set items.  How about a secondary passive skill system that lets you augment 2 or 3 skills similar to how items are doing now?  For sure one of the major selling points of this game is that it just looks and feels good (although I'd still argue that left click should be force move).. let's make that the central point of gameplay

Why no combos?
It's interesting that there are no official links between skills.. and we're instead given the generator/spender system.. I think it'd be way cooler to have leap xx ground stomp or teleport xx wave of force have interactions.. we can go on here.. blizzard xx frozen orb.. sentry xx caltrops.. wall of zombies xx zombie charger etc etc..

I get that the UI would be ridiculously complicated.. but I wouldn't mind having to read a giant FAQ of known interactions or have the community discover them

Items should be really cool.
Essentially.. items, now, are being used like additional skills. They shore up the weakness of the original design concept of 6 skills.  So why don't we just make them more like general skills? Some of the items are already doing so like thunder fury, haunt of vaxo, maximus, scourge etc.. procs and abilities should be the base line.. but let's de-couple legendaries and skills so that they add flavor and aren't specifically designed with the skill in mind

Synergies between items and skills should just be based on buffs/debuffs.  Let's throw away proc coefficients (although I do love em) so that we don't have to worry about scaling and make aspd stand out a little bit more

Also.. random proc with internal cooldown is kinda weird..

Element %/CC/CHD
I'm sure some people like it.. but I find element % a really boring system.  I get that it helps keep the item hunt going.. but I think looking for the perfect xyz is more fun than having to find perfect xyz for each element

Crits are fun.. they've always been fun.. but it's boring if I have to have it. Maybe making area damage relevant (like hits the primary target too) or something can help in this case.. but it's especially annoying because p400 with cc/chd is a huge breakpoint because of the way it scales

And that's about it.. it's probably not gonna happen but I really needed to write these thoughts down especially if I ever want to make an ARPG (this is probably not happening)

Tuesday, August 5, 2014

Caverna - first impression

I played one round of 4 player Caverna last night, and I think I see why a lot of people prefer Agricola, but I'll try to break it down.

Variation and Randomness

There's definitely less variation/randomness.. kind of.  I mean, Agricola has variation, but really if we used a 1 to 5 scale to see how you differentiated your final play decisions it'd look something like
1 - crops
5 - animals
1 - occupations
3 - improvements
4 - family growth
Really the cards are just telling you how to play.. which is fine i guess.  Or if you draft (which you should) you get a little bit of say in what branches you'll go in.

In Caverna, it's really starting order and people knowing that they should challenge for certain things. You could play each game the same.. but why would you? I mean especially if you lost the last time.. you're probably going to want to try something else.

Investment

Investment is MUCH easier in Caverna since the point system is very straightforward and the combos are much shorter.  It changes the risk ratio but then you don't have players who don't know the value and usage of the card beehive for example.

Also, it's much more difficult to support a large population of dwarves because there are no big automated food engines.

Play Order and Conflict

Part of the weirdness of Caverna compared to Agricola.. is the order in which things happen.  The first conflict is crops vs expansion vs (ore mine/adventuring) in contrast to Agricola's sheeps vs occupation vs wood (maybe crops if you've got stuff to make it work or you're playing the expansion).

The one thing that I really like are the gems though.  It's a very cool system that values flexibility and incentivizes taking starting player which livens play up.

Day One Assessment

Just a couple thoughts.  Keep in mind this is a view from a single game and we only played with the primary 12 furnishings so I'm not sure what the other ones can do.

  • It's weird not being able to get cows without adventuring
  • I don't understand the need for the stone/ore stage card
  • Misreading the ruby mine to be like the ore mine was bad
  • Gems are really fun
  • Dogs are awesome
  • Blocking doesn't hurt you as bad as it could in Agricola.. (those ridiculous traveling players combos)
  • Feels much more like Agricola: Farmers of the Moor in that you can win in a lot of ways

programming with javascript - lesson two - variables


Variables

Variables are where we store information for our program to interact with.  They're kind of like words and you get to define what they mean!

Here are the types of variables that exist in Javascript (JS) and how we can make them

Ignore the console.log() stuff for now.. it's basically a way for you to see what is in your variable and to see what the program thinks is in that variable.

String
strings store text.. so any number of numbers, characters and special characters.  So stuff like aA$d!13. Strings have to start and end with either ' or ".  No mixing allowed.

var thisIsAString = 'hello'
var thisIsAlsoAString = "123hello"
var evenThisIsAString = '!@#$h21i(*'
console.log( thisIsAString )
console.log( thisIsAlsoAString )
console.log( evenThisIsAString )

Integer
this stores whole numbers so like 1, 10, 12, -13, 0 (negative or positive are ok)

var thisIsAnInteger = 10
var thisIsAlsoAnInteger = -100
var evenThisIsAnInteger = 0
console.log( thisIsAnInteger )
console.log( thisIsAlsoAnInteger )
console.log( evenThisIsAnInteger )

Number
why do we need a number type? because numbers can store fractions

var thisIsANumber = 10.01
console.log( thisIsANumber )

Boolean
a fancy word for true or false

var thisIsABoolean = true
var thisIsAlsoABoolean = false
console.log( thisIsABoolean )
console.log( thisIsAlsoABoolean )

Array
these are basically collections of variables

var thisIsAnArray = [ 0, 1, 2 ]
var thisIsAlsoAnArray = [ 0, 'abc', 19.2 ]
console.log( thisIsAnArray )
console.log( thisIsAlsoAnArray )

Function
these guys are basically ways for us to organize our program.  I guess it'd be.. like a paragraph.

var thisIsAFunction = function(){

}
console.log( thisIsAFunction )

Object
in addition to their other types.. all variable types in JS are, at their core.. objects.  It's kind of like how a word can be an noun, but it's still a word

var thisIsAnObject = {}
var thisIsAlsoAnObject = new Object();
console.log( thisIsAlsoAnObject  )

Special Types

undefined
if we've never defined our variable word, then when we try to reference that word it is undefined.. you'll be seeing this in your console if you use it to do all the stuff from above.. but I'll explain why much later
var thisIsUndefined
console.log( thisIsUndefined )

null
traditionally.. this just means that there's nothing in there..
var thisIsNull = null
console.log( thisIsNull )

Breaking it down

The "var" is a special word that tells the program to create a variable and the text right after that is the variable's name.  The equal sign is an assignment and the text to the far right is the value.

so.. to create a variable
var (variable's name) = (variable's value)

Rules

For simplicity's sake, let's restrict all variable names to upper and lower case characters, and the underscore "_".

What're we taking away?

Congrats! You've learned how to store data in a program.  Data that you can then manipulate to do.. whatever it is you want to do.  Next time, I'll cover some operators so that you can do something with your data

Friday, August 1, 2014

Agricola - tactics - I'm a rich bully!

Being a resource bully!

Acquiring resources first without spending them is a great way for you to mess with your opponents.  I'll parallel this with the first big decision in the game.  Sheep.

If you want that first batch of sheep there are a couple of ways you can assert yourself..
  • early fireplace
  • early pasture
  • playing cards like the butcher or animal tamer
  • building a couple stables
So that's obvious but what isn't obvious is what your first few actions mean.

If you're the first to get 2 clay.. you're essentially holding the cheap fireplace hostage
If you're the first to get 4 wood.. you have the potential to build two stables or a pasture

It's easier to threaten with 4 wood because you can always build stables, but without the fireplace you can't cook your delicious sheep so you have to spend more turns getting clay (or maybe you get lucky and people leave it alone)

The occupations usually aren't as effective as getting the resource itself. But if you know you can't win the resource battle, you can block the opponents intent and benefit a little from it.

So what's the point of this technique? When you get any resource type that other people don't have you lay  the first claim to everything that that resource can get.  Which means that they need to plan with the possibility of you taking the thing that they really need.  They can fake you out or force your hand, but it delays their game plan.

Sunday, July 27, 2014

programming with javascript - lesson one - getting started


Introduction!

Welcome to the beginnings of my introduction to programming through Javascript!

There are a couple of things that I wanted to do here.. first.. I want to de-mystify programming for the general public because I feel that programming is a basic skill.. and second just to take a moment right now to talk about what programming means to me..

Programming is a language just like any other written language.  It has grammar and rules, and each program tells a story.  But that story.. is a human story.  Algorithms and theories are simply the tools to improving and enriching our lives.  We see it every day.  Google maps and escape from zombie games.. twitter and authors writing stories by having character accounts tweeting at each other.. and my favorite.. games that have now become stories that challenge our psychology and the issues of our day.

I'd like to invite you to join the excitement that technology brings and perhaps by the end of this.. impart on you the joy of creation

Getting Started!

So for all the newcomers, there are two main methods of executing your code that I'm going to recommend. You can either:
download and open the chrome browser
hit f12,
click on the console tab.  it'll be at the top of the popup on the bottom of the browser window

OR
create a file with the .html extension
in your html file type
<script type="text/javascript">
// write your code below this line!

// write your code above this line!
</script>

write everything between the two script lines
open your file in a browser (I'll be biased.. I prefer Chrome for development),
hit f12 and click to the console tab
use the console like above or refresh the page when you update your file

Hats off to tradition

Just so that you know that you're ready to go you can write this line into the f12 console or your file

console.log('Hello World')

and you should see the text pop up in your browser's console.

Unfortunately, I'm releasing these tutorials one section at a time.. so it won't be terribly useful until a few of these are written.. but hopefully it'll keep me on track and writing.

Friday, July 25, 2014

caverna!

Super excited to pick this up.  I've been playing Agricola for a while now.  It'll be nice to see what their second stab at this genre will be like! Here's some un-boxing type photos..



Surprised the box came in in as good of condition as it did.. it was packaged like a textbook =(

Thursday, July 24, 2014

the state of diablo 3 - channeling

Let's be honest here, with the way most people play this game.. almost all skills.. are channeled skills.

Why? Because unless you have some of the more interesting builds (based on items).. we're clicking on stuff and holding the button down..

So.. what's the problem with this? Minus the flavor of skill animations.. channeled skills can be directly compared with regular skills simply by the amount of damage that they do and how often on average that you'll stand still

Which is fine.. except for the way itemization works.. because when things are too easy or too hard.. channeling at best feels clunky and at worst just feels bad.. AND it's a lot of trouble to switch your gear out to be optimal for some other skill instead

How to fix the problem? I don't really know if it can be fixed with the mechanics that are currently in the game.. perhaps more damage/utility is good enough to make a difference

Tuesday, July 22, 2014

the case for javascript

Javascript is inefficient and does weird things, but at the same time, it's an amazing language.

Here are a few reasons why:
  • It's the only programming language where you can open your browser.. hit f12.. click on the console tab.. and start writing code
  • It has the most consistent syntax
  • Arguably, the best debugging tools
  • It can do (almost) all those fancy things people learned in college courses easily
  • And because of all this, it's the ideal starting language to teach programming
I'm going to start working on a little project, but before I begin, I'm going to try to write an introduction to programming through JS in pieces