Posts

Showing posts from July 4, 2018

spaces on mail body when we Open gmail app from iOS url schemes

spaces on mail body when we Open gmail app from iOS url schemes Is it possible to provide spaces or new line or line breaks on gmail compose on URL schemes. I tried both /n or stringByAddingPercentEscapesUsingEncoding , but space or lines breaks are not reflecting. /n stringByAddingPercentEscapesUsingEncoding googlegmail:///co?subject=subject&body= "nnn textfirstname" googlegmail:///co?subject=subject&body= "nnn textfirstname" Use HTML email body and a <a href="googlegmail:....">Whateverntextnyounwant</a> . – rmaddy Jun 30 at 19:33 <a href="googlegmail:....">Whateverntextnyounwant</a> 1 Answer 1 This is not an issue with iOS or url-scheme. You need to use html tag to set new line. F

Notification not sent by JobService

Notification not sent by JobService So I have a notification set up in my JobService.class and I know for sure that it works. The problem is that I don't think my JobService is ever getting called. I want my app to check the database every couple hours and if it matches certain criterias it will send a notification. I start my JobService like this in my MainActivity : JobService.class JobService JobService MainActivity ComponentName componentName = new ComponentName(MainActivity.this, JobService.class); JobInfo info = new JobInfo.Builder(6484, componentName) .setPeriodic(1000 * 60 * 15) .build(); JobScheduler scheduler = (JobScheduler) getSystemService(JOB_SCHEDULER_SERVICE); if (scheduler != null) { scheduler.schedule(info); } And this is my JobService since it's too long. I cut off the code for the notification parts because it's too long. JobService @Override public boolean onStartJob(JobParameters jobParameters) { {/

How to use ckeditor in php

How to use ckeditor in php I am building a CMS system and I found that I can not configure the ckeditor script on my text area, can anyone help me to solve the issue My code is below: header.php <?php ob_start(); // helps to buffer our project ?> <?php include "../includes/db.php"?> <?php include "functions.php"?> <?php ob_start(); ?> <?php session_start(); ?> <?php if (!isset($_SESSION['rl'])){ header("Location:../index.php"); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <title>SB Admin - Bootst

Cannot handle an error inside a promise

Cannot handle an error inside a promise I have this function that takes a path and fetches some information about it (using node.js capabilities) import fs from 'fs' import fse from 'fs-extra' import { join } from 'path' /** * Take in file path and return contents with stat * @param {String} path * @return {Array} */ export default path => { return readdir(path).then(files => { const statsPromises = files.map((file, i) => { const p = join(path, file) return stat(p).then(stat => ({ // THIS ONE LINE BELOW THROWS UN-HANDLED ERRORS FOR SOME PATHS // Error: EPERM: operation not permitted, scandir folderItemsCount: stat.isDirectory() ? fs.readdirSync(p).length : null, name: file, path: p, stat }) , err => console.log("Path access error ", err)) }) return Promise.all(statsPromises) }).then(contents => contents.filter(Boolean

Encoding base64 string to image in swift received from mysql

Encoding base64 string to image in swift received from mysql I am receiving a base64 string from mysql (stored as blob) and try to encode it like this: func loadImage() { var request = URLRequest(url: URL(string: URL_IMAGES)!) request.httpMethod = "POST" let userid = self.defaultValues.integer(forKey: "userid") let postString = "userid=(userid)" request.httpBody = postString.data(using: .utf8) let task = URLSession.shared.dataTask(with: request) { data, response, error in guard let data = data, error == nil else { print("error=(String(describing: error))") return } if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode != 200 { print("statusCode should be 200, but is (httpStatus.statusCode)") print("response = (String(describing: response))") } let responseString = String(data: data, encoding: .utf8)

Error of Averaging a Large Vector in MATLAB

Error of Averaging a Large Vector in MATLAB How do you accurately take the average of large sets of integers in MATLAB? I have two large vectors (2672x4008 in dimensions) I am dealing with, each the result of pixels in an image. Hence, the resulting vector is filled with values 0 to 256, all integers. My problem is that I want an accurate value of the average intensity of these grey-scale images. To do this, I used the line meanvalue = mean(I(:)) This yielded a value of meanvalue = 155.9335 in the output line of MATLAB. Next, I added 20 to each value of the vector, as below (this should raise the intensity of the overall image, if I am understanding correctly). Ipt = I + 20; I then took the mean value of this new vector, Ipt meanvaluept = mean(Ipt(:)) and matlab spat out a value of meanvaluept = 175.8916. I'm no math wizard, but I know enough to know that 175.8916 - 20 ≠ 155.9335. Any help would be appreciated, either mathematically (how to increase the precision of MATLAB), or pro

Is there an API endpoint available to access the new feed of “Info and Ads” publicly available for Pages [on hold]

Is there an API endpoint available to access the new feed of “Info and Ads” publicly available for Pages [on hold] Facebook just released a new public access to all the active Ads of any public pages (https://newsroom.fb.com/news/2018/06/transparency-for-ads-and-pages/), it would be interesting to have an API endpoint to read this info. Does anybody know if such an endpoint is already available or if there is a plan to provide one soon? Thanks This question appears to be off-topic. The users who voted to close gave this specific reason:

Improvement of performance for a maze solving program in Python

Image
Improvement of performance for a maze solving program in Python fellow programmers. I need help with one of my projects. I'm making a maze solving program. It reads an image file, which has to be black and white (black pixels are walls, white pixels are paths), have only one pixel at the top which is the entrance to the maze, and only one white pixel at the bottom which is the exit. There're three main parts to the code: 1) The program first create nodes in the maze, respecting a set of rules. For exemple here's a simple maze: and here're all the nodes drawn in red: The nodes are like the corners, the crossroads, every point where you can change direction. The distance between each node and the exit of the maze is also measured. While it's generating all the nodes, it places them in a list. 2) As soon as all the nodes are generated, the program will iterate through all the nodes in the list, and try to search in every direction possible for other nodes, to "lin

VertScrollBox Detect when bottom reached android and IOS

VertScrollBox Detect when bottom reached android and IOS I have GridLayout1 on a VertScrollBox1 . The vertical scroll box scrolls through the content of the grid layout. I need to detect when the Vertical scroll box reach the bottom so I get to load more content to the grid layout. And do it again whenever bottom is reached again. GridLayout1 VertScrollBox1 How can I achieve this? 1 Answer 1 Use the OnViewportPositionChange() of the VertScrollBox1 . Then some simple arithmetics tell you when you are at the bottom: OnViewportPositionChange() VertScrollBox1 uses Math, ...; // ... procedure TForm1.VertScrollBox1ViewportPositionChange(Sender: TObject; const OldViewportPosition, NewViewportPosition: TPointF; const ContentSizeChanged: Boolean); begin if CompareValue(NewViewportPosition.Y, GridLayout1.Height - VertScrollBox1.Height) = EqualsValue then Memo1.Lines.Add('At bottom, time to gro

Yet another onTriggerEnter()

Yet another onTriggerEnter() I am aware that many have already posted their problems with this command. I have tried all the differen recommendations but I am still unable to get the onTriggerEnter method to work for me. I am following a set of tutorials and the objective is to create sort of a minigame in which you, using the FirstPersonCharacter controller collect coins. The FirstPersonCharacter has a RigifBody attached to it, Gravity is applied and it is Kinematic, the "Player" tag is applied to the object. The coin has a a rotation script (one of the default assets), a mesh collider with the Is Trigger checkbox and the collection script. The "Coin" tag is applied to this game object and it is static. public class collect : MonoBehaviour { private void onTriggerEnter(Collider c0ol) { Debug.Log("Registered Trigger"); } private void onCollisionEnter(Collision col) { Debug.Log("Registered Collision"); } } I

Firebase transaction in nodeJs

Image
Firebase transaction in nodeJs What I try to achieve is simply increase a value in the database with a transaction. This is working for me as intended, but I always get following error in my firebase console: Function returned undefined, expected Promise or value My current call is as following: exports.reportCounter = functions.database.ref('/user/{userId}/reports/{initiatorId}').onWrite((change,context) => { const userId = context.params.userId; return userRef.child(userId).child("numReports").transaction(function(numReports) { return change.after.exists()?((numReports || 0) + 1):(numReports - 1); }) }); I also tried returning the promise directly: return userRef.child(userId).child("numToIncrement").transaction(function(numToIncrement) { return ((numToIncrement || 0) + 1); }); In both cases, the code is doing what it is supposed to do, but I still receive said error. You should be able to return the promise

Error installing Python 2 via Homebrew on MacOS Mojave

Error installing Python 2 via Homebrew on MacOS Mojave I'm having a lot of trouble with installing Python 2.7 on the MacOS 10.14 Mojave Beta. Yes, I know that Python 2 comes pre-installed on the Mac, but I need a framework build of Python for my task. I've tried re-installing the command line tools and then installing Python 2.7 as suggested here and here, but am still having issues - below is my output: NickLaptop:~ nicholasarner$ brew reinstall python@2 ==> Reinstalling python@2 ==> Downloading https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tar.xz Already downloaded: /Users/nicholasarner/Library/Caches/Homebrew/python@2-2.7.15.tar.xz ==> ./configure --prefix=/usr/local/Cellar/python@2/2.7.15_1 --enable-ipv6 --datarootdir=/usr/l ==> make ==> make install PYTHONAPPSDIR=/usr/local/Cellar/python@2/2.7.15_1 ==> make frameworkinstallextras PYTHONAPPSDIR=/usr/local/Cellar/python@2/2.7.15_1/share/python@ ==> Downloading https://files.pythonhosted.org/pack