Tips and Tricks in a world of Mix

Blog Archives


Getting images byte[] from MS SQLServer through WCF to Ionic3 Angular4

So , that was quite a challenge.

After saving the images as byte[] pretty neat through the MVC client into the MS SqlServer , I wanted to get them into the app of Ionic3 with Angular4 ..


The problem was –

Well there were several problems –

  1. How to return the data through the http without loosing data in “translation” on the way ?

Solution is in C# WCF before returning it convert to base64 – it will send the data intact through the www traffic.

dto.Logo = Convert.ToBase64String(dal.Logo);

       2.   When we get the data – we need to translate it into the image again :

this post helped me –  Search for the comment with 400 upvotes!

So, in my ts client side – my Ionic3 Angular4 baby ,  I added a function translating the byte[] into a Blob.

Blob object represents a file-like object of immutable, raw data. Blobs represent data that isn’t necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user’s system.

b64toBlob(b64Data, contentType, sliceSize) {
contentType = contentType || ”;
sliceSize = sliceSize || 512;

let byteCharacters = atob(b64Data);
let byteArrays = [];

for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
let slice = byteCharacters.slice(offset, offset + sliceSize);

let byteNumbers = new Array(slice.length);
for (let i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i);

let byteArray = new Uint8Array(byteNumbers);


let blob = new Blob(byteArrays, {type: contentType});
return blob;

3. Now I started getting those messages from Chrome 

unsafe:blob:http://localhost:8100/55df97ad-0b55-4724-8a4f-83861b87e60a:1 GET unsafe:blob:http://localhost:8100/55df97ad-0b55-4724-8a4f-83861b87e60a net::ERR_UNKNOWN_URL_SCHEME


So I’ve built a pipe as suggested here  in compbination with the DomSanitation suggested here :

So at last I have taken this solution :

import { Pipe } from ‘@angular/core’;

import { Pipe } from ‘@angular/core’;

import { DomSanitizer, SafeHtml, SafeStyle, SafeScript, SafeUrl, SafeResourceUrl } from ‘@angular/platform-browser’;
@Pipe({ name: ‘safe’})

export class SafePipe {
constructor(protected _sanitizer: DomSanitizer) {
public transform(value: string, type: string = ‘html’): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {

switch (type) {

case ‘html’: return this._sanitizer.bypassSecurityTrustHtml(value);

case ‘style’: return this._sanitizer.bypassSecurityTrustStyle(value);

case ‘script’: return this._sanitizer.bypassSecurityTrustScript(value);

case ‘url’: return this._sanitizer.bypassSecurityTrustUrl(value);

case ‘resourceUrl’:

return this._sanitizer.bypassSecurityTrustResourceUrl(value);

default: throw new Error(`Invalid safe type specified: ${type}`);




Added it to declarations in your app.module.ts with class name SafePipe .
And added the pipe on the html template
<img [src]=”company.LogoImage | safe: ‘resourceUrl'”>
And here I am – after two days without sleep I have images from the server side in my app..
Now it’s just about vise-versa – trying to upload those slippery brothers  🙂

Product Management – what is it? (resources)

  • What is Product Management


Product management is an organizational life-cycle function within a company dealing with the planning, forecasting, and production, or marketing of a product or products at all stages of the product life-cycle. Similarly,product life-cycle management (PLM) integrates people, data, processes and business systems.


  • The Simple Rule for Feature Prioritization


Prioritizing features without a product strategy is like mapping a route without a destination.

When you prioritize features, ask yourself:

  • Are you prioritizing features without a solid strategy and prioritization criteria?
  • Are you only listening to the loudest stakeholder, biggest customer, or squeaky wheel?
  • Are you just chasing after the features of the competition (feature parity)?
  • Are you trying to chase the latest trend in your industry?

If you answer yes to any of the above questions, then your prioritization will not only be difficult, but it’ll be highly ineffective.

So here is the simple rule: Your feature prioritization should flow from your overall product strategy.

Your company’s strategy will inform your high-level roadmap, which tells you what type of functionality you need to build in the short- and mid-term, to satisfy your customers needs as well as other internal company needs.


  •  How to use data to make decisions.


You Can Use Data to Make Better Roadmap Decisions

Product managers may think that unsolicited customer feedback only helps them to understand the vocal minority (the customers who voluntarily share their thoughts and ideas). However, carefully collected feedback combined with other data provides an objective look at every customer, making it an an excellent way to learn more about who your customers actually are and how they’re using your product. Knowledge is power, right?

..product managers can make more well-rounded product roadmaps by relying on a combination of feedback and data; customer feedback is fuel for ideas, while data is fuel for decisions. For example, when deciding between updating an old feature or adding a new one based on several customer suggestions, you can look at the lifetime value (LTV) of the customers who’ve requested the update and the LTV of customers who’ve asked for a new feature to determine which initiative would be most valuable to your company.

While analysis paralysis is real, it’s easily avoidable when you keep in mind what the goals of this data analysis are, decide what the information threshold for a decision is, and always remember that done is better than perfect!



  • How do you know if a product is well designed



flexibile for change,

fast performance,



strategize  adding features


Activate MongoDB from one bat file

  • Put this code in your bat file
  • It’ll start and activate the mongodb in 2 different admin privileged cmd windows.
  • Please check the paths before to adjust to your environment.

START “runas /user:administrator” cmd /K “cd C:\Program Files\MongoDB\Server\3.4\bin & mongod.exe –dbpath c:\data\db”


START “runas /user:administrator” cmd /K “cd C:\Program Files\MongoDB\Server\3.4\bin & mongo.exe “


Ionic3 – Angular4 Super starter change language



So I’ve started with Super starter for ionic angular template.


The problem was it was only english also it had i18n globalization multi lingual plugin

So I’ve found this and perfected it just a bit.


In ..\WebstormProjects\ionic3-angular4\src\pages\tutorial\tutorial.html

Added buttons getting the param of the language wanted :

<ion-header no-shadow>
    <ion-buttons end >
      <button ion-button (click)="translateTo('he')" color="primary">He</button>

    <ion-buttons end >
      <button ion-button (click)="translateTo('ru')" color="primary">Ru</button>

    <ion-buttons end >
      <button ion-button (click)="translateTo('he')" color="primary">He</button>

    <ion-buttons end *ngIf="showSkip">
      <button ion-button (click)="startApp()" color="primary">{{ 'TUTORIAL_SKIP_BUTTON' | translate}}</button>



And in ..\WebstormProjects\ionic3-angular4\src\pages\tutorial\tutorial.ts

I’ve encapsulated the code of  initialization for reuse when the button is hit, so actually all I am doing is reinitializing the language and saying to translate provider want language to use using the parameter I’ve got from clicking the button.

constructor(public navCtrl: NavController, public menu: MenuController, public translate: TranslateService) {


    (values) => {
      console.log('Loaded values', values);
      this.slides = [
          title: values.TUTORIAL_SLIDE1_TITLE,
          description: values.TUTORIAL_SLIDE1_DESCRIPTION,
          image: 'assets/img/ica-slidebox-img-1.png',
          title: values.TUTORIAL_SLIDE2_TITLE,
          description: values.TUTORIAL_SLIDE2_DESCRIPTION,
          image: 'assets/img/ica-slidebox-img-2.png',
          title: values.TUTORIAL_SLIDE3_TITLE,
          description: values.TUTORIAL_SLIDE3_DESCRIPTION,
          image: 'assets/img/ica-slidebox-img-3.png',



That easy. Now you are ready for the global world. 🙂








40 Productivity Hacks



Facebook API Marketing connecting through Python SDK



Many times we need the data of social and marketing networks available offline or at least off the network itself. For better BI and retrospective of the data we can export all the data from the Facebook , but how?

In this post I am going to summarize the easy way to connect your Facebook marketing accounts to get the data from the facebook.


  1. Get
  2. The bootstrapping

Meaning we set our facebook account to use with every function we will use against the facebook api – graph facebook.

my_app_id = '<APP_ID>'
my_app_secret = '<APP_SECRET>'
my_access_token = '<ACCESS_TOKEN>'

But how?

Well , I’ve struggled with it quit a bit.

The app_id and app_secret is easy – you just go to the specific app you want to use and copy it from there.

But how to get the token ?

2.a  shows you the token

2.b  The more complicated and strong way is through the

Choose an app


Login and allow to get data


Get user access token


If you don’t have enough permissions facebook will inform you what is needed.

  “error”: {
    “message”: “(#298) Requires extended permission: read_mailbox”,


3.  Go to pycharm. Add config file as config.json.example inside the example folder of  facebook-python-ads-sdk

  "app_id": "<YOUR_APP_ID>",
  "app_secret": "<YOUR_APP_SECRET>",
  "act_id": "act_<YOUR_ACCOUNT_ID>",
  "page_id": "<YOUR_PAGE_ID>",
  "access_token": "<ACCESS_TOKEN>"

4. Go to

Choose the account / business you want to work with

business_id== page_id

Go to


You can see an id of account in the dropbox the act_id or press on the account and see the “act=” value.

Pay attention that you need to add “act_” prefix and then copy paste the id itself.

5. Now inside the Pycharm just right click and debug any of the examples..





AdCampaign to just Campaign in code

from facebookads.objects import (
    AdUser, Campaign,


Code example to get campaigns and insights


from facebookads import FacebookSession
from facebookads import FacebookAdsApi
from facebookads.adobjects.adsinsights import AdsInsights
import datetime

from facebookads.objects import (
    AdUser, Campaign,

import json
import os
import pprint

pp = pprint.PrettyPrinter(indent=4)
this_dir = os.path.dirname(__file__)
config_filename = os.path.join(this_dir, 'config.json')

config_file = open(config_filename)
config = json.load(config_file)

### Setup session and api objects
session = FacebookSession(
api = FacebookAdsApi(session)

if __name__ == '__main__':

    print('\n\n\n********** Reading objects example. **********\n')

    ### Setup user and read the object from the server
    me = AdUser(fbid='me')

    ### Read user permissions
    print('>>> Reading permissions field of user:')


    ### Get first account connected to the user
    my_account = me.get_ad_account()

    ### Read connections (in this case, the accounts connected to me)

    # Pro tip: Use list(me.get_ad_accounts()) to make a list out of
    # all the elements out of the iterator

    my_accounts_iterator = me.get_ad_accounts()#[0]
    print('>>> Reading accounts associated with user')
    for account in my_accounts_iterator:
        for campaign in account.get_campaigns(fields=[]):
            print(">>> Campaign Stats")
            campaignObj = Campaign(campaign._json[u'id'])

            today =
            start_time = str(today - datetime.timedelta(weeks=1))
            end_time = str(today)

            campaign = Campaign(campaign._json[u'id'])
            params = {
                'time_range': {
                    'since': start_time,
                    'until': end_time,
                'fields': [
            insights = campaign.get_insights(params=params)


This slideshow requires JavaScript.




Tag Cloud

%d bloggers like this: