How to strike through text in Gmail?

Use “Alt + Shift + 5”. I didn’t know the trick before.

Posted in Uncategorized | Leave a comment

A json_encode issue in PHP

I found json_encode threw errors because of the “™” characters in the string retrieved from database. You can fix it when you retrieve the data from database (mysql). Here is the solution:

$res = mysqli_query($gDB, 'SELECT age,carrier,id,imageUrl,CAST(CONVERT(name USING utf8) AS BINARY) AS name,CAST(CONVERT(snippet USING utf8) AS BINARY) AS snippet FROM ' . $table);

Posted in Uncategorized | Leave a comment

How to copy files to AWS servers?

Here is how:
scp -i ~/Desktop/key_file.pem ~/Desktop/yourfile.txt ubuntu@yourawsinstance:/home/ubuntu/

Posted in Uncategorized | Leave a comment

React Native android build failed. SDK location not found.

Go to your React native Project > Android
Create a file local.properties
Open the file
paste your Android SDK path like below

in Windows sdk.dir = C:\\Users\\USERNAME\\AppData\\Local\\Android\\sdk
in macOS sdk.dir = /Users/USERNAME/Library/Android/sdk
in linux sdk.dir = /home/USERNAME/Android/Sdk
Replace USERNAME with your user name

Now, Run the react-native run-android in your terminal.

Posted in Uncategorized | Leave a comment

Remove spaces between tag in xml files

I need to compare two xml files but the spaces differences between tags preventing me from focusing on the real differences. I googled found this solution. You can use regular express to remove these white spaces: replace “>\s*<" will fix it. Then you can compare new files and find your real differences.

Posted in Uncategorized | Leave a comment

Atom editor issue

I installed atom editor on my mac but when I ran it from the terminal it always disappear. So I have to run these commands again:

rm /usr/local/bin/atom
ln -s /Applications/Atom.app/Contents/Resources/app/atom.sh /usr/local/bin/atom

Posted in Uncategorized | Leave a comment

PHP page 500 error

If you got 500 error and you’re wondering what the error really is, you can use the following statement in your php file:

ini_set('display_errors', 1);

Posted in Uncategorized | Leave a comment

C# – understand delegate

A delegate can be seen as a placeholder for a/some method(s).

By defining a delegate, you are saying to the user of your class, “Please feel free to assign, any method that matches this signature, to the delegate and it will be called each time my delegate is called”.

Here is an example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DelegateExample1
{

///

/// A class to define a person
///

public class Person
{
public string Name { get; set; }
public int Age { get; set; }
}

class Program
{
//Our delegate
public delegate bool FilterDelegate(Person p);

static void Main(string[] args)
{

//Create 4 Person objects
Person p1 = new Person() { Name = "John", Age = 41 };
Person p2 = new Person() { Name = "Jane", Age = 69 };
Person p3 = new Person() { Name = "Jake", Age = 12 };
Person p4 = new Person() { Name = "Jessie", Age = 25 };

//Create a list of Person objects and fill it
List people = new List() { p1, p2, p3, p4 };

//Invoke DisplayPeople using appropriate delegate
DisplayPeople("Children:", people, IsChild);
DisplayPeople("Adults:", people, IsAdult);
DisplayPeople("Seniors:", people, IsSenior);

Console.Read();
}

///

/// A method to filter out the people you need
///

/// A list of people
/// A filter
/// A filtered list
static void DisplayPeople(string title, List people, FilterDelegate filter)
{
Console.WriteLine(title);

foreach (Person p in people)
{
if (filter(p))
{
Console.WriteLine("{0}, {1} years old", p.Name, p.Age);
}
}

Console.Write("\n\n");
}

//==========FILTERS===================
static bool IsChild(Person p)
{
return p.Age = 18;
}

static bool IsSenior(Person p)
{
return p.Age >= 65;
}
}
}

Posted in Uncategorized | Leave a comment

Restore iPhone backup issue

Today I bought an iPhone X and tried to restore my iPhone 6s backup to it but failed. I got error message saying backup corrupt or incompatible. I was wondering if it was related to my carrier transfer from at&t to verizon but it turned out it’s not related. It is because the iOS on my iPhone X is older than the one on my iPhone 6s. After I upgraded iOS of my iPhone X to the latest version, I was able to restore it.

Posted in Uncategorized | Leave a comment

How to install gulp?

You need to run this command:
npm install -g gulp-cli

Posted in Uncategorized | Leave a comment