Skip to content

Instantly share code, notes, and snippets.

View kwekuboateng's full-sized avatar

Frederick Ampomah Boateng kwekuboateng

View GitHub Profile
# 1. Check if a numbers is prime
def midpoint(a,b)
(a + b)/2.0
end
def shrtcut(low,high,x)
guess = midpoint(low,high)
e_cmp = (guess * guess) - x
[guess,e_cmp]
end
def suggest_playlist(track,time):
count = len(track)
for i in range(count):
for j in range(1, count-i):
if track[j-1][1]>track[j][1]:
(track[j-1],track[j])=(track[j],track[j-1])
sum = 0
def Subsets(sets):
x = [[]]
for i in sets:
for j in x:
x = x + [j + [i]]
return x
a = [1,2,5,6]
print(Subsets(a))
def sorting_nums(item):
item = sorted(item)
len_item = len(item)
middle = len_item // 2
new_item = []
for i in range(middle):
new_item.append(item[i])
new_item.append(item[-1-i])
if len_item % 2 == 1:
@kwekuboateng
kwekuboateng / onAddRow
Created July 22, 2017 21:03
onAddRow error
TypeError: Cannot read property 'props' of undefined
onAddRow
src/Components/Dashboard/ManageProduct.js:84
81 | }
82 |
83 | onAddRow(row){
> 84 | this.props.addNewProduct(row)
85 | }
86 |
87 | createCustomInsertButton = (onClick) => {
import React, { Component } from 'react';
import './../../App.css';
// import afterSearch from './ManageProduct';
import { Table, Button, Modal, ModalHeader,
ModalBody, ModalFooter, Form,
FormGroup, Label, Input, Col, Collapse,
CardBlock, Card } from 'reactstrap';
import { Link } from 'react-router-dom';
import axios from 'axios';
import * as actionType from './actionTypes/orderActionTypes';
import setAuthorizationToken from '../Utils/setAuthorizationToken';
import localforage from 'localforage';
axios.defaults.baseURL = `https://api.aidahbot.com`;
/**
* PLAIN JAVASCRIPT ACTIONS
*/
import * as actionType from './../Actions/actionTypes/orderActionTypes';
import _ from 'lodash';
const INITIAL_STATE = {
orders: [],
orderIsLoading: false,
orderFetchSuccess: false,
orderStatusChange: false
};
import React, { Component } from 'react';
import './../../App.css';
// import afterSearch from './ManageProduct';
import { Table, Button, Modal, ModalHeader,
ModalBody, ModalFooter, Form,
FormGroup, Label, Input, Col, Collapse,
CardBlock, Card } from 'reactstrap';
import { Link } from 'react-router-dom';
data-order_items =
"[{
"product_id" = "23456782cc823726323",
"product_name" = "Straight Hair",
"order_qty" = "4",
"order_price" = "450",
"_id":"655273839cc3883s33"
}]"