Using JSON Web Tokens to Authenticate JavaScript Front-Ends on Rails While working on a project recently, I encountered a problem I haven't had to tangle with in a while: authenticating front-end applications against a Rails API. The last time I was even dabbling in this realm, jQuery was everything, CORS was still in its infancy, and JSONP was still a thing (that's not a thing anymore, right?). The only way I ever managed to scrape by in this hostile environment was to let Rails' asset pipeline serve up the front-end app and rely on same-origin requests and regular ol' cookies to handle authentication. Since those dark times, a few tools have cropped up and improved the landscape. At first, I got started by symlinking the front-end to public/ in my Rails app and setting protect_from_forgery with: :null_session. There were a few other, related problems to solve, but I want to focus on how I did authentication for the rest of this post. To that end, I scrapped together a handful of tools, blog posts, and sites that have already solved this problem.
Learn Breeze 15 Useful AngularJS Tools For Developers - Hongkiat Thinking of dipping your toes into Angular? If you have gone through our 10 best tutorials to learn AngularJS post and would like to play around with Angular on your own, you’re on the right post. We have here some tools that can streamline your development workflow. We’re looking at 15 of the best IDEs, text editors, tools for testing & debugging, modules and development tools and apps for building with Angular. Recommended Reading: More Posts On AngularJS IDE & Text Editor In the programming world, there are two types of editors: full featured Integrated Development Environment (IDE) and lightweight text editors. WebStorm WebStorm is suited not just for Javascript but also HTML and CSS. Aptana Aptana is a free open source IDE which is actually the customized version of Eclipse focusing on Javascript, HTML, CSS and other web goodies. Sublime Text More on Sublime Text: Testing & Debugging Tools Karma Jasmine MochaJS Protractor Angular Batarang ng-inspector Modules AngularUI Restangular Angular Gettext
My vi/vim cheatsheet Cursor movement h - move leftj - move downk - move upl - move rightw - jump by start of words (punctuation considered words)W - jump by words (spaces separate words)e - jump to end of words (punctuation considered words)E - jump to end of words (no punctuation)b - jump backward by words (punctuation considered words)B - jump backward by words (no punctuation)0 - (zero) start of line^ - first non-blank character of line$ - end of lineG - Go To command (prefix with number - 5G goes to line 5) Note: Prefix a cursor movement command with a number to repeat it. For example, 4j moves down 4 lines. Insert Mode - Inserting/Appending text i - start insert mode at cursorI - insert at the beginning of the linea - append after the cursorA - append at the end of the lineo - open (append) blank line below current line (no need to press return)O - open blank line above current lineea - append at end of wordEsc - exit insert mode Editing Marking text (visual mode) Visual commands Cut and Paste Exiting
Environment Specific Configuration In AngularJS using Grunt - Newtriks LTD Written by Simon Bailey One aspect of Rails I love is the simplicity of environment specific configuration. Out the box, Rails provides configuration for development and production environments and additions are effortless to implement. Using Angular, I typically create a constants module for the application configuration e.g. api url’s, third party service specific data, etc. AngularJS & Grunt I will use Yeoman as usual to setup the project. Plan of action Create an AngularJS app.Create a development config file.Create an Angular constants module.Setup grunt tasks to inject the environment specific data into the Angular app constants.Load the module constants into the app.Configure grunt tasks for app builds based on multiple environments. Create the app mkdir env-config-example && cd $_ yo angular npm install Setup the env-config generator npm install generator-env-config Create the development configuration yo env-config Create the AngularJS configuration yo env-config:angular config …Tidy!
Using FreeTDS to connect to SQL Server from Debian Apache/PHP This post describes how to set up a web site which uses PHP to connect to a backend SQL Server database using FreeTDS. I wrote it because I found the documentation currently available a bit confusing until I had completed the task, when it turned out to be really simple. I am setting up a development environment for a project I will be undertaking which ports a Microsoft Access application connected to a SQL Server database to become a web application. To avoid a complete tie in with Microsoft technologies I decided to use an Apache Web server running PHP as the main platform for this application. Although the final system will probably run on a Windows server, it is much more convenient for me to develop in a Linux environment where I have all my tools setup. I started reading the documentation to figure how to do it but I found it quite confusing. The first puzzle is which Debian packages do you actually need to install. And that is all there is to it.
Using rails-api to build an authenticated JSON API with warden | code - lucatironi An updated version of my previous tutorials on building an authenticated JSON API with Ruby on Rails In this tutorial I will build a small web application that provides a JSON API to manage customers through a REST interface. The requests to the endpoints will be authenticated through a token based authentication strategy, passing custom headers (X-User-Email and X-Auth-Token) containing the user’s credentials. A sessions endpoint is available to issue a new authentication token on login and disposing it on logout. The goal of the tutorial is building the base of an up-to-date, well tested, minimal and functional backend API that can be used for clients such as Angular/Ember web apps or even Mobile applications. Requirements Rails::API is a subset of a normal Rails application, created for applications that don’t require all functionality that a complete Rails application provides. The complete code for this tutorial can be found on my Github account. Setup Testing Customers Model Routing Setup
How to Turn Your Raspberry Pi into a Fully Functional Web Server Posted by dconroy on Mar 28, 2013 in How To's, Raspberry Pi | 12 comments | 4,080 views First we will start with the shopping list. You will need one of each of the required items. This list is assuming you already have a USB keyboard and USB mouse. *Prices are subject to change After you’ve collected your hardware, you need to flash your operating system onto your SD Card. To flash your SD Card, you will need to unzip the image and write it your SD card using Win32DiskImager. After the image is flashed, you can boot your device. host:raspberrypi Username: pi Password: raspberry For this tutorial, I will be using putty. sudo raspi-config The settings I recommend you update are update expand_rootfs change_pass change_timezone memory_split The usual distribution images are 2 GB. After you finish your changes to the raspi-config, you should reboot your pi using the following command: sudo shutdown -r now First, run the following commands from the shell to install Apache and PHP. And that’s it!
How to do loading spinners, the Angular way. Updated on 6/25/15 One interesting problem I had to solve recently was how to elegantly deal with loading spinners on the page without violating separation of concerns. Many times, the spinner element is in an area of the DOM controlled by the relevant controller and you can simply toggle a variable in scope and it just works. app.controller('myCtrl', function ($scope, $http) { $scope.loading = true; $http.get('/some/awesome/content') .success(function (data) { }) .catch(function (err) { }) .finally(function () { $scope.loading = false; });}); This works great, but what if your spinner is in a DOM tree that isn't managed by the controller that needs to show it? Even if you manage to solve this scenario, how then do you solve situations where you need to show/hide multiple loading spinners? The directive: Of course, we love directives and some kind of spinner directive seems to make immediate sense. See how the directive calls spinnerService. The directive would look something like this:
tocpj/articles/V002/7TOCPJ.pdf Printing to a zebra printer from VB.Net Printing to a zebra printer from VB.Net by Christiaan Baes (chrissie1) on June 16, 2008 in category Microsoft Technologies VB.NET. Article views: 27,389 Instapaper This code is based on code I found from Rick Chronister, but I can’t find the article anymore. Imports System.IO Imports System.Runtime.InteropServices Namespace ZebraLabels ''' <summary> ''' This class can print zebra labels to either a network share, LPT, or COM port. ''' ''' Programmer: Rick Chronister ''' </summary> ''' <remarks>Only tested for network share, but in theory works for LPT and COM. You use it like so. Dim _print as new ZebraPrint _print.StartWrite("//printserver//zebra001") _print.Write("Print test.") You can also write barcodes with it. like this Dim _print as new ZebraPrint _print.StartWrite("//printserver//zebra001") dim _Text as String = "Print test" _print.Write("A30,120,0,4,2,1,N,""" & _Text & """") _print.EndWrite() You can find all the code characters in your zebra manual. About the Author Chris is awesome.