Skip to content

Instantly share code, notes, and snippets.

View robophil's full-sized avatar
🍷
Working from home

Balogun Oghenerobo Philip robophil

🍷
Working from home
View GitHub Profile
@robophil
robophil / compute_change.js
Created February 7, 2017 15:14 — forked from KodjoSuprem/compute_change.js
coin change problem / Knapsack problem
var coinTypes = [25, 10, 5];     
var coinNb = [8, 12, 20]; 
function computeChange(change,coinTypes, coinNb) {   
var rez = [];   
for (var i = 0; i < coinTypes.length; ++i) {       
if (coinTypes[i] === 0) continue;       
var coinsToGet = Math.floor(change / coinTypes[i]);       
if (coinsToGet > coinNb[i]) {           
coinsToGet = coinNb[i];       
}       
@robophil
robophil / states.html
Created February 7, 2017 19:01
All the states in nigeria
<select class="form-control" id="" name="state">
<option value="Abia State">Abia State</option>
<option value="Adamawa State">Adamawa State</option>
<option value="Anambra State">Anambra State</option>
<option value="Akwa Ibom State">Akwa Ibom State</option>
<option value="Bauchi State">Bauchi State</option>
<option value="Bayelsa State">Bayelsa State</option>
<option value="Benue State">Benue State</option>
<option value="Borno State">Borno State</option>
<option value="Cross River State">Cross River State</option>
@robophil
robophil / vanish-config.sh
Created February 14, 2017 10:23
How to get vanish to work on port 80
sudo vi /lib/systemd/system/varnish.service
sudo systemctl daemon-reload
sudo service varnish restart
# The link below would be helpful
# https://www.digitalocean.com/community/questions/configure-varnish-with-apache-on-ubuntu-14-04
@robophil
robophil / .htaccess
Created March 7, 2017 14:45
Getting angular2 to play well with apache
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# not rewrite css, js and images
RewriteCond %{REQUEST_URI} !\.(?:css|js|map|jpe?g|gif|png)$ [NC]
RewriteRule ^(.*)$ /index.html?path=$1 [NC,L,QSA]
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Response } from '@angular/http';
import * as localForage from "localforage"
import { HttpService } from '../../http.service';
@Component({
selector: 'app-register',
<app-header></app-header>
<div id="page-content" class="header-static">
<div id="flexslider" class="fullpage-wrap small">
<ul class="slides">
<li style="background-image:url(assets/img/dollar.jpg)">
<div class="text">
<h3 class="">Welcome to Jaranaira.com</h3>
<h3 class="grey-light">Create an account <br>below</h3>
<div class="row">
<div class="col-md-3 col-xs-0"></div>
@robophil
robophil / AndroidManifest.xml
Last active April 7, 2017 12:58
Sample <activity> tag to handle deep linking for payporte.com mobile app. See https://developer.android.com/training/app-indexing/deep-linking.html
<activity
android:name="com.payporte.mobile.ProductActivity"
android:label="@string/category_title" >
<intent-filter android:label="@string/filter_title_product">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "http://www.payporte.com/category” -->
<data android:scheme="http"
android:host="www.payporte.com"
package com.payporte.mobile.activity;
import android.os.Bundle;
public class ProductActivity extends AppCompatActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.product);
@robophil
robophil / a.js
Created April 7, 2017 16:18
laju
Account.find({help:'ph'}).then(data=>data.forEach(account=>{Promise.all([ProvideHelp.findOne({account:account.id}),GetHelp.findOne({account:account.id})]).then(data=>{var ph=data[0],gh=data[1];if(!ph&&!gh){ProvideHelp.create({account:account.id,level:account.level}).then(d=>console.log(d))}})}));
@robophil
robophil / env-examples.md
Created April 20, 2017 14:46 — forked from ericelliott/env-examples.md
env-examples

Most configuration really isn't about the app -- it's about where the app runs, what keys it needs to communicate with third party API's, the db password and username, etc... They're just deployment details -- and there are lots of tools to help manage environment variables -- not the least handy being a simple .env file with all your settings. Simply source the appropriate env before you launch the app in the given env (you could make it part of a launch script, for instance).

env files look like this:

SOMEVAR="somevalue"
ANOTHERVAR="anothervalue"

To source it:

$ source dev.env # or staging.env, or production.env, depending on where you're deploying to