These are chat archives for thinkingmedia/iChrome

3rd
Dec 2015
Avi Kohn
@AMKohn
Dec 03 2015 00:21
BTW, if you're still doing the What's My IP widget, the next widget ID is 47. I plan on switching to GUID-type ones in the future, but until then they increment.
Mathew Foscarini
@thinkingmedia
Dec 03 2015 14:48
Dude, look at my git account. I have dozens of work-in-progress repos and no one to talk about it with. So I know exactly how you feel, and I don't want to talk about my personal projects at work. So please feel free to share anytime.
And yes, Guid would be great. Alternatively, you could just require that a widget has a unique name or camelCase key name or something like that.
I'll push 47 shortly.
Avi Kohn
@AMKohn
Dec 03 2015 15:20
Thank you
They need unique names also for scoped styling (scoped CSS isn't supported in Chrome anymore, so I prefix selectors)
I figure if/when things get bigger and the library really starts to grow, or when I build the directory, I'd switch to better IDs of some form and bundled widgets.
Also instances/installations should have unique IDs so configurations can be stored using something like ServiceWorker and then widget installations matched up with cached content using their IDs. That would let a web-based version with boostrapping data directly encoded into the page still work offline and load quickly, without worrying about out of date information.
I have plans for most parts of iChrome, but not enough time
Mathew Foscarini
@thinkingmedia
Dec 03 2015 15:24
I just pushed a new grunt task that lists all widgets and their ids.
I should have done a unique branch for that. maybe later
Avi Kohn
@AMKohn
Dec 03 2015 15:34
No problem. Two things though: 1. You accidentally committed the new tab override, and 2. I added a .editorconfig, could you please reformat the Gruntfile? You accidentally swapped tabs out for 4 spaces
Mathew Foscarini
@thinkingmedia
Dec 03 2015 15:35
that branch is baded on the old "pro" branch. it hasn't been updated to v3
yes, i need the .editorconfig thanks :)
made a pull for just the "grunt widgets" feature
i'll rebase to v3 when i get a chance
Avi Kohn
@AMKohn
Dec 03 2015 15:39
You have two tilde's at line 228: https://github.com/AMKohn/iChrome/pull/31/files#diff-35b4a816e0441e6a375cd925af50752cR228 And... could you please change the spaces to tabs when updating?
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:05
two what at 228?
Avi Kohn
@AMKohn
Dec 03 2015 16:05
Tilde's ~
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:05
ah
so ~~ is a short cut to convert a string to integer
it's null safe ~~null === 0
Avi Kohn
@AMKohn
Dec 03 2015 16:06
This message was deleted
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:07
okay, i'll remove it. :(
I use ~~ all the time. it's very handy, but a lot of people aren't use to it
Avi Kohn
@AMKohn
Dec 03 2015 16:08
Sorry... I could update the JSHint config, but I'm not sure what the right error ID is
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:08
no problem, maybe a year from now you'll come back and think "what the f* was the ~~ thing doing again?"
Avi Kohn
@AMKohn
Dec 03 2015 16:09
Probably...
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:10
you will also see me do things like this
if(!!foo) {
  //.... 
}
double !
can you figure out why? :) this is a test.
Avi Kohn
@AMKohn
Dec 03 2015 16:10
I do that all the time, it's handy
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:10
lol okay
Avi Kohn
@AMKohn
Dec 03 2015 16:10
Converts it to a boolean
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:11
I did ~~ in an interview exam once and the senior js developer didn't know what it was and I thought that was funny.
Avi Kohn
@AMKohn
Dec 03 2015 16:11
I've seen it before, but I don't use it
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:11
some times knowing to much isn't good either ;)
Avi Kohn
@AMKohn
Dec 03 2015 16:11
I've gotten more verbose as time's passed, I decided to leave things like that up to the compressor
Although I don't know of any that replace parseInt's
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:13
there is a way to configure git at the repo level to auto convert spaces to tabs. I'll try that
Avi Kohn
@AMKohn
Dec 03 2015 16:13
I didn't know that
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:13
the editor thing works, but only after I've made changes
Avi Kohn
@AMKohn
Dec 03 2015 16:15
So the double tilde's cut decimals also, cool
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:15
yeah, its basically converts anything to an integer.
i like it cause it never fails (throws an error)
it's like "force this thing to integer". great when a function parameter should be an int, and some idiot sends you an object or array. it just becomes 0
Avi Kohn
@AMKohn
Dec 03 2015 16:16
Doesn't parseInt only throw in strict mode or something?
Ah
parseInt would just return NaN
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:18

it also breaks the follow of a math expression

var x = 10 / ~~y + 30;
var z = 10 / parseInt(y) + 30;

the first is easier to read, and the second might fail.

unwell, that wasn't a good example. lol, divid by zero :)
Avi Kohn
@AMKohn
Dec 03 2015 16:19
I prefer the second still.
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:19
and that's what it is. personal preference. it's not a rule. :)
Avi Kohn
@AMKohn
Dec 03 2015 16:19
Things feel safer when they're more explicit.
Does that work out as a pre-commit hook?
Github for windows doesn't support them unfortunately :(
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:21
okay
ah.
I have to many git engines installed to know which one I'm using half the time anyway so that's not a recommended approach. i like the .editconfig better
Avi Kohn
@AMKohn
Dec 03 2015 16:22
I'd like to set one up to run JSHint before committing so I don't break the build, but I can't and continue to use the client.
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:23
don't run those
i put these on my path. makes life easier.
you could just add grunt jshint to gitty

what I do is

gitty "commit message"

It adds, commits and pushes in one line :)

you need git installed for windows
Avi Kohn
@AMKohn
Dec 03 2015 16:25
I set up Sublime Text to run JSHint with Ctrl+B
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:25
that works too
Avi Kohn
@AMKohn
Dec 03 2015 16:25
I think it can do commits natively also, but I haven't set it up
I have Git itself as well, I use it when the client fails (actually happens a good bit)
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:26
i use sourcetree to manage branches and cli for easy stuff like push/pull
Avi Kohn
@AMKohn
Dec 03 2015 16:27
You use BitBucket usually?
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:28
I use github, and have a gitlab running on Digital Ocean for private repos
gitlab has built in CI like travis. So I can do builds on my private repos too :)
Avi Kohn
@AMKohn
Dec 03 2015 16:29
Nice UI
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:29
yeah they copy github a lot
Avi Kohn
@AMKohn
Dec 03 2015 16:29
Looks cool
I actually pay for private repos (just one for now) for iChrome from the donated money I have so they're completely offsite
The server-side code is in one
I'm worried about running the wrong thing on a server and trashing it, it wouldn't be the first time
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:31
I was paying for the 5 repo option on github. I think it was $5 or $10? but I setup gitlab for like $10 with unlimited repos and CI
lol that could happen
i need to setup ftp backups
been to busy
Avi Kohn
@AMKohn
Dec 03 2015 16:31
Plus I put together a deploy script to pull directly from Github and create a new server
It took 15 minutes to set up the cluster of 4 (reverse proxy, 2 frontend, and a database)
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:32
I setup Jenkins to do that. it listens for new tags marked as a release and deploys the update
Avi Kohn
@AMKohn
Dec 03 2015 16:32
That sounds better...
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:32
it runs the build script which recreates the server
it's okay
you end up having to install all the dev tools on the production server
it's what I do for the "dev phase" where I don't need the server to be purely for that project
so I have a general jenkins node that builds projects and hosts them
it's time consuming to setup
Avi Kohn
@AMKohn
Dec 03 2015 16:34
I just run the script manually
So, do you use MongoDB at work?
Or have you in a large project before?
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:36
i've never used it. I use mysql on all my personal projects. we run mssql and aerospike at work.
Avi Kohn
@AMKohn
Dec 03 2015 16:36
I was going to use aerospike, but I couldn't run it locally for dev
MongoDB is very flexible, and pretty fast
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:36
it needs a partition
i've never run aerospike
it's overkill
you would need to setup a node on Digital Ocean and always use that for dev
Avi Kohn
@AMKohn
Dec 03 2015 16:37
I was looking for a fast basic store for syncing
But it doesn't support Windows, and I couldn't figure out the setup so I gave up
MongoDB works fine, response times hold at about 3ms (total request)
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:38
it's very popular. i have no issues with
maybe one day i'll look at it
Avi Kohn
@AMKohn
Dec 03 2015 16:38
I don't like SSH connection times
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:38
works good with nodejs
Avi Kohn
@AMKohn
Dec 03 2015 16:38
yes
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:39
you shouldn't ssh if it's only on a private network
Avi Kohn
@AMKohn
Dec 03 2015 16:39
I use that for everything also
On DO?
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:42
SSL i mean, not SSH
Avi Kohn
@AMKohn
Dec 03 2015 16:43
??
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:45
never mind lol
Avi Kohn
@AMKohn
Dec 03 2015 16:45
OK
grunt widgets is ready to merge?
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:46
build faulure?
one sec
Avi Kohn
@AMKohn
Dec 03 2015 16:46
Yes, I keep things strict
It was a pain to enable for the project, but it's good I think
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:48
for sure, and i like the pull tests :)
Avi Kohn
@AMKohn
Dec 03 2015 16:50
Travis is tightly integrated with Github, it's good
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:50
yes and it's automatic when you add travis. I wish the places I worked were this organized.
Avi Kohn
@AMKohn
Dec 03 2015 16:54
I try
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:54
i was thinking that widgets could use some kind of caching service
Avi Kohn
@AMKohn
Dec 03 2015 16:54
To cache what?
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:54
I don't want whatsmyip to always change the IP
so it should save the IP, and if 60 minutes has passed it updates it
Avi Kohn
@AMKohn
Dec 03 2015 16:55
Ah
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:55
when chrome restarts it should still be using the timer
weather might need something like this as well
Avi Kohn
@AMKohn
Dec 03 2015 16:55
I decided against that in general because when a user reloads the page, they expect to see the latest everything.
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:56
ah, thats a good point
Avi Kohn
@AMKohn
Dec 03 2015 16:56
But, you should be able to save a timestamp in the data
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:56
can we add moment.js as a dependecies library?
i like using that
Avi Kohn
@AMKohn
Dec 03 2015 16:56
Already there
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:56
cool
Avi Kohn
@AMKohn
Dec 03 2015 16:56
Just require "moment"
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:57
that will make the caching logic easier
Avi Kohn
@AMKohn
Dec 03 2015 16:57
I try to avoid it for that acutally
It's rather slow when comparing times
And doing relative formats
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:58
when speed is your PC?
Avi Kohn
@AMKohn
Dec 03 2015 16:58
But you should be able to do if (new Date().getTime() - cachedTime > 60 * 60 * 1000 ) refresh()
My computer isn't the issue, but I run perf checks on everything.
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:58
are perfs automated?
Avi Kohn
@AMKohn
Dec 03 2015 16:58
iChrome's used a lot on Chromebooks, and they're slow.
No
Mathew Foscarini
@thinkingmedia
Dec 03 2015 16:59
hmm. would be cool if that could be part of the lint process.
Avi Kohn
@AMKohn
Dec 03 2015 16:59
I put together a function to run them though
Basically a lightweight JSPerf, but I usually write one on the fly rather than hunt the JS file down
var timeLoop = function(fn, ops) {
    var start = performance.now();

    for (var i = 0; i <= ops; i++) {
        fn();
    }

    return performance.now() - start;
};

var bmark = function(fn, ops) {
    var time;

    if (ops) {
        time = timeLoop(fn, ops);
    }
    else {
        ops = 10;

        // Figure out the proper number of loops to run, anything that takes less
        // than ~500ms won't give a precise result. This will run an increasing
        // number of loops until it takes longer than that, saving the run time
        // each time so the loop doesn't have to run twice when it's over 500ms
        while ((time = timeLoop(fn, ops)) < 500) {
            ops *= 10;
        }
    }


    var perRun = Math.round((time / ops) * 100000) / 100000,
        opsSec = Math.round((ops / time) * 1000);

    return "Ran " + ops.toLocaleString() + " ops in " + time.toLocaleString() + " ms. That's " + perRun + " ms per run, " + opsSec.toLocaleString() + " ops/second";
};
Run bmark(function() { /* Op here */ })
Mathew Foscarini
@thinkingmedia
Dec 03 2015 17:00
well, if we add *.perf.js files we could automate this
then in the build you just exclude those files
Avi Kohn
@AMKohn
Dec 03 2015 17:00
It'll figure out the right number of loops to run for an accurate measurement and then run them. Usually takes about a second.
To perf what?
I get ~2,000,000 ops/second for bmark(function(){return new Date().getTime();}) as a reference
Mathew Foscarini
@thinkingmedia
Dec 03 2015 17:02
instead of stopping your work to perf something. you place the test in the perf and run a grunt task later.
Avi Kohn
@AMKohn
Dec 03 2015 17:03
I usually just perf patterns I use often and change my habits, so everything I use now is the faster method.
Like I said, performance freak.
Avi Kohn
@AMKohn
Dec 03 2015 17:05
Yup
All the time
Mathew Foscarini
@thinkingmedia
Dec 03 2015 17:05
:smile:
Avi Kohn
@AMKohn
Dec 03 2015 17:05
But, iChrome inits in 200ms flat.
It's just the loading that's slow
Mathew Foscarini
@thinkingmedia
Dec 03 2015 17:05
lunch, ttyl
Avi Kohn
@AMKohn
Dec 03 2015 17:05
Even though it's all local.
Yes, I need to finish the days work this afternoon also. So I won't have much time to talk
ttyl