Monday, August 29, 2016

Forcing IE10 to render IE9 due to Telerik incompatibilities

We use a lot of Telerik RadGrids and such to run AJAX for smoother UX on form submits. However one of our clients reported a strange issue when using IE10. Absolutely nothing would happen on clicking Submit. It worked on any version other than IE10, even IE9.

After much hair-pulling and googling, it turns out that the 2010 version of Telerik was released before IE10 existed. With newer versions of Telerik it is of course IE10 compatible, but for older Telerik versions some things don't work.

I didn't want to go through the hassle of upgrading Telerik and risk breaking any assemblies, so I needed a quick hacky workaround. What I ended up finding was that you could "fix" this issue by forcing IE10 to load using IE9 Document Mode.

I loaded both a meta tag and a header to tell IE10 to emulate IE9. So far it works, altho it's not the best long-term solution.


// force IE10 to load like IE9
var isIe10 = Request.UserAgent.ToString().IndexOf("MSIE 10.0") > -1;

if (isIe10)
{
    // add meta
    HtmlMeta meta = new HtmlMeta();
    meta.HttpEquiv = "X-UA-Compatible";
    meta.Content = "IE=EmulateIE9";

    // add header
    Response.AddHeader("X-UA-Compatible", "IE=EmulateIE9");
}
    else
{
}

Sunday, August 21, 2016

Oft-used Velocity.js methods

Scroll to an element
$element.velocity("scroll", { duration: 600, easing: "easeInSine"});

Stop existing velocity animations before running (de-queue)
$element.velocity("stop").velocity(...);

Adjust height
$element.velocity({ height: '400px' });

Adjust transform
$element.velocity({ translateY: '-100%' });

Fade in element
$element.velocity({ opacity: 1 }, { display: "block" });

Fade in element w/ a delay
$element.velocity({ opacity: 1 }, { display: "block", delay: 400 });

Fade out element
$element.velocity({ opacity: 0 }, { display: "none" });

Tuesday, August 16, 2016

Notes on Node.js using Express.js

To install Express for the first time:
npm install -g express-generator

Install Express files in a directory
express [PROJECTNAME]

Then install package.json after checking it has what you want
npm install

To start Node.js using Express on Windows cmd:
set DEBUG=[SERVERNAMEHERE]:* & node index.js
Friday, March 11, 2016

Installing SSL on Microsoft Azure VM IIS


Install the cert on IIS
https://www.digicert.com/ssl-certificate-installation-microsoft-iis-8.htm

If you go through these steps successfully but the certificate you just created disappears, you will need to import the private key. This happens if you created the certificate request on a different computer.

Export the private key from the originating computer, then import it to the target server
https://www.digicert.com/ssl-support/pfx-import-export-iis-7.htm

Add a new endpoint for HTTPS on Azure. If you do not do this, you will get a "webpage not available" error when trying to load the website via https.
http://stackoverflow.com/questions/31965713/how-i-add-new-endpoints-to-my-vm-on-new-azure-portal-preview

If you want to redirect all traffic to https, you will need to add an entry in your Web.config. Under the <system.webserver><rewrite><rules>, create a new <rule>:

<rule name="https-redirect" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect"  url="https://www.99restaurants.com/{R:1}" redirectType="Permanent" />
</rule>
Thursday, February 25, 2016

Helpful Linux SSH Commands

Change Owner/Group Recursively(into subfolders and files):
chown -R user:group directoryorfilename


Change Permissions Recursively:
***CAUTION: this has in the past deleted the entire contents of a folder when used with a directory name
chmod -R XXX DirectoryOrFilename


Get All Users: 
getent passwd


Get All Groups: 
getent group


Run commands as a superuser (if getting "Cannot run with sudo"):
(command) --allow-root


List current (working) directory:
pwd


Get file size of 1st level of folders in root directory:
ls


List contents of directory:

du -h --max-depth=1 /


Get size and avail space on drive

df -h


Get file size of each folder:
du -sh *


List files in order by size
ls -lh -S


MySQL Related Commands



Check mysql status:
/etc/init.d/mysql status


Restart mysql:
sudo service mysql restart


Export database to sql file:
mysqldump -u [uname] -p database_name > filename.sql


Restore database from sql file:
mysql -u username -p database_name < file.sql


Access MySQL shell from linux commandline:
mysql -u root -p


Once in mysql, you can use these commands

List databases:
SHOW DATABASES;


List users:
SELECT User FROM mysql.user;


Create a new user with remote access enabled:
GRANT ALL ON DatabaseName.* TO UserName@’1.2.3.4’ IDENTIFIED BY ‘PasswordHere’;


Nano Commands



Copy a line (This can be used multiple times to add lines to the buffer):

Alt-^ (Alt-Shift-6)


Paste buffer content
Ctrl-U


Go to bottom of file
Ctrl-W + Ctrl-V
Tuesday, January 26, 2016

Goals for 2016

Around this time each year I have to set my goals at work. Trying to formulate what my goals are is making me think of what my own personal goals as a coder are. In general, I want to use my abilities, skills, and talents to make the world a better place. In addition, I've noticed that I learn by just jumping in and trying things, as well as reading books and basically sucking up all the information I can about a subject. My hope is to use both the experiential and educational approaches to gain more knowledge and accomplish my goals.

Personal Goals

Create some kind of game or fun app
Whether it's a virtual pet app, a puzzle game, or functional app like mobile sticky notes. I've always been interested in creating games or apps. Maybe it was reading 3-2-1 Contact magazine growing up and looking at the BASIC games that they published and you could copy onto your computer. I remember borrowing a BASIC book from the public library and creating a very very simple text game about a koala.

Get involved with the coding community
I haven't really connected with coders outside my office very much. I have gone to the past two WordCamp Boston events, which have been awesome. I did go to one Meetup last year and it was really cool to chat with other programmers and see what they work on/in. I love the Github community and how everyone lets you get all up in their code and see how it was built and add their suggestions. I'd love to go to more events and conferences and maybe even contribute to a Github repo!

Learn foundational programming concepts
As a non-computer science major (I went for photography instead), most of my skills have been learned on the job. It hasn't been easy, but it's been incredibly rewarding. I'd liken the experience to learning a new language by dropping myself off in another country and quickly figuring out how to get the job done in each situation. It's worked out great, but I can sense the gap in my knowledge when it comes to how certain things are structured or how websites work in a broad sense. I've started making an Amazon list of books that deal with different aspects of computer programming, from coding philosophy to practical career advice. So far it's been pretty eye-opening, and I'm hoping it will help me have a more complete picture of how programming works.

Get more freelance and business experience
I did my first freelance project this past year, installing and customizing a Wordpress theme for a non-profit. Getting to see the business side of things was a new challenge for me, and I did a lot of Googling about skills like writing a good SOW, communicating with the client, and the all-important ability of getting paid. It was a great learning experience and the client was very happy with the end product. I also see the need of learning how business and marketing works. While I won't be looking for an MBA, I am looking into books that can teach me some basic business skills.

Professional Goals (as an employee)

Learn a front-end framework
I've learned a lot of front-end stuff this past year, and definitely feel more comfortable with basic responsive design, JS and working with SCSS and Grunt. I'd like to dive deeper into this area and learn more about popular frameworks like Angular.js or Node.js. I honestly don't even really know what they do exactly, so I definitely would like to get more knowledgeable in this area.

Continue contributing to scoping
This past year I've helped out more with estimating dev hours for upcoming projects. I'd like to continue doing that, as well as trying to be watchful for red flags and being more proactive in calling out potential problems in timelines or hours.

Present at Heads Up or other meeting
I presented on a new responsive website build for the first time at one of the monthly all-company meetings and I think it went well-- got good feedback and I enjoyed it. I'd like to try it again.

Monday, January 18, 2016

Wordpress Migration

When migrating Wordpress between servers, usually when moving from a staging to production database for the first time, I'll follow these steps:


  • Install a fresh version of Wordpress on the production server
  • Move wp-content folders via FTP: uploads, themes, plugins (if desired)
  • Export the MySQL database from the staging MySQL server, rename hostnames
  • Import the MySQL database to the production

In general this works pretty well. However I've never been able to get the media library files to successfully load on the new install. Since I uploaded all the uploads folders, the paths to the JPGs work. But in the Media Library they all show up w/o thumbnails. 

After much searching I found a plugin that reattaches the thumbnails in the new install. Tried it out and it works like a charm!


Wordpress Force Generate Thumbnails