Using Jetpack Compose alpha08 build. This post will cover how to draw shapes in Jetpack Compose.
Before starting, it’s good to have a grid notebook, something you can just use pen and paper and draw what you want to draw there first. The 0,0 is always in the top left corner. It’s basicly the reverse coordinate system. In a grid of 100x100, the bottom right corner is 100,100. All these examples will use a canvas of 100x100. For each of the example I’m gonna use a little different approach. End result still remains the same.
The most basic way to…
We are making a single html page that will display a random Kana — a random Hiragana and its Katakana equivalent.
Lets create app.js, it will contain our JavaScrip, data structure and the function to fetch a random kana out of the array.
Our kana variable is an array of objects. Where each object represents a hiragana/katakana pair together with its romaji — english letter.
The “hiragana_info” and the “katakana_info” serve as hints, a simple remined what the kana for each of them kinda looks like.
Comparing 3 web frameworks, how fast can they render the message “hello” via a templating engine back to the user. There is no optimisation going on. The premise is:
Using wrk, since all of them will be on the same port the command will be the same for all. Using 12 threads, concurrent 400 requests for duration of 30 seconds.
wrk -t12 -c400 -d30s http://127.0.0.1:3000/home
This will be our baseline. Ruby used 2.6.3. Rails…
Sometimes you just need to secure your localhost in order to test some stuff, like OAuth for example.
Creating a certificate for localhost is easy with
openssl . Just put the following command in the terminal. The output will be two files: localhost.key and localhost.crt
openssl req -x509 -out localhost.crt -keyout localhost.key \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=localhost' -extensions EXT -config <( \
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
Click on the crt file, on macOS the keychain app will open, add the key to it.
Now double click on it and under the trust section you will see “When using this certificate” select “Always Trust”.
Now in Next.js we have to create our own server.js file if not already.
Run the server, you now have a secure connection to localhost.
Setting up React with Babel is already available with create-react-app. If you need something configured and just start writing stuff, use that. In this article, we will create our own configuration boilerplate. In doing this we will better understand how these things actually work together.
Setting up working directory. In it, we will prepare the folder structure and some files.
Now we need to install all these packages.
Open config/webpack.config.js and put this content in it. This tells webpack how to work with out files in the src folder and how to bundle them together and deliver them.
Let’s build a simple Rails API and use Netflixes FastJSON library to serialize our JSON responses.
First create a new rails project in api mode.
rails new fjsonrail --api --skip-tests -d mysql
Then in the gem file add the gems:
gem 'faker', '~> 1.9', '>= 1.9.3'
gem 'kaminari', '~> 0.17.0'
Now run bundle install and rails db:create to create the database.
Create a model called Location, we will use these records for serialization.
rails g model Location name
And run rails db:migrate to apply the changes to the database. Now we need some sample data. For that we…
A simple painter, where you pick a color from a set of preselected ones. And then paint a grid cell with that color. We will be using React Hooks, more specifically useContext and useState. Context will give our components a context of color, which can be set via useState hook.
Create a react app, with create-react-app. I’m using the 3.0.0 version. For design layout I’ll use the Bulma CSS. It’s very easy to use.
First, create components and contexts folders. These will contains, as the name already tells us components and contexts.
Usually when somebody thinks chat, they think WebSockets. Normally there are tutorials how you make a server in NodeJs for example and a client in HTML. But in this case the client will also be a NodeJs app. It will display messages from the server and listen to users input with NodeJs
There will be no persistence here. A client will see only messages that server sends him from the point he connects to it. Also whenever a client is connected, the server will generate a random color and a random name, and the client will use that. …
Snake is so simple everyone can do it. But in case you need inspiration, here is how.
Create an index.html file. And put the basic html stuff inside.
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" /><title>Snake</title>
Now inside body, add a canvas element.
<canvas id="canvas" width="400" height="400"></canvas>
Let’s first define what should happen when
window.onload triggers. We want to get context of the…
Gmail is pretty nice right. Now let’s remove the stuff that we never use, making it a lot more cleaner, with a chrome extension.
Create a folder, name it what ever u like. I’m gonna name it ‘freshness’. Now inside that folder create a manifest.json, background.js, script.js & style.css.
Every extension needs an icon, so also create a folder called images and place some icon png files in there. I took mine from the Google Chrome Extension Tutorial (https://developer.chrome.com/extensions/getstarted).
The manifest defines the chrome extension. Without it Chrome can’t do anything. …