Securing SSH

Securing SSH

Coding, Guide
If you are using SSH, you'll want to run down this checklist of to make that ssh server a bit more secure. If any of these settings is absent from the configuration file, you should add them. For Ubuntu this is in the file /etc/ssh/sshd_config Change Port This is more of a security through obscurity approach, but it'll help slow down bot scrapers. Change this value to something else. Port 22 Set Client Timeout ClientAliveInterval configures the server to send null packets to clients each 10 seconds. ClientAliveCountMax configures the server to close the connection if the client has been inactive for 300 seconds. In this case that is 10*300 = 3000 seconds or 50 minutes. ClientAliveInterval 10 ClientAliveCountMax 300 Disable empty passwords PermitEmptyPasswords no Limit Login Attempts MaxAuthTries 3…
Read More

MongoDB Mac Cheat Sheet

Coding
Install MongoDB with brew. To start mongodb: brew services start mongodb To stop mongodb if it's already running: brew services stop mongodb Tools Robomongo / Robo 3T Commands MongoDB Statistics - To get stats about MongoDB server, type the command db.stats() Currently selected database, use the command db Databases list, use the command show dbs Create collection use db.createCollection("mycollection") View collections show collections Drop a collection db.COLLECTION_NAME.drop() Basic syntax of insert() command is as follows − db.COLLECTION_NAME.insert(document) Query data with find - db.COLLECTION_NAME.find() To display the results in a formatted way, you can use pretty() method - db.mycol.find().pretty() Equality {:} db.mycol.find({"by":"tutorials point"}).pretty() where by = 'tutorials point' Less Than {:{$lt:}} db.mycol.find({"likes":{$lt:50}}).pretty() where likes < 50 Less Than Equals {:{$lte:}} db.mycol.find({"likes":{$lte:50}}).pretty() where likes <= 50 Greater Than {:{$gt:}} db.mycol.find({"likes":{$gt:50}}).pretty() where likes…
Read More
Using GIT Properly

Using GIT Properly

Coding, Guide
Everyone needs to get into the habit of branching when they use GIT. Whether it's a new feature, a bug fix, or a small improvement to some existing code, every ticket should get its own branch. Do some work on this branch, committing early and often (for instance, whenever your tests pass). Also make sure to use the Atomic Approach to creating commits. It shouldn’t be uncommon for you to have 10-30 commits per day. Atomic Approach • Commit each fix or task as a separate change • Only commit when a block of work is complete • Commit each layout change separately • Joint commit for layout file, code behind file, and additional resources The seven rules of a great Git commit message 1. Separate subject from body with…
Read More
Auto Follow Twitter Users

Auto Follow Twitter Users

Coding
I'm often tasked with building a twitter user's following. This script is for the console of your web browser and it will click all of the Follow Buttons for you automatically. var FOLLOW_PAUSE = 1250; var FOLLOW_RAND = 250; var PAGE_WAIT = 2000; __cnt__ = 0; var f; f = function() { var eles; var __lcnt__ = 0; eles = jQuery('.Grid-cell .not-following .follow-text').each(function(i, ele) { ele = jQuery(ele); if (ele.css('display') != 'block') { console.trace('Already following: ' + i); return; } setTimeout(function() { console.trace("Following " + i + " of " + eles.length); ele.click(); if ((eles.length - 1) == i) { console.trace("Scrolling..."); window.scrollTo(0, document.body.scrollHeight); setTimeout(function() { f(); }, PAGE_WAIT); } }, __lcnt__++ * FOLLOW_PAUSE + Math.random()*(FOLLOW_RAND) - FOLLOW_RAND/2); __cnt__++; }); } f(); Unfollow People who Don't follow you! $('.ProfileCard-content').each(function () {…
Read More
MySQL Best Practices

MySQL Best Practices

Coding, Guide
Database operations often tend to be the main bottleneck for most web applications today. As programmers need to do our part by structuring tables properly, writing optimized queries and better code. Table Names By convention, the "snake case" in lowercase (no PascalCase - we're not using Microsoft SQL Server here!), plural name of the class will be used as the table name unless another name is explicitly specified. Tables should also be named based on their respective contents. Try to avoid naming tables based on a single use case and think more about how that table will be expanded in the future. If you're not sure how to name the table ask your manager before creating it. eg: To find an order product we would look in the order_products table  Primary Keys The…
Read More
Summernote Image Upload

Summernote Image Upload

Coding
NOTE: This only applies to Summernote 0.6.* and not to newer versions. $('#summernote').summernote({ height: 850, toolbar: [ ['style', ['fontsize','fontname','bold', 'italic', 'underline', 'clear']], ['color', ['color']], ['para', ['ul', 'ol', 'paragraph','hr','link','picture']], ['src',['fullscreen','codeview']] ], onImageUpload: function(files, editor, welEditable) { sendFile(files[0], editor, welEditable); } }); function sendFile(file, editor, welEditable) { data = new FormData(); data.append("file", file); $.ajax({ data: data, type: "POST", url: "/admin/upload", cache: false, contentType: false, processData: false, success: function(url) { $('#summernote').summernote('editor.insertImage', url); } }); }
Read More
Connecting to Ubuntu Servers With RSA Keys

Connecting to Ubuntu Servers With RSA Keys

Coding, Guide
I manage a bunch of internal servers and for those that aren't part of the wider web I like to use key pairs to speed up my sign ins and maintenance. Key-Based SSH Logins Key-based authentication is the most secure mode of authentication usable with OpenSSH. Key-based authentication has several advantages over password authentication, for example the key values are significantly more difficult to brute-force, or guess than plain passwords, provided an ample key length. Key-based authentication uses two keys, one "public" key that anyone is allowed to see, and another "private" key that only the owner is allowed to see. To securely communicate using key-based authentication, one needs to create a key pair, securely store the private key on the computer one wants to log in from, and store the…
Read More