User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » Today I learned (Tech Edition)... Page 1 2 3 4 [5] 6, Prev Next  
lewisje
All American
9196 Posts
user info
edit post

TIL that

function f(x){x=x||'default_value';/* function body */}
is a manner of setting a default value that people with actual jobs maintaining Javascript code do not understand: http://arstechnica.com/information-technology/2013/09/if-my-team-has-low-skill-should-i-reduce-the-difficulty-level-of-my-code/

9/7/2013 2:31:15 PM

Fry
The Stubby
7784 Posts
user info
edit post

at least the comment is super helpful?

9/8/2013 9:47:14 AM

lewisje
All American
9196 Posts
user info
edit post

the comment isn't the important part of the snippet, it's the use of the || operator to set a default value (and also to turn any falsy value into the default, like 0 or the empty string)

9/8/2013 10:47:12 PM

Fry
The Stubby
7784 Posts
user info
edit post

/sarcasm

the danger is the 0/false/etc... i'd personally avoid something like that unless i had some type checking/validation to go with it. i do like assignment by boolean evaluation when the clause is relatively short/simple though

9/8/2013 11:32:28 PM

qntmfred
retired
40796 Posts
user info
edit post

seen people do this with sublimetext before, not sure how i never figured out that this is a thing

http://coding.smashingmagazine.com/2013/03/26/goodbye-zen-coding-hello-emmet/

9/10/2013 10:21:02 PM

kiljadn
All American
44690 Posts
user info
edit post

<3 emmet

9/13/2013 7:46:34 AM

Fry
The Stubby
7784 Posts
user info
edit post

i havent jumped into emmet, but in general learning keyboard shortcuts and commands for sublime text can make coding much more efficient, especially dealing with markup too

9/13/2013 8:57:17 AM

lewisje
All American
9196 Posts
user info
edit post

I came in to do some long-overdue routine maintenance before hardening a Windows XP system that we can't just ditch or upgrade, because it's tied to a certain piece of equipment that costs thousands of dollars to replace; the first thing I noticed was that it kept saying the free disk space was dangerously low, so low I couldn't even get Windows Update to work, clearing the ordinary browser caches and running Disk Cleanup weren't helping, and the users weren't saving a bunch of files or installing a bunch of programs on the computer that I could clear out (it had a 37GB HDD but still there should have been plenty of free space).

It wasn't until I used SpaceSniffer that I discovered the likely source of the problem: The LocalService Cookies directory alone occupied a few dozen megabytes!
Then I ran CCleaner with the special winapp2.ini file from winapp2.com to start cleaning out the hidden Temporary Internet Files directories; a few hours later, it's still about halfway through the one in LocalService (now at the randomly named directories starting with "ML"), and so far it has cleared out 14GB of space (I'm monitoring it remotely).

I'll soon check to see whether this was the fault of malware, but for all I know from searching the Web, it could have been the "Web Client" service (which I will probably turn off, even though it was nice to have network shares accessible from this computer); still, I'm surprised that neither Internet Options nor Disk Cleanup managed to catch this.

[Edited on April 22, 2014 at 11:28 PM. Reason : also Windows Update was borkd to start off...could well be malware

4/22/2014 11:28:09 PM

lewisje
All American
9196 Posts
user info
edit post

In the end it cleared out 24GB of space, more space than I have ever seen occupied by browser caches at once before.

4/23/2014 3:36:29 AM

FroshKiller
All American
51913 Posts
user info
edit post

And what you learned was...?

4/23/2014 7:14:09 AM

lewisje
All American
9196 Posts
user info
edit post

It was that Temporary Internet Files can grow to practically unlimited size.

(BTW I checked a little later and the Local Service Temporary Internet Files was filling up again, and I noticed the MSE entry in Startup had been misnamed, then I scanned with MalwareBytes and found the ZeroAccess trojan.)

4/24/2014 2:25:34 PM

FroshKiller
All American
51913 Posts
user info
edit post

I wrote what I think is my first CGI script today. If it wasn't the first, it must be the second. Kind of amazing to me that I haven't had a need to do it before.

A few years ago, our power went out, so we decided to hang out at the bar until the power came back on. I had what I thought was a clever idea for telling whether the power was on at the house. I'd drop a file into a folder on my laptop that I sync to Dropbox, and when I see that file in the Dropbox app on my phone, we'll know that the Internet, and by inference the power, is back on.

Well, that ultimately didn't work out, because I had paused Dropbox sharing earlier that day and forgot to turn it back on. Oops. Never mind that the plan would only work if the power came back on before my laptop's battery ran out.

Anyway, this afternoon's thunderstorm reminded me of that, so I decided to implement it differently. I run the Tomato firmware (http://www.polarcloud.com/tomato) on my router. One of its features is the ability to write a custom script that runs when the WAN interface comes up. Wouldn't it be cool if I could push a notification to my phone using a script like that?

I recently started using Pushbullet (http://www.pushbullet.com/), a service that lets you (among other things) send arbitrary push notifications to your devices through an HTTP REST API. All I needed was a way to POST a request from the WAN startup script on the router.

Unfortunately, my router doesn't have cURL installed. Worse, its implementation of wget doesn't support basic authentication or posting data, so while I could easily GET a URL from the Pushbullet API, I couldn't really do anything useful.

However, I do have an account with a shell provider that has a better wget implementation, and my access level lets me run CGI scripts. So I wrote a very simple KornShell script to call wget with my parameters, and I configured my WAN startup script to GET the CGI script. The CGI script sends the actual authenticated POST to Pushbullet.

I rebooted the router, and sure enough, it worked like a charm. I was almost disappointed that the power didn't go out.

4/25/2014 11:53:58 PM

FroshKiller
All American
51913 Posts
user info
edit post

Update: The power did go out overnight, and I woke up to a notification letting me know the router's WAN interface was back up.

4/26/2014 8:13:46 PM

Noen
All American
31346 Posts
user info
edit post

^That's awesome man!

4/26/2014 10:08:03 PM

GraniteBalls
Aging fast
12262 Posts
user info
edit post

TIL I have woefully underestimated the complexity of Sharepoint 2013 installation and configuration.

4/29/2014 9:44:18 AM

qntmfred
retired
40796 Posts
user info
edit post

ever run into the PATH environment variable in Windows getting jacked up b/c it went over 2048 characters?

apparently this is a workaround

PATH=C:\;%PATHCONTINUED%
PATHCONTINUED=E:\


[Edited on September 13, 2014 at 4:56 PM. Reason : NEAT]

9/13/2014 4:53:31 PM

Krallum
56A0D3
15294 Posts
user info
edit post

^cool

I'm Krallum and I approved this message.

9/15/2014 11:41:34 AM

moron
All American
34183 Posts
user info
edit post

^^^^^
If you want to be really clever, you can use net cat (nc) to send the HTTP get command with the basic auth header:

http://stackoverflow.com/questions/642707/scripting-an-http-header-request-with-netcat

looks like Tomato has netcat

[Edited on September 15, 2014 at 7:59 PM. Reason : ]

9/15/2014 7:59:36 PM

FroshKiller
All American
51913 Posts
user info
edit post

That's fine, but I don't want to be clever. I want to do the least amount of work required with the simplest tools available to me. I shouldn't have to quibble over how to form an HTTP request for something like that. I was already doing too much work writing the CGI script, but that was at least a marginally useful exercise.

9/16/2014 8:11:24 AM

moron
All American
34183 Posts
user info
edit post

To me, a single command to hit your pushbullet is easier than bouncing off a cgi. HTTP formatting isn't that bad really...

9/16/2014 10:43:59 AM

FroshKiller
All American
51913 Posts
user info
edit post

I mean...? "A single command," okay, but there are lots of single-command solutions I could come up with that imply hours of research and testing before I could actually implement them. I already knew wget and shell scripting well enough in this case to connect the dots. If I had known netcat was available and knew how to form the request off the top of my head, I might have preferred that method, but the simpler end result is frequently the more involved implementation.

9/16/2014 12:42:22 PM

Agent 0
All American
5677 Posts
user info
edit post

...there are still people trying to force "photochop" on me.

Fuck your dreams.

9/16/2014 3:45:37 PM

moron
All American
34183 Posts
user info
edit post

^^ yeah i get that... i was just offering an alternative solution for any on-lookers.

You have a good solution too.

I'm not trying to harsh you vibe or anything.

9/16/2014 4:14:57 PM

jaZon
All American
27048 Posts
user info
edit post

So, I've never really worked with perl much

SORRY

I realize it's a bit of a joke

But TIL that perl developers are a fucking joke - I have seen shitty code before, but the shit these people put out blows my mind.

[Edited on September 16, 2014 at 5:56 PM. Reason : ]

9/16/2014 5:56:12 PM

neodata686
All American
11577 Posts
user info
edit post

So after a few beers I was playing around with Boxcryptor for Dropbox. For some reason I thought it was smart to encrypt my key file using Boxcryptor then close the program.

9/16/2014 9:21:17 PM

jaZon
All American
27048 Posts
user info
edit post

lol

9/16/2014 10:04:13 PM

lewisje
All American
9196 Posts
user info
edit post

Quote :
"ever run into the PATH environment variable in Windows getting jacked up b/c it went over 2048 characters?

apparently this is a workaround
PATH=C:\;%PATHCONTINUED%
PATHCONTINUED=E:\
"
I would just shove the less-important stuff into my user PATH, but this is a more robust and scalable solution now that that is bloated up too.

Also IDK why the D programming language distro, and a few other programs, don't know how to deal with the PATH properly and then just wipe that environment variable away and replace it with just the path to their own binary components.

9/16/2014 11:22:30 PM

Stein
All American
19842 Posts
user info
edit post

Quote :
"But TIL that perl developers are a fucking joke - I have seen shitty code before, but the shit these people put out blows my mind."


As a general rule, the Perl code you think is the worst is [I]always[/I] the best.

9/17/2014 12:54:34 AM

Quinn
All American
16417 Posts
user info
edit post

that italics code ; however, always sucks

9/18/2014 7:59:34 AM

neodata686
All American
11577 Posts
user info
edit post

Today I learned if you type 'sl' instead of 'ls' in unix you get a surprise.

9/18/2014 11:41:10 AM

afripino
All American
11433 Posts
user info
edit post

TIL that Unicode <> Unicode (big endian) and some people are dicks because they can't read a damn text file!

9/18/2014 11:59:02 AM

lewisje
All American
9196 Posts
user info
edit post

A couple days ago I noticed a subtle PHP error while I was modifying a Google Analytics plugin to output Universal Analytics:

<?php echo ga('require','ecommerce','ecommerce.js'); ?>
Can anyone guess what's wrong here?

11/24/2014 10:43:24 PM

jaZon
All American
27048 Posts
user info
edit post

...nothing?

ha. without knowing what your function looks like, I just copy pasted and wrote a bullshit function to return the three inputs and it works fine.

so...no idea. tell us?

11/24/2014 11:27:24 PM

aaronburro
Sup, B
53136 Posts
user info
edit post

the function isn't properly respecting of LGBT perspectives, because it's named "ga".

[Edited on November 25, 2014 at 12:04 AM. Reason : ]

11/25/2014 12:04:33 AM

Fry
The Stubby
7784 Posts
user info
edit post

^^^ you're using PHP?

11/25/2014 12:57:14 AM

lewisje
All American
9196 Posts
user info
edit post

Syntactically: nothing

Semantically: "ga" is defined as a Javascript function earlier in the output Javascript, but it's not defined as a PHP function and shouldn't be, because the Google Analytics snippet runs on the client side, not the server.

<?php echo "ga('require','ecommerce','ecommerce.js');"; ?>
This is the correct code.

BTW the issue isn't really related to using PHP (not that it's at all trivial to move our eCommerce platforms to a new stack), but the error wouldn't have been so difficult to uncover in a server-side programming language that had a different function-invocation syntax.

11/25/2014 9:58:58 PM

afripino
All American
11433 Posts
user info
edit post

TIL that the forcedos command does not work in windows 7.

I had to use a DOS emulator called DosBox in order to run an old Clipper program as we migrated the process to a new pc. Ancient programs

1/26/2015 1:54:11 PM

GraniteBalls
Aging fast
12262 Posts
user info
edit post

Windows Admin workarounds are still a thing.

http://imgur.com/gallery/H8obU

2/2/2015 11:14:44 AM

Hiro
All American
4673 Posts
user info
edit post

I've used Dosbox plenty of times...










































To play oldschool games

2/2/2015 11:40:02 PM

FroshKiller
All American
51913 Posts
user info
edit post

In SQL Server, using ISNULL in your WHERE clause to test the value of an indexed column forces an index scan if the column is nullable. What I didn't know is that if the column disallows null values, the query planner is smart enough to optimize the ISNULL out and can do an index seek instead.

So now I just have to worry about programmers who blindly define every column as nullable even when that doesn't make a lick of sense for the data model.

[Edited on March 18, 2015 at 8:34 AM. Reason : ///]

3/18/2015 8:34:16 AM

afripino
All American
11433 Posts
user info
edit post

Goddamn Paradox 5.x requires you to create a unique index in order to insert rows into an empty table. The error you get doesn't fucking say that!!! Also, it will let you insert a single row before you get the error (operation must use an updateable query...wtf,bro!?), so you're all like..."durr...why did the insert work on one row, but not the next row???" Legacy db technology bullshit....

12/30/2016 9:56:01 AM

FroshKiller
All American
51913 Posts
user info
edit post

File this one under Obviously, but I just learned today that you can attach the Performance Explorer in Visual Studio to a Windows service process to sample the service at runtime instead of stubbing a console program.

1/3/2017 3:32:40 PM

afripino
All American
11433 Posts
user info
edit post

ADA compliance requirements for websites is some BULL!!!!!!!

8/10/2017 3:16:11 PM

Wolfmarsh
What?
5975 Posts
user info
edit post

Quote :
"ADA compliance requirements for websites is some BULL!!!!!!!"


Not to the people who need it.

8/10/2017 8:15:28 PM

afripino
All American
11433 Posts
user info
edit post

^yeah, I get it. it's just crazy how many (subtle) changes have to be made to stay compliant.

8/14/2017 12:50:02 PM

FroshKiller
All American
51913 Posts
user info
edit post

"It's crazy how much consideration it takes to respect the needs of all users instead of assuming everyone has the same freedom of movement as me and senses as accurate as mine."

8/14/2017 3:54:17 PM

FroshKiller
All American
51913 Posts
user info
edit post

you know what fuck you

i don't care if it's hard

it's supposed to be hard, that's why it's your fucking job

8/14/2017 3:54:42 PM

afripino
All American
11433 Posts
user info
edit post

wow....must be on your period today.

It's crazy how much consideration it takes to respect the needs of all users instead of assuming everyone has the same freedom of movement as me and senses as accurate as mine." frivolous lawsuits are running rampant.

not everyone is trying to be a bad guy.



[Edited on August 14, 2017 at 4:20 PM. Reason : how many ADA compliant websites have you made?]

8/14/2017 4:16:18 PM

FroshKiller
All American
51913 Posts
user info
edit post

This isn't so much a "learned" as it is connecting the dots, but in this .NET project, there's a lot of repetition in the code that I'm obliged to follow by convention. So like if I want to remove a column from a DataTable, it involves a lot of this stuff:

If ReportData.Columns.Contains("ColumnToRemove") Then
ReportData.Columns.Remove("ColumnToRemove")
End If


And I don't know about you, but I am prone to errors when copying & pasting code, so I wind up making mistakes like this:

If ReportData.Columns.Contains("ColumnToRemove") Then
ReportData.Columns.Remove("SomeOtherColumn")
End If


This throws an exception at run-time, and that sucks.

Then I realized I could just set up a lambda expression:

Dim Remove = Sub(ColumnName As String)
If ReportData.Columns.Contains(ColumnName) Then
ReportData.Columns.Remove(ColumnName)
End If
End Sub


And now I don't copy and paste shit, I just type a new line 'cause it's easy:

Remove("NewColumnToRemove")


Yeah yeah yeah there are ten million bad practices and loads of better ways to avoid situations like this. I'm just telling you that shit happens, and at least this way, I don't step in it.

4/18/2018 1:36:25 PM

CaelNCSU
All American
7132 Posts
user info
edit post

Ctrl-I is the same as tab. I learned this by changing my binding to Ctrl-I in tmux and havinh tab completion break in all my tmux terminals. Dafuq....

4/18/2018 11:20:15 PM

 Message Boards » Tech Talk » Today I learned (Tech Edition)... Page 1 2 3 4 [5] 6, Prev Next  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.39 - our disclaimer.