Skip to content

Instantly share code, notes, and snippets.

View rajikaimal's full-sized avatar

Rajika Imal rajikaimal

View GitHub Profile
@rajikaimal
rajikaimal / nodecloud-aws-compute.js
Last active July 2, 2017 08:10
NodeCloud compute sample
const nodeCloud = require('../nodecloud/lib/');
const ncAWS = nodeCloud.getProvider('AWS', process.env.ncconf);
const options = {
apiVersion: '2016-11-15',
};
const params = {
ImageId: 'ami-10fd7020',
InstanceType: 't1.micro',
MinCount: 1,
MaxCount: 1,
@rajikaimal
rajikaimal / style_guide.md
Created April 29, 2017 14:11 — forked from dominictarr/style_guide.md
style guide

High level style in javascript.

Opinions are like assholes, every one has got one.

This one is mine.

Punctuation: who cares?

Punctuation is a bikeshed. Put your semicolons, whitespace, and commas where you like them.

@rajikaimal
rajikaimal / nginxproxy.md
Created April 16, 2017 14:44 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@rajikaimal
rajikaimal / index.test.js
Created January 14, 2017 11:46
Unit tests for github-followers
const assert = require('chai').assert;
const ghFollowers = require('../index');
describe('github-followers', function() {
it('should return an array of objects', function(done) {
ghFollowers('rajikaimal')
.then(res => {
assert.typeOf(res, 'array');
done();
})
@rajikaimal
rajikaimal / index.js
Last active December 8, 2023 12:56
Entry point for github-followers
const httpFetcher = require('http-fetcher');
const ghURI = '/users/:username/followers';
module.exports = function(username) {
const URI = ghURI.replace(':username', username);
return httpFetcher('api.github.com', URI, { 'User-Agent': 'github-followers' }, 'https');
}
@rajikaimal
rajikaimal / laravel-blogController.php
Created December 25, 2015 16:30
Laravel controller
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Tweet;
@rajikaimal
rajikaimal / laravel-blog.html
Last active December 25, 2015 17:09
React app for React-Laravel
<!DOCTYPE html>
<html>
<head>
<title>Laravel-React</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/babel" src="js/main.js"></script>
</head>
@rajikaimal
rajikaimal / laravel-routes.php
Last active August 25, 2017 02:56
Laravel routes
//add extra extension to render pure html alongside with php
View::addExtension('html', 'php');
Route::get('/blog', function() {
return view('Blog');
});
//route for inserting
Route::post('/tweets/create', 'BlogController@create');
//route for deleting
Route::post('/tweets/delete', 'BlogController@delete');
@rajikaimal
rajikaimal / mutation-graphql.txt
Created December 19, 2015 16:32
Mutation in GraphQL
mutation {
AddUser (
_id: 2,
name: "Taeyeon",
age: 26
) {
_id,
name
}
}
@rajikaimal
rajikaimal / directives-graphql.txt
Last active December 19, 2015 16:07
Directives in GraphQL
query ExampleQuery(presents: Boolean) {
ExampleRootQueryField {
...ConditionalFragment @include(if: presents)
}
}
fragment ConditionalFragment on ExampleType {
_id,
firstname,
speciality