Logo

Who is talking?

Archive

Free Continuous Integration for .NET Projects with TravisCI

about 3 years ago | Dave Kerr: dwmkerr.com

TravisCI offers free hosted continuous integration for Open Source projects. It's a great platform and I use it for some of my libraries, such as Angular Modal Service. Build Status If you are maintaining open source projects, CI is really useful. When people are creating pull requests, verifying that the code builds and the tests pass is critical, and having quick feedback on that is essential. TravisCI runs builds on Unix boxes, and it has no support out of the box for the .NET framework, Visual Studio and so on. But with the help of Mono we can use Travis to create a CI build. 2/12/2014: If you need more functionality and have an open source project, you can also try AppVeyor! Getting Started You'll need to be hosting your project on GitHub. Travis downloads your code from GitHub. Now sign up to Travis using your GitHub account, once you've done this follow the instructions on Travis to allow the two systems to communicate. The .travis.yml File Travis works by looking for a .travis.yml file in your repository and executing commands from it. All we need to do is set up our yml file to install mono and build the project. In this example, I want a CI build for my GlmNet project, which is an implementation of the GLM mathematics library for .NET. The details of the project aren't important, important is that it is a .NET class library with some tests. Here's how we might start with the yml file: language: c install: - sudo apt-get install mono-devel script: - xbuild source/GlmNet/GlmNet.sln We set the language to C (as Travis doesn't support C# it doesn't really matter!), install mono and build our solution. That's what we'd like to do, but nothing's ever that easy. It takes a little more than this to get it working, but in essence this is what we need. Installing Mono Installing mono is not as simple as apt-get install mono-devel, because the most Unix distros are using out of date versions of mono in their package sources. Here's a script that installs the latest version of mono - everything's commented so you can see what's going on: # Add the Mono Project GPG signing key. sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF # Add the Mono Package Repositories. echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list echo "deb http://download.mono-project.com/repo/debian wheezy-apache24-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list # Update the Package Cache. sudo apt-get update # Install Mono Complete. You might be able to get away with # mono-devel depending on which assembies you use from the # .NET framework, try it if you can, it'll make your # build quicker! sudo apt-get install mono-complete # sudo apt-get install mono-devel # Some tools like Nuget are going to make requests on # HTTPS resources. Mono doesn't trust SSL certificates # by default, so let's import Mozilla's list of trusted # certificates. mozroots --import --sync So this script basically adds a GPG key for the mono project, adds a new package source which has the latest mono versions, installs mono complete and updates the machines certificate store. This should be enough to install mono. If you have access to a Unix machine or VM, give the script a try. Now there are two ways to go from here - either we can save this script to a scripts directory in our repo and call it from the .travis.yml file, which keeps things clean, or we can just include what we need directly in the yml file. I'm going to include it directly in this article because it'll make it easier to follow, but for serious projects I'd suggest a scripts folder. That's because you can check out your repo to a test VM, and test each script in turn - it's harder to test the yml file. It also keeps the yml file clean as you build on it over time. So let's look at our yml file now: language: c install: - sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF - echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list - echo "deb http://download.mono-project.com/repo/debian wheezy-apache24-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list - echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list - sudo apt-get install mono-devel - mozroots --import --sync script: - xbuild source/GlmNet/GlmNet.sln Notice that I'm not doing apt-get update. We're on a clean VM and I'm speeding the build up by assuming my packages are up to date. I'm also only installing mono-devel, which is lighter than mono-complete, it has less .NET assemblies but all the ones I need. If you can get away with mono-devel, do it, it's faster. If the build complains about missing assemblies, then try mono-complete. The script part of the yml file uses xbuild, mono's compiler, to build our solution. Easy! We now have a running build, we can add the badge to the README.md file for the project and our Open Source .NET project has CI! Build Status Adding Unit Tests to the Build My project has nunit tests. Can we run those as well? Actually, this is super easy. Just update the .travis.yml file: language: c install: - sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF - echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list - echo "deb http://download.mono-project.com/repo/debian wheezy-apache24-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list - echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list - sudo apt-get install mono-devel nunit-console - mozroots --import --sync script: - xbuild source/GlmNet/GlmNet.sln - nunit-console ./source/GlmNet/Tests/bin/Debug/Tests.dll Notice the difference? We install nunit-console and run out tests assembly against it. Now the build will fail if the tests do not succeed! That's It I hope you found this useful, do let me know in the comments if you have any questions or suggestions. Troubleshooting Some issues you might run into are listed here. Error: Unmet Dependencies The following packages have unmet dependencies: mono-devel : Depends: libmono-system-runtime4.0-cil (>= 2.10.1) but it is not going to be installed I've have seen this happen if the correct repositories are not added, make sure you include the lines: # Add the Mono Package Repositories. echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list echo "deb http://download.mono-project.com/repo/debian wheezy-apache24-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list In your build. See Installing Mono on Linux for details. References Some resources that were useful: Installing Mono on Unix Donal Lafferty - Building your Microsoft Solution with Mono

Could not load file or assembly 'MySQL.Data' or one of its dependencies. Access is denied.

about 3 years ago | Sumit Bajaj: Sumit Bajaj's Blogs

It is very common error with .net assemblies. When someone included dlls from outside, in the project, this kind of exceptions are generic.Here is the resolution.Open the file location (MySql.Data.dll in this case)Right click on dll and check its properties (it should not be encrypted and should have right access permissions)Run the project after assigning appropriate permissions. It should work now.Even after this if it does not work. Check in web.config that assembly information is added under <compilation> tag.It is advisable to included new dlls using nuget package reference. It will update its reference automatically.Happy Coding!!!

When frameworks try to be smart, AngularJS & Expressions

about 3 years ago | Kristof Mattei: Kristof's blog

One of my colleagues just discovered this bug/feature in AngularJS. Using an ngIf on a string "no" will result in false. HTML: <div ng-app> <div ng-controller="yesNoController"> <div ng-if="yes">Yes is defined, will display</div> <div ng-if="no">No is defined, but will not display on Angular 1.2.1</div> <div ng-if="notDefined">Not defined, will not display</div> </div> </div> JavaScript: function yesNoController($scope) { … Continue reading "When frameworks try to be smart, AngularJS & Expressions" The post When frameworks try to be smart, AngularJS & Expressions appeared first on Kristof's blog.

When frameworks try to be smart, AngularJS & Expressions

about 3 years ago | Kristof Mattei: Kristof's blog

One of my colleagues just discovered this bug/feature in AngularJS. Using an ngIf on a string "no" will result in false. HTML: <div ng-app> <div ng-controller="yesNoController"> <div ng-if="yes">Yes is defined, will display</div> <div ng-if="no">No is defined, but will not display on Angular 1.2.1</div> <div ng-if="notDefined">Not defined, will not display</div> </div> </div> JavaScript: function yesNoController($scope) { … Continue reading "When frameworks try to be smart, AngularJS & Expressions" The post When frameworks try to be smart, AngularJS & Expressions appeared first on Kristof's blog.

Clojure Conj 2014 - Thank Yous, Noir Recommendations, Personal Highlights

about 3 years ago | Daniel Higginbotham: Flying Machine Studios

This year's Clojure Conj was a complete blast! I got to meet and reconnect with great, friendly, brilliant people, and had enormous fun the whole time. And by the way - if you were hoping to get a sticker, please email me at daniel@flyingmachinestudios.com and let me know how I can get one to you! The main thing I want to say is THANK YOU SO MUCH to everyone who went out of their way to share their appreciation for Clojure for the Brave and True; I know how easy it is to feel nervous about approaching a stranger! The book is a labor of love, an attempt at both expressing myself creatively and bringing joy to others through entertainment and education, and it is immensely gratifying to hear that my efforts are paying off. Putting myself out there over and over with each chapter and revision is nervewracking as hell, but y'all really make me feel like it's worth it. I have to admit, though, that I'm finding it hard to adjust back to normal life. Why aren't the other people waiting in this airport with me coming up and thanking me? Don't they know who I am!?!? Seriously, though - thanks everybody, and I hope you're enjoying your Clojure journey :) Second, I'm grateful to Alex Miller (@puredanger), Cognitect, and all of the excellent speakers for creating such a great experience for everyone. Send them your thanks, and go watch the talks at the ClojureTV YouTube channel. Did anyone else freaking love the crime museum? What an awesome choice for a party venue! If you're into noir/hardboiled entertainment, here are some recommendations: True Detective - I am completely nuts over the first season. The acting is superb, and the storytelling is some of the best you'll see in any TV show or movie. It actually ruined all TV for me - it was out around the same time as The Walking Dead, and it made The Walking Dead feel clunky and boring. This is the gold standard for noir entertainment. Sleeper, a gritty graphic novel by Ed Brubaker. Also check out his "Fatale" and "Criminal" series. His works are suspenseful and heartbreaking, with great art and great storytelling. Hard Magic / The Grimnoir Chronicles Frankly, I expected this book to be complete trash, but man did it grab me! I came away incredibly impressed at the author's ability to craft an action-packed novel that actually had depth with prose that exceeds most literary works. Now, normally I try to write stuff that's useful for readers, but the rest of this post is essentially fanboi raving because OMG I got to meet Bozhidar Batsov! Bozhidar is the Emacs Knight we need, and holy crap I got a private CIDER lesson from him. Expect an article on all the cool CIDER features you're not using in the near future. Other fanboi highlights: Getting to real-life meet Mike Marsh, one of the most prolific posters on Grateful Place and a thoughtful, smart, and genuine good guy. Meeting Brian Jennings, the man responsible for Emacs 24.4's lose-focus hooks. He gets about a million geek points for persuading the Emacs team, including and especially RMS, that the feature was a good idea. How cool is that? Totally bombing one of my programming jokes with a Clojure Olympian. That gets me geek points, right? Right? Eh? Eh? Hearing about a cool swarm intelligence project from a college hacker, Anthony, who also happens to be an awesome dude Spending time with Isaac Praveen and the rest of the Sparx team. Thanks for the drink, and thanks for the company! These guys are doing cool stuff and they are hiring Clojure devs. Meeting Angela Harms and Jason Felice, my new Buddha buddies. I'm hoping to see a lot of cool stuff at Maitria :D Talking to Johann Bestowrous (@opinionsonline) - do yourself a big favor and follow him on twitter, he is a funny dude Getting a sneak peek at the next version of Hostel Rocket. These guys are also hiring Clojure Devs, and they have a really cool product. It was great hanging out with folks, and I hope everybody had a safe trip home!

Facebook Connect With Passport.js

about 3 years ago | Eduard Moldovan: eduardmoldovan.com - tech

I needed a Facebook authentication implemented with node.js. Seamed ok to use Passport.js for this purpose, it looks liket it is maintained a fairly easy to use.

How to use Jenkins to monitor cron jobs

about 3 years ago | Steve Jansen: /* steve jansen */

Cron jobs have a funny way of being ignored. Either no one knows the job is failing because the job doesn’t tell anyone. Or, the job is spamming your e-mail inbox many times a day, regardless of success or failure, which means you just ignore the e-mails. I’ve seen the “Monitor an external job” option for new Jenkins jobs before, and never paid much attention. Turns out it’s a great bucket for storing logs and results of cron jobs. The external-monitor-job plugin seems to ship with the Jenkins war file. So, your Jenkins should have it out of the box. Creating a job is pretty simple. It’s just a name and description. Click “New Item” in Jenkins and select the “Monitor an external job” option. This creates a job of type hudson.model.ExternalJob. The wiki describes a fairly complicated method to download the Jenkins jar files onto the server running your cron jobs, and then use the Java runtime to run a jar with your cron script as an argument. The jar presumably forks your a new shell to run your desired cron command and sends the output/result to Jenkins. There’s a much easier way to do this. Redirect or tee your job’s stdout/stderr output to a temp file. Then post the result code and log file via curl to Jenkins. No need to download jar files. No need to even have Java runtime on the server. Just POST a small XML document with the log contents (binary encoded) and the exit code to Jenkins @ /job/:jobName/postBuildResult where :jobName is the URL encoded name of your monitoring job in Jenkins. [example cron script]1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 #!/bin/sh # example cron script to post logs to Jenkins # exit on error set -e log=`mktemp -t tmp` timer=`date +"%s"` jenkins_job=my_monitoring_job jenkins_server=http://jenkins.example.com:8080/jenkins/job/$jenkins_job/postBuildResult # see http://jenkins.example.com:8080/me/configure to get your username and API token jenkins_username=myusername jenkins_token=abcdef0123456789fedcba9876543210 function banner() { echo $(printf '#%.0s' {1..80}) >> "$log" } function report() { result=$? timer=$((`date +"%s"` - $timer)) banner echo "`whoami`@`hostname -f` `date`: elapsed $timer second(s)" >> "$log" echo "exit code $result" >> "$log" # binary encode the log file for Jenkins msg=`cat "$log" | hexdump -v -e '1/1 "%02x"'` # post the log to jenkins echo curl -X POST \ -u "$jenkins_username:$jenkins_token" \ -d "<run><log encoding=\"hexBinary\">$msg</log><result>$result</result><duration>$timer</duration></run>" \ $jenkins_server/job/$jenkins_job/postBuildResult } trap report EXIT; banner echo "hello, world @ `date`!" | tee "$log" [sample `crontab -e` entry]1 2 MAILTO="" 0 * * * * /bin/sh /your/directory/myjob.sh A sample of the build log on Jenkins with a green/red build status: Sample Jenkins Build Log Credit to Taytay on Stackoverflow.com for figuring out how to use hexdump to properly encode the XML for Jenkins.

Step 1 – R Authentication for Twitter

about 3 years ago | Ajay Mittal: R Handbook

Sentiment analysis – First Step Getting a developer Twitter account You can’t directly pull tweets from the twitter, to do so twitter comes up with OAuth handshake. It is necessary for every request to verify your app. Steps involved to pull tweets from twitter Create an app in Twitter. Go to the https://apps.twitter.com/ and log in with your […]

Discovering the Computer Science Behind Postgres Indexes

about 3 years ago | Pat Shaughnessy: Pat Shaughnessy

Captain Nemo and Professor Aronnax discussing theengineering and science behind the Nautilus. This is the last post in a series based on a presentation I did at the Barcelona

tmux in 5 Minutes

about 3 years ago | Daniel Higginbotham: Flying Machine Studios

If you work on projects that require you to open multiple terminal tabs, then tmux (and its super buddy, tmuxinator) will help you be more productive! tmux allows you to run multiple sessions in one terminal, and tmuxinator allows you to save tmux configurations. For example, if you're a Rails developer, you could easily open separate terminal sessions for running a Rails server, a Rails console, and tailing logs. When working on a Clojure-based forum I have four terminal sessions running: a shell, a grunt server building the frontend, datomic, and a shell for deployments: tmuxinator.png In order to start all this up, I only have to run one command: mux ath. This is much more convenient than trying to remember which services I need and manually starting each one up. Below are instructions for getting started with tmux and tmuxinator. First, install tmux using the instructions (for mac users) in this gist. Next, install tmuxinator using gem install tmuxinator Create your first tmuxinator config file under ~/.tmuxinator/sample.yml. Its contents should look like this, where the command under server is whatever's appropriate for your environment: name: sample root: ~/path/to/your/project pre: git pull windows: - shell: - server: bundle exec rails s The pre option runs that command in the root directory before trying to open any "windows". (I think of windows as tmux's "virtual tabs"). You can then start this tmux session with "mux sample". To navigate back and forth between the windows, use C-b n for "next window", and C-b p for "previous window". C-b means "hold down control and hit the 'b' key". To leave a tmux session, you use the key binding C-b d. If you leave the session, it's still actually running; any process you started in your windows is still executing. I rarerly ever use other commands, but if you need more, here's a tmux cheatsheet. To completely end a tmux session, you have to kill it. To do that, you run the command tmux kill-session -t sample, where "sample" is the name option in your tmuxinator config. I've created an alias for this, alias "tmk"="tmux kill-session -t". That way I only have to type tmk sample. I hope you find this useful! For more information, you can check out tmuxinator's github repo. You can do some pretty crazy stuff, like split your terminal into multiple panes. There's also a a handy book on tmuxinator available from the Pragmatic Programmers if you want to really go nuts with it. I hope you've found this tip useful!