Posts

Showing posts from 2015

Soving AccessDenied on Google Cloud Storage domain mapping

As I was facing this again trying to create amp pages for my main site www.tekartik.com , here is a concrete example for my changes Adding the proper DNS redirection in my domain provider (OVH in my case) www.tekartik.com. CNAME c.storage.googleapis.com. This was first giving the error: <Error>   <Code>AccessDenied</Code>   <Message>Access denied.</Message>   <Details>Anonymous callers do not have storage.objects.list access to bucket www.tekartik.com.</Details> </Error> the solution was to configure my bucket as a website configuration : gsutil web set -m index.html -e 404.html gs://www.tekartik.com And to make all files I add public by default and not worry about ACL anymore, I can use gsutil defacl ch -u AllUsers:R gs://www.tekartik.com To make previous imported files public, I can use gsutil -m acl -r set public-read gs://www.tekartik.com

Mercurial back in time, going back to a previous revision

After making some changes in a project and finally forking part of it into another project, I wanted to get back in time to the state where it was 2 days ago. I really did not want to create a new branch but rather have repository matching the state it was 2 days ago (i.e. the files added are then removed but still in the history). The easiest I found out was to find the last revision I wanted to included in my bitbucket project and then do: hg revert --all --rev <my_rev> hg commit -m "revert to <my_rev>"

Delete a Managed VM instance

I had a Dart managed VM running. Since it was an experiment, I wanted to stop and delete the running instances to prevent extra costs. In the console, each time I try to stop or delete the instances, it keeps restarting. The only solution I found (for now, it seems google is working on a allowing deleting managed vm instances) was to upload a non-managed AppEngine application. The simplest setup I use is with the go language. Create the following app.yam l file (here I want to replace the default module. Otherwise enter the proper module name) module: default runtime: go api_version: go1 handlers: - url: / static_files: index.html upload: index.html secure: always Create a dummy main.go file package noserver func init() { } And dummy index.html file <html lang="en"> <head> <title>No server</title> </head> <body> <pre>no server</pre> </body> Then deploy to your <appname>.appspot.com

Dart on AppEngine logging on local dev server

While logging works fine on AppEngine I could not manage to have print or any logging when using local development target. It turns out that stderr output is working fine so the solution I ended up with was to create a logger handler (when running locally) that output logging output on to the console. Below is the simplest hello world app that do log fine both locally and on the server import 'dart:io'; import 'package:appengine/appengine.dart'; import 'package:logging/logging.dart'; import 'package:args/args.dart'; main(List args) async { Logger _log = new Logger("app"); ArgParser parser = new ArgParser(); parser.addOption("port", abbr: "p", defaultsTo: "8080"); parser.addFlag("help", abbr: "h"); ArgResults results = parser.parse(args); if (results["help"]) { print(parser.usage); exit(0); } // On dev server we have GAE_PARTITION="dev" // Red

Dart on AppEngine experiment 1 - avoid killer prices and use f1-micro instances

My first Dart AppEngine experiment doing a dummy HelloWorld turned out to be super expensive. Monitoring the project, 2 instances were always running, costing several bucks for doing...absolutely nothing...It seems that by default custom vm use a rather big instance. Event worst, I was not able to stop these instances that kept restarting. The solution I ended up with was to upload a managed VMs (go in my case) dummy project instead where I could then make as the default and stop the previous instances in a proper way I wanted to try running dart on a micro instance Locally I managed to run my app using: dev_appserver.py --custom_entrypoint "dart bin/server.dart --port {port}" app.yaml and killing my app properly when needed using pgrep -f dev_appserver.py | xargs kill -9 dev_appserver is actually detecting changes as I change my dart file and restart my server, however since it binds to the same port, it sometimes fails. To deploy I can use the following app

A Contact Form using mdl hosted on Blogger

Image
Getting a contact form on a static website always ends up with an ugly solution (Google sheet form or external website) and using free hosting (wordpress) requires to stick with a given style. Blogger has a contact form that people manage to use with a personal style. I wanted to try blogger template for a long time and was wondering whether it could play well with Material Design Lite. I created a new "blog" that will only contain the contact form for the sake of simplicity. The simplest template I ended up with was this: <html xmlns:b="http://www.google.com/2005/gml/b"  xmlns:data="http://www.google.com/2005/gml/data" xmlns:expr="http://www.google.com/2005/gml/expr"  xmlns="http://www.w3.org/1999/xhtml"> <head> <title><data:blog.pageTitle/></title> <b:skin></b:skin> </head> <body> <b:section id="main_section"></b:section> </body> Add

Resolving Dart external name from dependencies in WebStorm

After several months with WebStorm, I was still wondering why sometimes a class or function from an external Dart package was not resolved when trying to go to its definition. It turns out that i need to include the package(s) manually https://www.jetbrains.com/webstorm/help/managing-dart-packages-and-assets.html The simplest I found was to right click on the packages directory at the root and to right click Mark Directory As | Cancel Exclusion , although sometimes selecting only the packages I import was sufficient.

Dart on Google Cloud Shell

Google Cloud Shell is available for free until the end of 2015. Good opportunity to try it! It starts right away from google cloud console https://console.developers.google.com/project/ from the Activate Google Cloud Shell icon at the top right Let's install Dart $ sudo sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -' # Set up the location of the stable repository. $ sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list' $ sudo apt-get update $ sudo apt-get install dart $ dart --version Dart VM version: 1.12.1 (Tue Sep  8 11:14:08 2015) on "linux_x64" Somehow pub is not symlinked properly so it is needed to symlink it somewhere (I tend to use /usr/local/bin). $ sudo ln -s /usr/lib/dart/bin/pub /usr/local/bin/pub $ pub --version Pub 1.12.1 yeah! git is (of course) installed so I can checkout any project and work on th

Dart, travis and content_shell

Up to now I was using drone.io for testing my dart packages after a commit. As of today, as dart was stuck to an earlier version (1.10 while 1.13 will soon be out), I decided to try travis. After signin up with my github credentials it proposed me right away all my public projects. Good surprise, integration is as simple as selecting your project in travis and adding the following .travis.yml at the root of your project language: dart dart:   - stable   - dev sudo: false script: pub run test Even better, I was never able to execute my browser test and adding content-shell support is as easy as updating the .travis.yml file with the following content language: dart with_content_shell: true dart:   - stable   - dev sudo: false before_install:   - export DISPLAY=:99.0   - sh -e /etc/init.d/xvfb start script: pub run test -p vm -p content-shell The before install steps are puzzling and explained (somehow) here

dart 1.12, boot2docker and ubuntu 15.04

After some successful attempts some time ago using the appengine and dart tutorial. My boot2docker setup seems to be broken. In virtual box, I deleted the boot2docker-vm $ docker run google/dart /usr/bin/dart --version Using default tag: latest Error response from daemon: client and server don't have same version (client API version: 1.20, server API version: 1.19) $ docker version Client:  Version:      1.8.2  API version:  1.20  Go version:   go1.4.2  Git commit:   0a8c2e3  Built:        Wed Oct  7 17:53:44 UTC 2015  OS/Arch:      linux/amd64 Server:  Version:      1.8.2  API version:  1.20  Go version:   go1.4.2  Git commit:   0a8c2e3  Built:        Wed Oct  7 17:53:44 UTC 2015  OS/Arch:      linux/amd64 I removed my docker installation (currenly 1.8.2) with sudo apt-get remove docker docker-engine Although I might have simply needed to stop the service Since I installed docker using the official installation, I downgrade docker manually $ sudo rm /usr/lo

Change Intellij source control integration

I use both Mercurial (hg) and git and now switched to WebStorm for Web development and Android Studio for Android. When you want to enable source code integration Intellij asks you which version control system to use (wonder why it does not try to look recursively in parent folders for any .hg or .git folder) Remove source code integration Go to Settings (or Preferences on Mac) then choose Version Control and delete the offending line  - typically there is only one - in the mapping list using Delete or the "-" button In a terminal or file explorer remove the incorrect .git or .hg folder that intellij might have created (don't delete the correct one if there was one before) Then you can enable source control integration again using  VCS|Enable Source Control Integration ... and pick the correct version control system!

Add Android unit test to existing android studio project

Here I'm talking about tests that needs Emulator or a device to run, not pure java unit test. For example for testing a provider. The test example is pure java though but it is a simple proof of concept. Add the following in your build.gradle apply plugin: 'com.android.application' android { ... defaultConfig { … testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' } } dependencies { ... // test dependency testCompile 'junit:junit:4.12' testCompile group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3' // AndroidJUnit Runner dependencies androidTestCompile 'com.android.support.test:runner:0.3' // Set this dependency to use JUnit 4 rules androidTestCompile 'com.android.support.test:rules:0.3' // Dependency conflict androidTestCompile 'com.android.support:support-annotations:22.+' } Simple test to put in src/a

Dart, content-shell and cygwin

Following my post on how to get pub working on cygwin , I wanted to use content-shell as well. Here it is a simple: Get content shell from  http://gsdview.appspot.com/dart-archive/channels/stable/release/latest/dartium/ , choose content_shell-ia32-release.zip Uncompress and add the resulting folder to you global PATH variable $ pub run test -p content-shell works fine in cygwin

Dart, Pub and Cygwin

While I do most of my development on linux, I need to perform some testing on Windows where the result are sometimes different for io applications. To share some scripts between windows and linux, I tend to use bash scripts, which means using cygwin on Windows, however the current dart sdk (1.11.1 as of now) does not play well with cygwin. I used the the new chocolatey tool to install dart and dartium on windows ( https://www.dartlang.org/downloads/windows.html ) where they ended up in c:\tools $ dart --version Dart VM version: 1.11.0 (Wed Jun 24 06:44:48 2015) on "windows_x64" $ pub sh.exe": pub: command not found Ouch! It seems that due to  https://github.com/dart-lang/pub/issues/1120 , pub is not supported on cygwin. A simple script named pub solved the issue (added to my global path) #!/bin/bash SNAPSHOT="/c/tools/dart-sdk/bin/snapshots/pub.dart.snapshot" dart "$SNAPSHOT" "$@" I can now run pub run test without issues.

Eclipse Mars 4.5 on MacOS - JVM issue

after installing eclipse 4.5 on MacOS Yosemite, I was always getting the following alert The JVM shared library "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/../lib/server/libjvm.dylib" does not contain the JNI_CreateJavaVM symbol. it seems the -vm parameters is skipped from the eclipse.ini file so the only way I found to launch eclipse was using the following command line /opt/apps/eclipse-4.5/Eclipse.app/Contents/MacOS/eclipse -vm /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java (assuming Eclipse is installed in  /opt/apps/eclipse-4.5/ and Java 8 (1.8.0.45) is installed)

Java 8 on Yosemite

After installing Java 8 on Yosemite, I was still stuck with Java 6 from Apple website. The solution was to do the following $ sudo rm /usr/bin $ sudo ln -s /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java /usr/bin/java

Search form for wordpress boostrap based theme

As I create a boostrap based theme for bootstrap despite  why-bootstrap-is-a-bad-fit-for-wordpress-themes , I wanted to have a search form that fits well. creating-bootstrap-wordpress-theme-search , and enhanced for Boostrap 3.2, here is my searchform.php <?php $search_terms = htmlspecialchars( $_GET["s"] ); ?> <form role="form" action="<?php bloginfo('siteurl'); ?>/" id="searchform" method="get"> <label for="s" class="sr-only">Search</label> <div class="input-group"> <input type="text" class="form-control" id="s" name="s" placeholder="Search" <?php if ( $search_terms !== '' ) { echo ' value="' . $search_terms . '"'; } ?> /> <span class="input-group-btn"> <button type="submit" class="btn btn-primary&qu

Installing ios-sim for Cordova

$ sudo npm install -g ios-sim always gave me the following message: shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied. Solution was to add  --unsafe-perm $ sudo npm install -g --unsafe-perm  ios-sim

Using dart test_runner on Ubuntu

Not being able to easily run my browser test is a pain so I tried to give a shot to the new test_runner package from Nicolas Garnier. However having content_shell setup is not a done deal so thanks to http://japhr.blogspot.fr/2014/09/dart-content-shell-on-debian.html  I was able to set it up conveniently Download content shell and add it to the path cd $DART_TOP/chromium ./download_contentshell.sh unzip content_shell-linux-x64-release.zip CONTENT_SHELL_PATH=$(ls -d drt-*) PATH=$PATH:$CONTENT_SHELL_PATH install the missing package (fonts) sudo apt-get install wdiff ttf-indic-fonts ttf-mscorefonts-installer ttf-dejavu-core ttf-kochi-gothic ttf-kochi-mincho Make sure you have everything in your path (pub, dart2js, ~/.pub-cache/bin) and run_tests can be ran on any project. I had to rename some files to have the expected conventions.