Skip to content

Instantly share code, notes, and snippets.

View MichaelObi's full-sized avatar
🏠
Working from home

Michael Obi MichaelObi

🏠
Working from home
View GitHub Profile
const fetchBill = () => {
const api = "https://randomapi.com/api/006b08a801d82d0c9824dcfdfdfa3b3c"
fetch(api).then((response) => {
if (reponse.status !== 200) {
console.log("Error" + response.status)
return;
}
return response.json()
}).then((data) => {
mCameraSource.takePicture(null, new CameraSource.PictureCallback() {
@Override
public void onPictureTaken(byte[] bytes) {
try {
File basePath = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath());
if (!basePath.exists()) {
Log.d("CAPTURE_BASE_PATH", basePath.mkdirs() ? "Success" : "Failed");
}
File captureFile = new File(basePath + File.separator + "vstyle_photo_" + (new Date().getTime()) + ".jpg");
public class FileUtils
{
/// <summary>
/// Saves file into a local directory and returns the path + file name as string
/// </summary>
/// <param name="file">File</param>
/// <param name="filePath"></param>
/// <param name="fileName"></param>
/// <param name="saveLocal"></param>
/// <returns></returns>
@MichaelObi
MichaelObi / CameraActivity.java
Last active April 23, 2017 19:05
Save photo from a Camera source to a file
public void takePhoto() {
mCameraSource.takePicture(null, new CameraSource.PictureCallback() {
@Override
public void onPictureTaken(byte[] bytes) {
try {
File basePath = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "vstyle");
if (!basePath.exists()) {
Log.d("CAPTURE_BASE_PATH", basePath.mkdirs() ? "Success": "Failed");
}
File captureFile = new File(basePath + "photo_" + (new Date().getTime()) + ".jpg");
package com.example.components;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.text.Html;
import android.view.View;
@MichaelObi
MichaelObi / signup.php
Created August 17, 2013 13:30
controller for signup. Gcm tutorial -CodeIndulge
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*****************************************************************************************************************
* Signup details are recieved and sent to users_model from here.
* Signup results are recieved and actions are triggered from this controller.
* Validation status codes: when success = 1, Signup succeeds
*****************************************************************************************************************/
class Signup extends CI_Controller {
public function auth()
{
$data = $this->input->post();
@MichaelObi
MichaelObi / Users_model.php
Last active December 21, 2015 05:28
Shows the signup function in users model to insert user data into database - CodeIndulge tutorial.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/* implements signup and login of users */
class Users_model extends CI_Model {
//To implement user signup
public function signup_user($data){
$signup['email'] = trim(mysql_real_escape_string($data['email']));
$signup['fname'] = trim(mysql_real_escape_string($data['fname']));
$signup['lname'] = trim(mysql_real_escape_string($data['lname']));
$signup['phone'] = trim(mysql_real_escape_string($data['phone']));
$signup['password'] = md5($data['password']);
@MichaelObi
MichaelObi / users.sql
Last active December 21, 2015 05:28
Code to create table for users in GCM tutorial - CodeIndulge
CREATE TABLE IF NOT EXISTS `users` (
`user_id` int(5) NOT NULL AUTO_INCREMENT,
`gcm_id` text NOT NULL,
`email` varchar(40) NOT NULL,
`phone` varchar(15) NOT NULL,
`password` varchar(40) NOT NULL,
`fname` varchar(20) NOT NULL,
`lname` varchar(20) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`user_id`),