Posts

Showing posts from July, 2018

Git delete branch locally and remotely on github.

Delete local branch git branch -d tab_drawer Delete remote branch in Git git push git --delete api_integration

Reactive native : Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function but got: object

This is hard to trace but essentially there was a difference in terms of having bracket in your code, for example, Good i mport Navigator from './tabs/home' ; // Ok, If you have export default defined in your js Fail import { Navigator } from './tabs/home' ; // Works,f you js file has more than a default export. Apparently this has to do with "De-structuring" object in javascript. For example, say you have your components export that looks like this :- export const Tabs = createMaterialTopTabNavigator ({ Home: Home , About: Settings , Contact: Settings },{ tabBarOptions: { activeTintColor: '#000' , inactiveTintColor: 'gray' , style: { backgroundColor: '#fff' , }, indicatorStyle: { backgroundColor: '#000' , }, } }); This works.... . import { Tabs

react-native still dependent on jdk 8.

To my surprise, reactive native is very much dependent on jdk 8. After installing and setting my java_home to point to jdk 10, it was not working anymore.

Android studio - Unable install Intel x86 HAXM - hardware accelerator

Trying to install  Intel x86 HAXM - hardware accelerator using Android studio. And just like the title of the post, i am not able to do so. So best way to do it yourself. You have to download, extract and install it yourself. Go to the link here . If you have problem trying write to C:\users\username\appdata\local\intel, please add "Everyone" to the list of users who can access this folder.

React Native error: “Could not determine java version 9/10"

Bump into this error earlier and thanks -to some magic of upgrading the distribution url to use gradle-4.3, we able to resolve this error :- distributionUrl =https\://services.gradle.org/distributions/gradle-4.3-rc-2-all.zip That was it.

Solidity contract test error : is not implicitly convertible to expected type uint256

I had this piece of code in my contract (just a property) and when i write my test, to my surprise i se that i need to include a function() parameter in the code to call it. uint public _landCount; // In test contractInstance. _landCount(); // Returns value.

react app start - configuring typescript + react

One of the best way to start creating application are create-react-app . It is completed driven by cli. I will try not to take away the glory from folks from microsoft. Please visit the link above and follow the instruction. You should really use this to create a react quick start. 

“Truffle test” fails - Could not find artifacts for xxxx from any sources

Bump into this issue and the solution to to "ensure your test contract name matches your contract filename. For example, this is where you will get an error TestLandContract.sol contract TestLandContractOhCrap { LandContract targetContract = LandContract (DeployedAddresses. LandContract ()); function test () public { uint data = 8 ; Assert. equal ( 8 , data, "Adoption of pet ID 8 should be recorded." ); } } No error TestLandContract.sol contract TestLandContract { LandContract targetContract = LandContract (DeployedAddresses. LandContract ()); function test () public { uint data = 8 ; Assert. equal ( 8 , data, "Adoption of pet ID 8 should be recorded." ); } }

Getting started with EOS block chain platform

docker is probably the easier way to setup EOS locally. So install Docker, if you do not have one. Pull down the image by runmning the following command docker pull eosio/eos-dev Next start your image running this :- docker run --rm --name eosio -d -p 8888 :8888 -p 9876 :9876 -v /tmp/work:/work -v /tmp/eosio/data:/mnt/dev/data -v /tmp/eosio/config:/mnt/dev/config eosio/eos-dev /bin/bash -c "nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::wallet_plugin --plugin eosio::producer_plugin --plugin eosio::history_plugin --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin --plugin eosio::http_plugin -d /mnt/dev/data --config-dir /mnt/dev/config --http-server-address=0.0.0.0:8888 --access-control-allow-origin=* --contracts-console" There are some utilities like nodeos, cleos (client eos) and keosd which are needed. Just run docker exec -it /bin/bash Magically, you get all the tools mentioned above for free.

sitecore item api using powershell

Image
Here is an interesting problem, using powershell to call sitecore api's item. First we need to authenticate ourselves. To Authenticate # Your sitecore api login $loginurl = 'https://yourserver/sitecore/api/ssc/auth/login' # Converting object into a JSON $Body = @{     domain = "sitecore"     username = "admin"     password = "mradmin"  } $json = $Body | convertto-json # Call to authenticate and store into session variable call "mysession". Please note that we do not put $ in front of it. Invoke-WebRequest -Uri $loginurl -ContentType 'application/json' -Method 'POST' -Body $json -usebasicparsing -sessionvariable mysession You should get something like this. Next, we pass our session variable into our websession parameter (shown in bold). $jsonContent = Invoke-WebRequest 'https:/yourserver/sitecore/api/ssc/item/%7B95FD0E53-0466-49A6-BB24-F5D2FE996393%7D' -WebSession $m

Getting a sitecore api item using curl

You can authenticate yourself using curl with the following curl command :- curl -X POST  https://yourserver/sitecore/api/ssc/auth/login -c cookiefile -d "domain=sitecore&username=admin&password=mradmin" When you are successfully authenticated, please try to request for the item using the following curl - curl -b cookiefile curl -b cookiefile  https://yourserver/sitecore/api/ssc/item/%7B95FD0E53-0466-49A6-BB24-F5D2FE996393%7D Please note that you need to use HTTPS.

tamperchrome : tool to help debug your http(s)

Tamperchrome is a cool extension to help you with your http debugging.  For more info, you can find out from here. https://github.com/google/tamperchrome

solidity quick start

Keywords for solidity mapping ( mapping(_KeyType   =>   _ValueType)  - use to express we're going to map 'KeyType' to get the intended 'ValueType'.  We will use address as a key and we get Voter type in return. // This declares a state variable that // stores a `Voter` struct for each possible address. mapping ( address => Voter ) public voters ; payable - if a function supports payment (transfer  / receive payment)  storage - memory - stack  - msg.sender is the current account interacting with a transaction. Data type is address. A very simple, get / set contract property example :- Coin balance example. In this example, solidity code allows user to mint / create coins and then keep track it it. A call to 'coinbalance' you will be able to query amount in an address. Some common global variables / terms block.blockhash(uint numberOfBlock) returns (bytes32) : hash which belongs to the given block – will o

Python :- UnicodeDecodeError: 'charmap' codec can't decode byte

encounter this issue sometime ago and the reason this is happening is because open() file method was called without passing in encoding type like utf8, etc. If you open your file using the code below, the error should go away. with open (fname, encoding = 'utf8' ) as fp:

Database feature as a service framework

While database has been pretty old and dominant technology, we face a rather challenging issue with big data, ingesting data faster. Here we proposed a database framework which sees database as a blob and services such as synchronization, indexing, sharding, scaling as a plug-in add-on service. As database gets bigger, there is no standard way to make it faster. We need to figure out a way of learning data stored in a database and proposed ways to handle, store, retrieve and managed it.

Beckman database report is pretty interesting.

If you're interested about progress in database research by some of the top db researcher in the world, check out beckman report here . Explore their slides. Some of the researcher has some interesting point to put across.

after running npm install, you still didn't get your script to run on Windows

Please update your %PATH% to add the following path pattern depending on which user you used. C:\Users\jeremywoo\AppData\Roaming\npm That's it!

Creating nuget package - revisit

Image
To create a nuget package :- a) Create your project like you would do normally. b) Download nuget cli  and place it in your project root directory. Next create your nuspec file. c) Run " nuget pack AppConsole1.csproj " and not against your nuget spec file. d) Setup local repository Go to Tools -> Options -> Nuget Package Manager -> Package Sources -> Click on the Green plus sign and setup a local repository by providing a Name and Source (folder path to your project) . Done! :) Please note : You can also bundle static file here. Possible error :- Invalid URI: The format of the URI could not be determined. This happens if your have an attribute in your nuspec which is not a valid url value. Value cannot be null or an empty string. Parameter name: value This happens when you have a mandatory attribute for example, name, description but it was omitted. 

sitecore - getting field value

From time to time you might need to find out what is the value for field value in sitecore. You can use the following script to get field value.  First you query [Items] table and follow by [Fields] table  as shown in code below :-

async / await and promise

To ensure we make the correct async / await call, we still need Promises to resolve our task. Promise is like a marker that helps signified a task has been completed. Pretty sure if you don't make use of promise, it is very unlikely that your function is awaited. In this example, we're calling a long running external call to a service and then uses await to 'wait' for the results. Results are then output into the console.

Multiple with typescript issues - cannot resolve console and async function or method in ES5/ES3 requires the 'Promise' constructor

Was facing multiple issues trying to write up an async function. These error messages are as follows :- 1, Cannot resolve console and async function Solution :- Requires tsconfig.json to have the following configuration npm install @types / node 2. Method in ES5/ES3 requires the 'Promise' constructor Solution

An async function or method must have a valid awaitable return type

While trying to create an async function with a return type, i encounter this error message :- "An async function or method must have a valid awaitable return type" this simply means that we need to have a function with the following signature which receive a Promise   That's it ! :)

getting json post from express

With express 4.6, it comes with its json parser. We don't need to use body parser. All we need to do is setup this in our middleware and we're good to go.

debugging application with nodejs

Image
There are two easy ways to debug application written in nodejs which are :- a) Nodejs - ChromeDev Tools - First you need to run node --inspect, assuming you are trying to debug index.js scripts. node --inspect=0.0.0.0:9229 index.js next, you need to click on the "green" button. If you do not see your scripts appearing, on your leftmost tab, you should see "FileSystem, Node". Select Node and then drill down until you see your scripts. Place your break points as shown above b) Visual Code - using this approach all you need to do is select "Debug" -> "Start Debugging"