TIL that
function f(x){x=x||'default_value';/* function body */}
9/7/2013 2:31:15 PM
at least the comment is super helpful?
9/8/2013 9:47:14 AM
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
/sarcasmthe 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
seen people do this with sublimetext before, not sure how i never figured out that this is a thinghttp://coding.smashingmagazine.com/2013/03/26/goodbye-zen-coding-hello-emmet/
9/10/2013 10:21:02 PM
<3 emmet
9/13/2013 7:46:34 AM
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
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
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
And what you learned was...?
4/23/2014 7:14:09 AM
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
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
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
^That's awesome man!
4/26/2014 10:08:03 PM
TIL I have woefully underestimated the complexity of Sharepoint 2013 installation and configuration.
4/29/2014 9:44:18 AM
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:\
9/13/2014 4:53:31 PM
^coolI'm Krallum and I approved this message.
9/15/2014 11:41:34 AM
^^^^^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-netcatlooks like Tomato has netcat [Edited on September 15, 2014 at 7:59 PM. Reason : ]
9/15/2014 7:59:36 PM
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
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
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
...there are still people trying to force "photochop" on me.Fuck your dreams.
9/16/2014 3:45:37 PM
^^ 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
So, I've never really worked with perl muchSORRYI realize it's a bit of a jokeBut 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
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
lol
9/16/2014 10:04:13 PM
9/16/2014 11:22:30 PM
9/17/2014 12:54:34 AM
that italics code ; however, always sucks
9/18/2014 7:59:34 AM
Today I learned if you type 'sl' instead of 'ls' in unix you get a surprise.
9/18/2014 11:41:10 AM
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
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'); ?>
11/24/2014 10:43:24 PM
...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
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
^^^ you're using PHP?
11/25/2014 12:57:14 AM
Syntactically: nothingSemantically: "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');"; ?>
11/25/2014 9:58:58 PM
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
Windows Admin workarounds are still a thing.http://imgur.com/gallery/H8obU
2/2/2015 11:14:44 AM
I've used Dosbox plenty of times...To play oldschool games
2/2/2015 11:40:02 PM
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
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
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
ADA compliance requirements for websites is some BULL!!!!!!!
8/10/2017 3:16:11 PM
8/10/2017 8:15:28 PM
^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
"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
you know what fuck youi don't care if it's hardit's supposed to be hard, that's why it's your fucking job
8/14/2017 3:54:42 PM
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
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
If ReportData.Columns.Contains("ColumnToRemove") Then ReportData.Columns.Remove("SomeOtherColumn")End If
Dim Remove = Sub(ColumnName As String) If ReportData.Columns.Contains(ColumnName) Then ReportData.Columns.Remove(ColumnName) End If End Sub
Remove("NewColumnToRemove")
4/18/2018 1:36:25 PM
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