Github API

Tags

Github API
complete reference: https://developer.github.com/enterprise/2.4/v3/

============================
Possible Triggers
============================
Any new issue
-triggers everytime any new issue is opened in a repository you own/collaborate on.
opt_type=ISSUES

Any closed issue
-triggers everytime any issue is closed in a repo you own/collaborate on.

New issue assigned to you
-triggers everytime a new issue is assigned to you.

New repository by a specific username or organization
-triggers everytime a new repository is created by the username or organization you specify.

Any new gist
-triggers everytime new snippets is created/updated

Any published release event
-triggers when a release is published.

Any pull request event
-triggers when a pull request is assigned, unassigned, labeled, unlabeled, opened, closed, reopened, or synchronized.
opt_type=PULL_REQUEST

Any push event
-triggers everytime a repo branch is pushed to.
opt_type=PUSH

Starred a repository
-triggers everytime a user stars a repo.
opt_type=WATCH

============================
Possible Actions
============================
Issues
* Create/Read/Update an issue
Any user with pull access to a repository can create an issue.

Repositories
* Create/Read/Update/Delete a repository
Create a new repository for the authenticated user.

* Create/Read/Update/Delete a release
Users with push access to the repository can create a release.

* Create/Read/Update/Delete a commit comment
* Create/Read/Update/Delete a file
This method creates a new file in a repository

* Create a fork
Create a fork for the authenticated user.

Git Data
* Create a blob
Supported encoding: “utf-8” and “base64”. Default: “utf-8”.
* Create a commit
* Create a Tag Object

Gist
* Create/Read/Update/Delete a gist
* Star/Unstar a gist

Organization
* Create/Read/Update/Delete a team
In order to create a team, the authenticated user must be a member of :org

* Add/Remove team member
In order to add a user to a team, the authenticated user must have‘admin’ permissions to the team or be an owner of the organization that the team is associated with,
and the user being added must already be a member of atleast one other team on the same organization.

* Add/Remove team repository
In order to add a repository to a team, the authenticated user must be anowner of the org that the team is associated with.
Also, the repository mustbe owned by the organization, or a direct fork of a repository owned by theorganization.

Pull Request
* Create/Read/Update a pull request

CREATE monitoring
curl -X POST http://localhost:3010/api/monitor/ \
-H “Content-Type: application/json” \
-d ‘{ “recipeId” : “7af2ecfdee0909096564a36af31c55e9”, “token”: “0e98ec3cb08ba332a2ec9aaf16813ece46fe8fcf”, “repo”: “test”, “owner”: “ortegaaa”, “event”: “watch” }’

DELETE monitoring
curl -X DELETE http://localhost:3010/api/monitor/ \
-H “Content-Type: application/json” \
-d ‘{ “token”: “0e98ec3cb08ba332a2ec9aaf16813ece46fe8fcf”, “webhookUrl”: “https://github.com/api/v3/repos/ortegaaa/test/hooks/102205” }’

How to deploy Node.js app using IBM Bluemix DevOps

Tags

How to deploy Node.js apps using IBM Bluemix DevOps
1. Create Cloud Foundry App -> Select Cloud Foundry Apps -> Select SDK for Node.js
2. Once the app was successfully created look for the Git repo and checkout it to your local machine.
3. To check the Git repo go to https://git.ng.bluemix.net/dashboard/projects
4. Checkout the source code and modified it. The source code contains a minimal boilerplate Node.js code.
5. Test it locally and once it works in your local then it is good to push to master branch.
6. On executing the git push command, the Bluemix will auto-deploy your app.

How to check the progress of your Build
1. Go to Services menu -> Click DevOps menu
2. Go to Pipelines -> then select the pipeline that you want to see. That’s it!

Docker common problems and its solution

Tags

Problem: When running any docker command, the error below is printed

$ docker version

Client:
Version: 1.12.0-rc3
API version: 1.24
Go version: go1.6.2
Git commit: 91e29e8
Built: Sat Jul 2 00:17:11 2016
OS/Arch: windows/amd64
An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/version: open //./pipe/docker_engine: The system cannot find the file specified.

$ docker ps -a

An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json?all=1: open //./pipe/docker_engine: The system cannot find the file specified.

Solution:
We need to configure the shell to be able to execute docker commands.

webdev@localhost ~
$ docker-machine env

export DOCKER_TLS_VERIFY=”1″
export DOCKER_HOST=”tcp://192.168.99.100:2376″
export DOCKER_CERT_PATH=”C:\Users\webdev\.docker\machine\machines\default”
export DOCKER_MACHINE_NAME=”default”
# Run this command to configure your shell:
# eval $(“C:\Program Files\Docker Toolbox\docker-machine.exe” env)
For cmd, use this command:

eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env)

For cygwin, use this command:

$ eval $("C:/Program Files/Docker Toolbox/docker-machine.exe" env default)

For set permanent variable easily:
1.Right-click on the Windows Button
2.Select System, from the menu.
3.From there, select “Advanced system settings” → “Environment Variables”
4.Under the System Variables section, add all variables displayed when you ran the command: docker-machine env

Mysql basic commands

Tags

, ,

mysql> show variables like ‘port’;
+—————+——-+
| Variable_name | Value |
+—————+——-+
| port | 3306 |
+—————+——-+
1 row in set (0.00 sec)

mysql> show variables like ‘socket’;
+—————+—————–+
| Variable_name | Value |
+—————+—————–+
| socket | /tmp/mysql.sock |
+—————+—————–+
1 row in set (0.00 sec)

mysql> show variables like ‘hostname’;
+—————+————-+
| Variable_name | Value |
+—————+————-+
| hostname | myhostname |
+—————+————-+
1 row in set (0.00 sec)

How to connect to ClearDB and import your local sql schema.
$ mysql -h us-cdbr-sl-dfw-01.cleardb.net -u abcdefghijkl -D remotedbname -p < C:\Apache24\htdocs\myWebApp\schema.sql

Rails common problems and its solutions

Tags

Problem:
Gem Load Error is: Could not find a JavaScript runtime.

$ rails console
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.1/lib/bundler/runtime.rb:85:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
Backtrace for gem load error is:
/usr/local/bundle/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect'
/usr/local/bundle/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'
/usr/local/bundle/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (required)>'
/usr/local/bundle/gems/uglifier-3.2.0/lib/uglifier.rb:5:in `require'
/usr/local/bundle/gems/uglifier-3.2.0/lib/uglifier.rb:5:in `<top (required)>'

Solution A:
Edit the Gemfile and add/uncomment the line:
gem ‘therubyracer’, platforms: :ruby
Solution B:
sudo apt-get install nodejs

Docker: Basic Docker tutorial

Tags

Lets assume that you’ve created or downloaded some docker images. But in this tutorial, we are going to use the ubuntu-xenial image.

$ docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
ubuntu-xenial               latest              1d4b614305f6        23 minutes ago      859.8 MB
friendlyhello               latest              bf391a773695        18 hours ago        194.6 MB
python                      2.7-slim            1c7128a655f6        2 weeks ago         182.8 MB
mysql                       5.5                 c0fb485deb70        5 weeks ago         256 MB
truthadjustr/myng2          latest              f76b7a86e3b1        6 weeks ago         852.4 MB
hello-world                 latest              48b5124b2768        4 months ago        1.84 kB
ibmcom/cloudant-developer   latest              fb798da3ab5d        11 months ago       1.162 GB

Next, lets see if there are running container.

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES

We can see that there are no active running container. Let’s display all containers by running the command docker ps -a

## List all running/stopped containers
$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
871e7dfd063c        ubuntu-xenial       "bash"              46 seconds ago      Exited (0) 6 seconds ago                       vigorous_johnson

Yay! there is one existing container available. Let’s use it.
But if ever there is no container found then we need to run the command docker run -it ubuntu-xenial bash first!

Moving forward, lets rename the existing container name.

## Rename from vigorous_johnson to ubuntu_xenial
$ docker rename 871e ubuntu_xenial

So renaming is done let’s verify it. It should be ubuntu_xenial now.

$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
871e7dfd063c        ubuntu-xenial       "bash"              46 seconds ago      Exited (0) 6 seconds ago                       ubuntu_xenial

Next, we can see that the container(ubuntu_xenial) was exited then lets start it..

$ docker start ubuntu_xenial
ubuntu_xenial

$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
871e7dfd063c        ubuntu-xenial       "bash"              46 seconds ago      Up to 5 seconds                                ubuntu_xenial

So the container ubuntu_xenial is started..lets execute it.

$ docker exec -it ubuntu_xenial bash

TAKE NOTE: if we run the image again it will create another container.

$ docker run -it ubuntu-xenial bash
## After running docker run run there are
## now two containers created from image ubuntu-xenial.
$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
6409eda3b5d6        ubuntu-xenial       "bash"              20 minutes ago      Exited (0) 8 minutes ago                       agitated_shannon
871e7dfd063c        ubuntu-xenial       "bash"              22 minutes ago      Up 20 minutes                                  ubuntu_xenial

So, it is recommended to just re-use one container otherwise there is a reason to do it.

Apache: Bad Request: Your browser sent a request that this server could not understand.

Tags

If you’ve encountered an error that says: Bad Request: Your browser sent a request that this server could not understand.
Size of a request header field exceeds server limit.

Solution:
Edit the httpd.conf, then add the line LimitRequestFieldSize {bytes}.
$ vi /etc/httpd/conf/httpd.conf

ServerRoot “/etc/httpd”
LimitRequestFieldSize 16384


Then restart the server…
$ sudo /etc/init.d/httpd restart