shohey1226-blog
shohey1226-blog
Debuginfo
10 posts
A weblog about technology, management, marketing, and records to be professional CTO
Don't wanna be here? Send us removal request.
shohey1226-blog · 10 years ago
Text
Move the blog to Wiredify.com
I'm building a blogging platform, called Wiredify(http://wiredify.com). I haven't udpate much on this tumblr but I will update frequently on Wiredify. See my page - http://wiredify.com/shohey1226/logs
0 notes
shohey1226-blog · 11 years ago
Text
Turn-around of (#1500) fbcdn.net urls are not allowed.
When I tried to publish instagram photo by Facebook Open Graph, I see the below error.
(#1500) fbcdn.net urls are not allowed.
It seems instagram photo is now under facebook cdn after facebook bought instagram.. And due to some restriction in facebook, the pic won't be published saying the error msg.
I resoved this with having nginx.. I brought up nginx and set rewrite, like below.
server { listen 80; server_name dev.myhost.com; location /instagram/ { rewrite ^/instagram/(.*)/(.*) http://$1.fbcdn.net/$2 break; } }
and then, I changed the uri in my app code.
if ($row->cover_image =~ /http:\/\/(\S+).fbcdn.net\/(\S+)/ ){ $image_url = "http://dev.myhost.com/instagram/$1/$2"; }
This works fine. I know this may not good solution but it can handle the issue.
0 notes
shohey1226-blog · 11 years ago
Text
Ansible playbook to install system wide Perl and its module using cpanm with cpanfile
On the other day, I posted How to install system wide perl5.18 on CentOS6.5 and I wrote an Ansible playbook to do this.
Here is the codes:
main.yml which has 2 shell scripts
Install System Perl on /opt/perl5 with plenv
Install Perl modules using cpanm with cpanfile
cpanfile
0 notes
shohey1226-blog · 11 years ago
Text
How to install system wide perl5.18 on CentOS6.5
Perl version on CentOS is 5.10 by default. It’s a bit old, so most of the perl developers install the latest perl on his home directory by perlbrew or plenv. This time, for a program to be executed by Jenkins, I wanted to install system wide perl on the Jenkins server.
The below is example to install system wide perl using “plenv” which is very popular in Japan. (See the benefit of plenv over perlbrew - http://weblog.bulknews.net/post/58079418600/plenv-alternative-for-perlbrew)
$ export PLENV_ROOT=/opt/perl5 # wherever you want to install $ mkdir -p /opt/perl5 $ git clone git://github.com/tokuhirom/plenv.git $PLENV_ROOT $ git clone git://github.com/tokuhirom/Perl-Build.git $PLENV_ROOT/plugins/perl-build/ $ $PLENV_ROOT/bin/plenv install 5.18.2 $ $PLENV_ROOT/bin/plenv rehash $ $PLENV_ROOT/bin/plenv global 5.18.2 $ $PLENV_ROOT/bin/plenv install-cpanm $ $PLENV_ROOT/bin/plenv rehash
And you can call the below in your ~/.bash_profile or the shell script to run the program.
export PLENV_ROOT=/opt/perl5 export PATH="$PLENV_ROOT/bin:$PATH" eval "$(plenv init -)"
0 notes
shohey1226-blog · 11 years ago
Text
Perl script, doman.pl (DigitalOcean MANipulator), to handle DigitalOcean
Tumblr media
I tried to find the script on the web but I couldn't find.. therefore, I just wrote it.. (it just uses DigitalOcean )
This script doesn't cover all functions but I belive it's not difficult to add when you check the cpan document of DigitalOcean module.. (I just implemented the functions that I wanted :) )
Usage
Set env varialble, client ID and API key, in your shell. (or you can specify in the argument -client_id and -api_key)
$ export DIGITALOCEAN_CLIENT_ID=xxxx $ export DIGITALOCEAN_API_KEY=yyyy
show droplet that you have
$ doman.pl --show_droplet
show images that you have
$ doman.pl --show_my_image
show size ids and region
$ doman.pl --show_size $ doman.pl --show_region
create droplet. -ssh_key_ids is optional
$ doman.pl --create_droplet -size_id 66 -region_id 6 -image_id 111 -droplet_name mydroplet1 -ssh_key_ids 12345
destroy droplet and image
$ doman.pl --destroy_droplet -droplet_id 11111 $ doman.pl --destroy_image -image_id 2474933
Code
0 notes
shohey1226-blog · 11 years ago
Text
Ansible playbook to add user using public ssh key on Github
Tumblr media
I looked for a way to put ~/.ssh/authorized_keys using Packer. Because Packer utilizes ansible-local, we can't just copy the authorization key from the host that ansible-playbook is executed on. I was web surfing and found that Github puts my public ssh key on public.. In my case, here - https://github.com/shohey1226.keys
http://thechangelog.com/github-exposes-public-ssh-keys-for-its-users/
I thought this can be used to add user with ssh key and write down the following ansible playbook.
I used delegate_to to work on both ansible local and nomal ansible. Now you don't worry about how you manage ssh pub keys :) ,, except Github is down :p
0 notes
shohey1226-blog · 11 years ago
Text
Mojolicious + AngularJS + Yeoman = Mojangman?
I wanted to have Perl web framework, Mojolicious, as backend to provide API and AngularJS as frontend. One problem that I faced with is that I'm not sure how to deploy angularjs/dist directory with backend. In the Yeoman document, it said git subtree can be used but I thought it adds complexity to the repo.
I was surfing on the web and found the below blog post which describes Rails + AngularJS + Yeoman.
Angular + Rails + Yeoman = Angrailman?
I like this title, therefore, my blog post's title is similar one. (I put Mojo first, because I like it :) )
The things that we need to do is very simple, create angular directory under Mojolicious root and extract angular components by 'yo angular' and then, map the original dist/ directory to ../public which Mojolicious's default static file location. Le'ts look at it, one bye one.
$ mkdir Mojangman $ cd Mojangman $ mojo generate app Mojangman $ mv mojangman/* . $ rmdir mojangman $ mkdir angular $ cd angular $ yo angular
and you see the tree, like below.
├── angular │   ├── Gruntfile.js │   ├── app │   ├── bower.json │   ├── karma-e2e.conf.js │   ├── karma.conf.js │   ├── node_modules │   ├── package.json │   └── test ├── lib │   ├── Mojangman │   └── Mojangman.pm ├── log ├── mojangman ├── public │   └── index.html ├── script │   └── mojangman ├── t │   └── basic.t └── templates ├── example └── layouts
Le's edit Guntfile.js to replace "dit" with "../public",
$ vi Gruntfile.js # change the below entry grunt.initConfig({ yeoman: { app: require('./bower.json').appPath || 'app', dist: '../public' // Change from dist to ../public },
'grunt build' creates the static files under public directory.
$ grunt build # under angular directory $ cd .. $ tree -L 1 public public ├── 404.html ├── bower_components ├── favicon.ico ├── fonts ├── images ├── index.html ├── robots.txt ├── scripts ├── styles └── views
Modify Mojlicious modules so that root(/) access points to the public directory.
Mojangman.pm
package Mojangman; use Mojo::Base 'Mojolicious'; # This method will run once at server start sub startup { my $self = shift; # Documentation browser under "/perldoc" $self->plugin('PODRenderer'); # Router my $r = $self->routes; $r->route('/')->to('example#serve_root'); }
Mojangman/Example.pm
package Mojangman::Example; use Mojo::Base 'Mojolicious::Controller'; sub serve_root { my $self = shift; # will render the index.html file found in the /public directory $self->render_static('/index.html'); }
At last, bring up mojo process and it's done.(or it's just the begining :p )
$ script/mojangman daemon Server available at http://127.0.0.1:3000.
The codes in my repot: https://github.com/shohey1226/Mojangman
2 notes · View notes
shohey1226-blog · 11 years ago
Text
Use github push to initiate Jenkins job
What I wanted to do is to git push on github and hook'ed this event to run Jenkins,,
http://blog.cloudbees.com/2012/01/better-integration-between-jenkins-and.html
All procedure is written in the above link except that authentication failure, which shows "Failed to validate the account" when put ID/Pass..
How to fix is as following:-
Create the token in Github's Account Setting -> Application -> Personal access tokens -> Generate New token
Put the token in Jenkins -> GitHub Credentials
Tumblr media
0 notes
shohey1226-blog · 11 years ago
Text
Ansible Jenkins playbook
Quickly wrote the recipe to install Jenkins with Ansible :)
0 notes
shohey1226-blog · 11 years ago
Text
How to add profile on Tumblr Theme
I wanted to add my profile under the title of my blog in tumblr. This is very simple, go to customization page and edit html, and then create html, like below.
Note that I use AddThis service for the pretty buttons :)
0 notes