Skip to content

Instantly share code, notes, and snippets.

View Sylvance's full-sized avatar
:octocat:
Shipping it 🚀

omusamurai Sylvance

:octocat:
Shipping it 🚀
  • Nairobi
View GitHub Profile
var removeByAttr = function(arr, attr, value){
var i = arr.length;
while(i--){
if( arr[i]
&& arr[i].hasOwnProperty(attr)
&& (arguments.length > 2 && arr[i][attr] === value ) ){
arr.splice(i,1);
}
var contains = function(needle) {
// Per spec, the way to identify NaN is that it is not equal to itself
var findNaN = needle !== needle;
var indexOf;
if(!findNaN && typeof Array.prototype.indexOf === 'function') {
indexOf = Array.prototype.indexOf;
} else {
indexOf = function(needle) {
var i = -1, index = -1;
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi", "Lemon", "Pineapple");
console.log(fruits);
fruits.unshift("Guava");
console.log(fruits);
delete fruits[0];
console.log(fruits);
fruits.splice(1,1);
@Sylvance
Sylvance / index.html
Created August 28, 2016 07:55
ZOgarR
<html ng-app="gemStore">
<head>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link crossorigin="anonymous" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity=
"sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.js" type="text/javascript">
</script>
<script crossorigin="anonymous" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" src="https://code.jquery.com/jquery-3.1.0.min.js">
</script>
@Sylvance
Sylvance / index.html
Created September 1, 2016 13:02
ORJrwm
<div class="app_con">
<div class="app_base">
<div class="app_top">
<div class="top_con">
<div class="top_base">
<nav class="navbar navbar-white navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle collapsed" type="button">
<!-- data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"--><span class="sr-only">Toggle
@Sylvance
Sylvance / cmd.sh
Last active February 26, 2018 09:14
A shell script that creates directories, moves to a different directories, copies files, lists directory contents, executes commands with parameters, pipes and redirects input #796
// make new directory to create directory
$ mkdir new_directory
// change directory to create directory
$ cd new_directory
// create a new file
$ touch cmd.txt
// create child_directory
@Sylvance
Sylvance / variable.sh
Created March 16, 2018 09:41
A program showing assignment and use of variables
Python 2.7.10 (default, Jul 15 2017, 17:16:57)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> changing = 1
>>> print(changing)
1
>>> changing = 15
>>> print(changing)
15
>>> variable=3
@Sylvance
Sylvance / app1.py
Last active September 7, 2018 15:11
from flask import Flask
from flask_restful import reqparse, abort, Api, Resource
app = Flask(__name__)
api = Api(app)
TODOS = {
'todo1': {'description': 'Build a REST API'},
'todo2': {'description': 'Connect to database'},
'todo3': {'description': 'Host documentation on Heroku'},
from flask import Flask
from flask_restplus import Api, Resource, fields
from werkzeug.contrib.fixers import ProxyFix
app = Flask(__name__)
app.wsgi_app = ProxyFix(app.wsgi_app)
api = Api(app, version='1.0', title='Todo API',
description='A simple Todo API',
)
@Sylvance
Sylvance / mpesa.json
Last active October 6, 2018 08:48
Safaricom MPESA Sandbox working payloads
// registerurl
/*
Request POST /mpesa/c2b/v1/registerurl HTTP/1.1
*/
{
"ShortCode": "600482",
"ResponseType": "Completed the Mwavuli Transaction",
"ConfirmationURL": "https://urlhitter.herokuapp.com/api/v1/callbacks",
"ValidationURL": "https://urlhitter.herokuapp.com/api/v1/callbacks"