Raspberry Pi printing server (with Brother HL-2035 inside)

    Here is some steps to install a printing server on a Raspberry Pi :

    • install, boot and execute raspi-config on Raspbian; reboot
    • sudo apt-get get update && apt-get upgrade
    • sudo apt-get install cups cups-pdf
    • sudo apt-get install foomatic-db
    • sudo usermod -a -G lpadmin pi
    • sudo vim /etc/cups/cupsd.conf

    Look for "Listen localhost:631" and replace by "Port 631"

    Then do these mods :

    < Location / >
     # Restrict access to the server...
     Order allow,deny
     Allow @local
     < /Location >
     
     < Location /admin >
     # Restrict access to the admin pages...
     Order allow,deny
     Allow @local
     < /Location >
     
     < Location /admin/conf >
     AuthType Default
     Require user @SYSTEM
     
     # Restrict access to the configuration files...
     Order allow,deny
     Allow @local
     < /Location >

    • Save and sudo /etc/init/cups restart
    • Browse to https://yourip:631 and add a printer don't forget to share it.

    If you own a Brother HL-2035 (or a 2030/2040), don't use CUPS+gutenprint but the Foomatic "driver" suggested by the CUPS web admin panel.

    Print Email

    Présentation AngularJS & Ionicframework le 15/09 (LaTechAmienoise)

    [fr-FR]

    Une fois n'est pas coutume, un post en Français pour mettre à disposition les éléments de ma presentation pour LaTechAmienoise sur Ionicframework le 15 septembre à 18h30 au Carré Lamartine (19 rue Lamartine à Amiens)

    Get it on Google Play

    [en-EN]

    You will find here some of the assets I will use tonight during my Ionicframework talk for LaTechAmienoise taking place at 6:30pm, Carré Lamartine, 19 Lamartine Street, Amiens

    Get it on Google Play

    Print Email

    Dynamic locale change with Ionicframework

    Loading locales in a AngularJS project is easy but quite limited. You can load locales like any other javascript asset but only one at starting time.

    So I decided to find a way to load several angularjs locales in my application. The idea was to select (or to detect if you wish) the desired locale, display locales (or currencies in my case) in a select box and once selected, update the content in the window (currency, dates, symbol, currency position...)

    I found a lot of help with the angular-dynamic-locale project from Lucas Mirelmann and I easily apply his methods in my code.

    First you need to create a blank Ionic project with ionic start myApp blank

    Then edit the app.js, we are going to add a few modules to it :

    • add tmh.dynamicLocale to the module section
    • we need to tell dynamicLocale where the i18n files are. You can drop them in a i18n/ folder in your project but I prefered to query angularjs servers (even if I think it is not a good idea, it's not a CDN, but it is for example purposes) :
       .config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider, tmhDynamicLocaleProvider) {
        tmhDynamicLocaleProvider.localeLocationPattern('https://code.angularjs.org/1.3.18/i18n/angular-locale_{{locale}}.js');
      })
    • we need to create a controller for our data to be exported to the view :

    .controller('indexCtrl', function($rootScope, $scope, tmhDynamicLocale, $locale) {

    $scope.amount = "10";
    $scope.currencies = {
        'fr-fr': 'French',
        'en-us': 'US' };
    $rootScope.model = {currencySelected: 'en-us'};
    $rootScope.$locale = $locale;
    $rootScope.changeLocale = tmhDynamicLocale.set;

    • this controller is quite simple, I defined an currency amount I will use with a currency filter. The list of currencies is also quite simple, you can add as much locale files as you want.
    • take a look at $rootScope.model wich is the default settings you will need to set for your app. In a real app I worked on I stored the default and saved locale settings in localeStorage, that may be a good hint for your projects...
    • tmhDynamicLocale.set is setting the locale and reloading the scope.

    Now the index.html :

    <ion-content ng-controller="indexCtrl">
        <div class="list">
            <div class="item item-input item-select">
              <div class="input-label">
                Select locale
              <select ng-model="model.currencySelected" ng-options="key as value for (key, value) in currencies" ng-change="changeLocale(model.currencySelected)"></select>
              </div>
            </div>
            <div class="item">
              <p>An amount of {{amount | currency}}</p>
              <p>A date {{0 | date}}</p>
            </div>
       </div>
    </ion-content>

    • don't forget to add the filters to your data (here : currency, date...)

    You can find the full github repo for this example here : https://github.com/lennycartier/angularjs-ionic-snippets/tree/master/ionic-angular-dynamic-locale

    Print Email

    Android APK signing automation with Ionicframework and Gradle

    It is very easy to automate signing at build time with ionicframework (or cordova) and gradle.

    You have to create a release-signing.properties file in platforms/android/, this file will be used by gradle to launch signing tools with the right parameters.

    It should be as follows :

    storeFile=/thepathto/key.p12
    storeType=jks
    keyAlias=yourkeyalias
    // optional
    // storePassword
    =yourstorepassword
    // keyPassword=yourkeypassword

    My key was generated using Java tools :

    keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

    Warning :

    • don't loose your passphrase
    • don't loose your keystore file
    • if you forgot your alias_name you can display it with : keytool -list -keystore my-release-key.keystore

    Bonus : gradle will also zipalign your apk. Ready to upload !



     

    Print Email