Programming
Does DNS filtering still work?
DNS, or domain name system is how nice names like google.com get translated into an IP address and eventually find the server that has your content.
For this article we are going to focus on website filtering (or content filtering) since the goal is to block access to websites that are deemed inappropriate. This can be blocked by a parent, employer, ISP, or government regulation/policy.
Employers typically have an enterprise policy which gets pushed out to your web browser, and they often have a proxy at the edge of the network which does HTTPS inspection. That will make all of the techniques we are going to discuss irrelevant since the employer controls all aspects of the network. This article mainly focuses on non-enterprise users.
c++ programming quick tips
c++ is one of my favorite programming languages. It has been around a long time (I used it for my bachelor degree) and is very mature. The libraries and optimized algorithms are great to make software fast and efficient.
The downside is more modern languages provide a wide array of features that make development much quicker. One of the main features is garbage collection, which is a memory management technique that Python and many other languages have built-in. With c++ memory management is handled by you!
Default route or full routing table?
When a company/enterprise is signing up with an ISP for internet access, they are able to connect in many different ways, but we are going to go over a couple of the popular methods.
NOTE: This is a brief overview to answer this one question, BGP is very powerful and programmable, so we won’t touch on most of its features.
If the company has its own ASN (Autonomous System Number) they can connect to an ISP and advertise out this number through BGP with the IP space (prefixes) they own. That way other participants in BGP can find the best path to get to that company/ASN and the IP space. Companies will typically get an ASN if they are an ISP or if they are hosting some sort of content that others need to access. You can think of content as a website, portal, video, audio, VPN, or anything else that someone else needs to connect to from somewhere else. A large majority of the time this content is “in the cloud” instead of on-premise, but many larger organizations have their own equipment and data centers to handle accessing this content.
Some uwsgi settings for Django with StreamingHttpResponse
I have been working with Django quite a bit the last few months, and finally deployed the app into production. The setup uses uwsgi and nginx.
My Django app uses threads quite a bit, and when deployed to development server using uwsgi/nginx, it was painfully slow. As in it took 15 minute to run commands that should take 30 seconds. So it took a while of experimenting, and determined that a setting was missing in the uwsgi configuration.
Get the time and date in the future with different timezones in python
I recently had the need to figure out the date and time in my local timezone (Phoenix) for a future appointment. Bookings on a website don’t open until 12:01AM in their local timezone (HST), so how can you determine what date and time that is locally? Don’t want to be late to book! Counting on the calendar can be wrong by a day as well.
Python to the rescue. Two libraries make this easy: datetime and pytz.
Cumulus and Netmiko
This post will walk through a quick script that connects to a Cumulus switch and runs a command. Cumulus has a virtual machine appliance called VX available for free to run your tests on. Cumulus VX
Much of this can be found on the netmiko github:Netmiko
There is an examples directory that goes into more details for adding things like concurrency. If you are running this on 10+ switches in series, things get slow!
Meteor 1.5 and Code Splitting with React and React Router
Meteor 1.5 is out and we can finally do code splitting! If you are not familiar with code splitting, this allows us to separate our logic in a single page web app (SPA) and only send the client the relevant portions of code. This is useful in a couple immediate ways:
- You have a giant application that is too large to send at once (any script files over 1MB often take too long and the user experience is terrible)
- You want to keep some portions of code hidden until the user is authorized to see it
We are going to cover option 2 since that is a use case I just ran into. Sometimes splitting the code up can make the files larger (or the same size) so Meteor has provided a nice tool that helps visual how large the file sizes are once they are bundled. You can read more about that in this great post: Bundle Visualizer. Use the tool before the split, and after the split to make sure it doesn’t effect your code in the wrong way (compare the two).
Moving To Containers in Meteor (ES6) For React
The current way to connect Meteor into your React App is to use ES6 based components. Meteor has a function called “createContainer” that will send Meteor data into your React component as props instead of “this.data” access. This can make it a bit more complicated if you need to change your subscriptions based on React’s state, but we will talk about the new pattern you will need to use. This is a better pattern long term as you can switch out the top level data injection and re-use all your display logic (say you want to swap out Meteor down the road, or use Redux).
Re-factoring from React CreateClass to Native ES6 Classes
For the past few weeks I have been refactoring a client’s app to move from the React.CreateClass() format to the new and shiny ES6 class based format. We also re-factored Meteor from a mixin to the new createContainer component format. While we are at it, let’s demonstrate the functional based components for a child that only uses props (so not state). Functional components make the code much cleaner as you don’t need constructors for just display logic.
React in a WordPress page
If you are creating things with ReactJS, it’s sometimes nice to use it in WordPress. I will describe how to use it in a page, but this should also work for just a post.
You can do this pretty easily with a couple plugins:
“Scripts N Styles” - this plugin will allow you to add JavaScript to your Page.
“Per Page Add to Head” - this will allow you to add the necessary JavaScript libraries to the head portion of the WordPress page. This is how React is actually loaded.
Connect your Meteor App with MailChimp
Does your application have users? I hope so! Keep them around and active.
The best way to get users engaged, and keep them coming back is to use email marketing. You can create a sign-up workflow, move users to different workflows based on what they are doing in your app, and re-engage users that haven’t logged in for X months/weeks. Its very easy, so here is some code that connects to the MailChimp API and lets you add users to Lists. Lists are what trigger the emails for each email address.
Meteor, React and Browserify
I have been chasing down an odd issue with a Meteor/React app I am building. The error showing up in the browser console is:
You are currently using minified code outside of NODE_ENV === ‘production’. This means that you are running a slower development build of Redux. You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) to ensure you have the correct code for your production build.