Angular JS Controller error Argument is not a function

Jul 23

Broken Control error in Angular Today I got an error of several hello world todo examples in AngularJS when I tryed new 1.3 version. Error like: Error: [ng:areq] Argument 'sarcCntrl' is not a function, got undefined Prevent bad habits It seems that they have broken the api. See my working example: http://jsfiddle.net/patriklindstrom/XGeJb/ See the broken example: http://jsfiddle.net/patriklindstrom/LGhEJ/ See my fix of the broken example: http://jsfiddle.net/patriklindstrom/5cFy8/ Only difference is the version of AngularJS If you change the external resource in jsfiddle from beta 1.3.0-beta.16 to previous version like //ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js it starts to work. So lots of AngularJS democode on the net will stop working. See: Angular Changelog and reason given With the exception of simple demos, it is not helpful to use globals for controller constructors. This adds a new method to `$controllerProvider` to re-enable the old behavior, but disables this feature by default. BREAKING CHANGE: `$controller` will no longer look for controllers on `window`. The old behavior of looking on `window` for controllers was originally intended for use in examples, demos, and toy apps. We found that allowing global controller functions encouraged poor practices, so we resolved to disable this behavior by default To make it work: Before: function MyController() { // ... } After: angular.module('myApp', []).controller('MyController', [function() { // ... }]); or you could set the settings back to allow global controllers. angular.module('myModule').config(['$controllerProvider', function($controllerProvider) { // this option might be handy for migrating old apps, but please don't use it // in new ones! $controllerProvider.allowGlobals();...

Read More

Vas-Stickan simple Xamarin App

Jun 08

Xmarin Crossplattform slider I have started to write a crossplattform app with Xamarin for ios, windows and Android devices. I started using Xamarin a year ago. But did not get anywhere. I restarted now and decided to make a Hello world applikation in the form of a slider. This slider can be used to give a level of much pain you have. IRL they are used by nurses and doctors when asking patients: Show us on this stick how much pain you have on a scale between 0 and 10. Screenshot of iPad emulator on Mac Code is here: https://github.com/patriklindstrom/VAS-Stickan Ill add more blogpost as I evovole. My goal is to make and publish a simple app on all three plattform with unit test and shared code. Also share problems with publishing them on all three app stores. The important code is in the ViewController I decided to declare all GUI in code instead of xml or XAML. I wanted control over it and I did not get the XCode GUI drag and drop to work. public class MyViewController : UIViewController { UISlider _sliderVas; private const float SLIDER_WIDTH = 630; private const float SLIDER_HEIGHT = 50; UILabel _lblValue; private const float LBL_VALUE_OFFSET = 300; private const float LBL_VALUE_WIDTH = 50; private const float LBL_VALUE_HEIGHT = 50; UILabel _lblHeader; private const float LBL_HEADER_OFFSET = -300; private const float LBL_HEADER_WIDTH = 200; private const float LBL_HEADER_HEIGHT = 50;   public MyViewController() { }   public override void ViewDidLoad() { base.ViewDidLoad();   View.Frame = UIScreen.MainScreen.Bounds; View.BackgroundColor = UIColor.White; View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; //label   _lblHeader = new UILabel(componentRect(View.Frame, LBL_HEADER_WIDTH, LBL_HEADER_HEIGHT, LBL_HEADER_OFFSET)){ Text = "VAS - Stickan", AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleBottomMargin, Font = UIFont.FromName("Helvetica-Bold", 40f), AdjustsFontSizeToFitWidth = true, // gets smaller if it doesn't fit LineBreakMode = UILineBreakMode.TailTruncation, Lines = 1, // 0 means unlimited }; View.Add(_lblHeader); // slider _sliderVas = new UISlider(componentRect(View.Frame, SLIDER_WIDTH, SLIDER_HEIGHT, 0)) { AutoresizingMask = UIViewAutoresizing.FlexibleWidth , MinimumTrackTintColor = UIColor.Green, MaximumTrackTintColor = UIColor.Red, MinValue = 0f, MaxValue = 10f, Value = 2.5f }; View.Add(_sliderVas); _sliderVas.ValueChanged += OnSliderValueChanged; //label _lblValue = new UILabel(componentRect(View.Frame, LBL_VALUE_WIDTH, LBL_VALUE_HEIGHT, LBL_VALUE_OFFSET)){ Text = "Your Pain", AutoresizingMask = UIViewAutoresizing.FlexibleWidth , Font = UIFont.FromName("Helvetica-Bold", 40f), AdjustsFontSizeToFitWidth = true, // gets smaller if it...

Read More

Hello Bing Translator

Oct 05

I am learning how to use the Bing translator via the Azure marketplace. Describes a console application that uses bing translation rest api. There are many rites where you have to register with microsoft to get keys. More will come…

Read More

shorinji kempo notes

May 08

The new Shorinji Kempo Stockholm Södra youtube film The new Shorinji Kempo Stockholm Södra youtube film is on youtube now Preparation notes for my classes Lesson 18 Explore Ten’o ken Lesson 17 You need a sidekick. Lesson 16 Three principles in the wrist. Lesson 15 Copy the Embu and then leave it. Lesson 14 Dirty Go Ju ittai. Lesson 13 Explore Sango-Ken Branch of Shorinji Kempo tecniques. Lesson 12 How to train Kempo. Set goal. Explore branches of tree Lesson 11. Principle of Shorinji Kempo. Teko no ri, Kuruma no ri, Hazumi no ri Lesson 10. Basic Shorinji Kempo Lesson 9. Sneaky stances Lesson 8. Calm in Dire straits Lesson 7. Long mits combination Missing Lesson 5. Self defence two against one Lesson 4. Randori block with legs and arms Lesson 3. Defence first attack later Lesson 2. Attacks at different levels Lesson 1. Rotate your torso three...

Read More

Hello World Rhino ETL

Nov 25

Rhino-Etl is an Opensource framework for doing Extract Transform and Load of data (ETL) in C#. There are other commercial ETL products that can do this as well. I have mostly used Microsofts SSIS. It is easy to get started with SSIS and it has good performance. But in my humble opinion is it hard to keep track of the changes in the SSIS projects. All logical rules of the transformation of the data dissapperas in a forrest of boxes and lines that has to be clicked on. SSIS marriage to code repositories resemble the marriage Tom & Kate – its just afront. The debate over ETL tools as SSIS can be emotional so I wanted to show an other path: An ETL tool that is more traditional C# developer centric: Rhino-ETL. With this tool you can program all ETL in normal C# classes or you can choose to do it with DSL script files in the BOO language and run them with Rhino-ETL-command tool. The example that follows with Rhino-ETL shows how to load two textfiles, join them and transform columns and finally put the rows somewhere. In this example it only puts them on the screen. I hope it will get people up to speed a little faster than it took me to realize that it was quit simple. All code is avaible at my github repository:github.com/patriklindstrom/HelloWorld-Rhino-ETL First step is to create a simple console windows application in Visual Studio. Second step is to install Rhino-ETL components. The simplest way is to import a Nuget package with Rhino-ETL and all its dependent objects. You could instead download Rhino-ETL yourself build it and include the components in your project. It is a little more cumbersome and will take five to 30 minutes instead of just under a 1 minute. You could use the built in powershell package manager or the graphical one. Below is a screenshot how I use the graphical Nuget package manager and search for Rhino-ETL. You can see what packages that was installed: Third step write your code. Rhino-ETL has two main classes: EtlProcess and AbstractOperation. You register your operation in the Initialize() method of the EtlProcess. So if would have three Operations: Extract data,...

Read More

My chinese javascript sorting plugin is added to the datatables jQuery component on GitHub

Jul 23

Allan Jardine accepted the pull request I did. See here http://datatables.net/plug-ins/sorting#chinese-string. Yipee I am a contributor. On Github I first made fork on the plug-in repository. That copied it all to my GitHub repository. After that I made a local repository with GithHub for windows. The first thing I did was a branch on my local repository called chinese-sorting. I saw on youtube that this was the way that Linus Torvald wanted it to be done. I slowly did my development and testing on the branch. To check from time to time if there had been any changes on the original datatables plug-in repository on GitHub I used the git fetch command. ( You get that in the powershell module in git for windows) When I felt that this was ready. I synced my localrepository with my GitHub repo. Then I finally was ready to click on the pull request button. Allan Jardine at Datatables could then compare my branch chinese-sorting with the master branch and he felt that it was ok and merged it with the master branch....

Read More

ClosedXML det enkla sättet att exportera till Excel

Jul 23

I flera projekt har jag använt ClosedXML för att spara i Excelformat. Kan verkligen rekommendera den. Den förenklar OpenXML formatet betydligt. För ett exempel. Gå till den här demositen och klicka på Excel så laddas data som man ser till Excel. Lagerhantering. ClosedXML finns att hämta ned via Nuget eller codeplex. Det är bara att skriva: Install-Package ClosedXML i packet manager consolen så installeras det i Viual Studio projektet. Nedan är ett exempel. Ett Proof of concept. Där jag ska exportera data (olika fonders statiska data) till Excel. Användaren väljer i websida att de vill ladda ned data i excel. Kärnan i koden är // Som inparameter skickas en lista på objekt från databasen. // Dessutom skickas en url där man kan uppdatera data. Detta för att jag vill att det ska finnas // en länk i Excelbladet för att kunna uppdatera data om man vill det. MemoryStream ms = CreateExcelFile(db.Funds.ToList(), urlStr); // I privata metoden CreateExcelFile är den viktigaste koden: // Create an Excel Workbook XLWorkbook wb = new XLWorkbook(); // Add the worksheet IXLWorksheet ws = wb.Worksheets.Add("New Worksheet"); ws.Cell(++curRow, curCol).InsertTable(fundList.AsEnumerable()); Sedan är det en massa kod för att autojustera kolumnbredden. Skriva lite i cellerna högst upp i Excelbladet om när exporten gjordes och vem som gjorde exporten vilken url man kan gå till för att uppdatera mm. Här har jag ställt en fråga på stackoverflow om hur man ska exportera data med ClosedXML och få med sig object annotations som display name. Det visade sig vara lättare än jag trodde. private HaxitDB db = new HaxitDB();   // // GET: /Api/   [HttpGet]   public ActionResult DownloadFundsAsExcel() {   //See http://closedxml.codeplex.com/wikipage?title=How%20do%20I%20deliver%20an%20Excel%20file%20in%20ASP.NET%3f&referringTitle=Documentation // see http://closedxml.codeplex.com/discussions/248214 string host = "wsp1063c:8080/"; string urlStr = "http://" + host + "Api/DownloadFundsAsExcel/"; MemoryStream ms = CreateExcelFile(db.Funds.ToList(), urlStr); if (ms != null) { // return the filestream // Rewind the memory stream to the beginning ms.Seek(0, SeekOrigin.Begin); string filename = "OneFundStaticDataFundList" + ".xlsx"; return File(ms, @"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml", filename); } // No Excel file, reshow the same view return null; }     private MemoryStream CreateExcelFile(IList fundList, string urlStr) { try { // Create an Excel Workbook XLWorkbook wb = new XLWorkbook(); // Add the worksheet IXLWorksheet ws = wb.Worksheets.Add("New Worksheet"); #region Add data to Excel...

Read More