C++ to Python Conversion

Hi all,

I am new to C++, I am studying a C++ code and would like to learn how to implement it in Python.

I encountered the following:
1 unsigned short arr1[2];
2 unsigned int arr2 = (unsigned int ) arr1;

I tried to write a C++ code to see the effect of the second line:
.....

    arr2[0] = 6553621;  //some random big number 

    cout<< "arr1[0] is "  << arr1[0] <<endl;
    cout<< "arr1[1] is "  << arr1[1] <<endl;
    cout <<"arr2[0] is " <<arr2[0] <<endl;
    cout <<"arr2[1] is " <<arr2[1] <<endl;

,and I got the following:
arr1[0] is 21
arr1[1] is 100
arr2[0] is 6553621
arr2[1] is 1257984000

My question is how to get the values in arr1[0] and arr1[1] after 6553621 is assigned to arr2[0]?

9 Top Text to Speech APIs

Text to Speech (TTS) services convert text into spoken word audio. The technology is useful for providing content accessibility to people with visual impairments, reading impairments such as dyslexia, speaking impairment, studying languages, playing video games, language translation, and other uses.

Developers wishing to enhance applications with TTS services can tap into APIs for help.

How to Use Google Sheets with D3.js and Google Visualization

The D3.js visualization library can be used for creating beautiful graphs and visualizations using data from external sources including CSV files and JSON data.

To give you an example, this D3.js animation inside the Google Sheets associated with the COVID-19 tracker project visualizes the growth of Coronavirus cases in India over time. It uses the Google Visualization API, D3.js and the very-awesome Bar Chart Race component built by Mike Bostock, the creator of D3.js.

Google Sheets and D3.js

This guide explains how you can use data in your Google Spreadsheets to create charts with D3.js using the Visualization API. The data is fetched in real-time so if the data in your Google Sheets is updated, it is reflected in the graph as well.

D3.js Chart with Google Sheets

Step 1: Make the Google Sheets public

Make your Google Spreadsheet public - you can either share the sheet with “anyone who has the link can view” access or make it public so even search engines that find your sheet that has the Charts data.

We are using this Google Sheet for this tutorial.

Step 2: Load the Libraries in HTML

Load the D3.js (v5) and the Google charts library in your index.html file. The JavaScript for rendering the D3 chart is written in the index.js file.

<!DOCTYPE html>
<html>
  <head>
    <script src="https://www.gstatic.com/charts/loader.js"></script>
    <script src="https://d3js.org/d3.v5.min.js"></script>
  </head>

  <body>
    <svg></svg>
  </body>
  <script src="./index.js"></script>
</html>

Step 3: Initialize the Google Visualization API

Here specify the URL of your publish Google Spreadsheet (the gid should point to the sheet that has the data). The Google Visualization API Query Language (reference) lets you use SQL like syntax to specify columns that should be used for fetching data from the Google sheet. You can also use offset, where and limit clauses to limit the data that is returned by Google Sheets.

google.charts.load('current');
google.charts.setOnLoadCallback(init);

function init() {
  var url =
    'https://docs.google.com/spreadsheets/d/1YpiTo7Fc3QvBdbuReCIcwtg7lnmZupQAH57phrDLotI/edit#gid=0';
  var query = new google.visualization.Query(url);
  query.setQuery('select A, B');
  query.send(processSheetsData);
}

Step 4: Prepare the Data for D3.js

After the spreadsheet data is available, manipulate the response in an Array of Objects that can be read by d3.js. Google Sheets returns numerical data as String so we can either use parseInt or the Unary (+) operator to convert the String to Integer.

function processSheetsData(response) {
  var array = [];
  var data = response.getDataTable();
  var columns = data.getNumberOfColumns();
  var rows = data.getNumberOfRows();
  for (var r = 0; r < rows; r++) {
    var row = [];
    for (var c = 0; c < columns; c++) {
      row.push(data.getFormattedValue(r, c));
    }
    array.push({
      name: row[0],
      value: +row[1],
    });
  }
  renderData(array);
}

Step 5: Render the D3.js chart

Next, we create a Bar Chart in D3.js using the data from Google Sheets. You may follow this tutorial on @ObservableHQ to understand how to make bar charts inside D3.js. The chart is rendered in SVG.

function renderData(data) {
  const margin = { top: 30, right: 0, bottom: 30, left: 50 };
  const color = 'steelblue';
  const height = 400;
  const width = 600;
  const yAxis = (g) =>
    g
      .attr('transform', `translate(${margin.left},0)`)
      .call(d3.axisLeft(y).ticks(null, data.format))
      .call((g) => g.select('.domain').remove())
      .call((g) =>
        g
          .append('text')
          .attr('x', -margin.left)
          .attr('y', 10)
          .attr('fill', 'currentColor')
          .attr('text-anchor', 'start')
          .text(data.y)
      );

  const xAxis = (g) =>
    g.attr('transform', `translate(0,${height - margin.bottom})`).call(
      d3
        .axisBottom(x)
        .tickFormat((i) => data[i].name)
        .tickSizeOuter(0)
    );
  const y = d3
    .scaleLinear()
    .domain([0, d3.max(data, (d) => d.value)])
    .nice()
    .range([height - margin.bottom, margin.top]);

  const x = d3
    .scaleBand()
    .domain(d3.range(data.length))
    .range([margin.left, width - margin.right])
    .padding(0.1);

  const svg = d3
    .select('svg')
    .attr('width', width)
    .attr('height', height)
    .attr('fill', color);

  svg
    .selectAll('rect')
    .data(data)
    .enter()
    .append('rect')
    .attr('x', (d, i) => x(i))
    .attr('y', (d) => y(d.value))
    .attr('height', (d) => y(0) - y(d.value))
    .attr('width', x.bandwidth());

  svg.append('g').call(xAxis);

  svg.append('g').call(yAxis);
}

49 Free Tattoo Fonts

This is a big collection of free tattoo fonts. You can also use these fonts for creating logos. Download is also available for tattoo fonts

Visit The Site For More...

VB Access Buttons

Hello,
Can someone assist me how to create here buttons 
- Button7 - First
- Button5 - Next
- Button6 - Previous
- Button8 - Last

To search in database and display the results.

Here is my project until now:
- Also if there are mistakes or suggestions to make it better i'm open for ideas to learn too :)

<pre>
Public Class Form2

    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Using con As New OleDbConnection(ServerStatus)
            Using cmd As New OleDbCommand("SELECT * FROM Table", con)
                cmd.CommandType = CommandType.Text
                Using sda As New OleDbDataAdapter(cmd)
                    Using dt As New DataTable()
                        sda.Fill(dt)

                        'Set AutoGenerateColumns False
                        DataDisplay.AutoGenerateColumns = False
                        'DataDisplay.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
                        DataDisplay.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
                        DataDisplay.AutoResizeColumns()

                        'Set Columns Count
                        DataDisplay.ColumnCount = 6

                        'Add Columns
                        DataDisplay.Columns(0).Name = "ID"
                        DataDisplay.Columns(0).HeaderText = "ID"
                        DataDisplay.Columns(0).DataPropertyName = "ID"

                        DataDisplay.Columns(1).Name = "cName"
                        DataDisplay.Columns(1).HeaderText = "Name"
                        DataDisplay.Columns(1).DataPropertyName = "cName"

                        DataDisplay.Columns(2).Name = "cNumber"
                        DataDisplay.Columns(2).HeaderText = "Number"
                        DataDisplay.Columns(2).DataPropertyName = "cNumber"

                        DataDisplay.Columns(3).Name = "cSupplier"
                        DataDisplay.Columns(3).HeaderText = "Supplier"
                        DataDisplay.Columns(3).DataPropertyName = "cSupplier"

                        DataDisplay.Columns(4).Name = "cStore"
                        DataDisplay.Columns(4).HeaderText = "Store"
                        DataDisplay.Columns(4).DataPropertyName = "cStore"

                        DataDisplay.Columns(5).Name = "cCount"
                        DataDisplay.Columns(5).HeaderText = "Count"
                        DataDisplay.Columns(5).DataPropertyName = "cCount"

                        TextBox1.Text = dt.Rows(0).Item(1)
                        TextBox2.Text = dt.Rows(0).Item(2)
                        TextBox3.Text = dt.Rows(0).Item(3)
                        TextBox4.Text = dt.Rows(0).Item(4)
                        TextBox5.Text = dt.Rows(0).Item(5)
                        TextBox6.Text = dt.Rows(0).Item(0)

                        DataDisplay.DataSource = dt
                    End Using
                End Using
            End Using
        End Using
        Try
            With cmd
                Dim stream As New IO.MemoryStream()
                conn.Open()
                .Connection = conn
                .CommandText = "select cPicture from Table where ID=@uID"
                .Parameters.Add("@uID", OleDbType.Integer, 50).Value = TextBox6.Text
                Dim image As Byte() = DirectCast(cmd.ExecuteScalar(), Byte())
                stream.Write(image, 0, image.Length)
                Dim bitmap As New Bitmap(stream)
                PictureBox1.Image = bitmap '---&gt;I have used another picturebox to display image from database.
                stream.Close()
                .Parameters.Clear()
            End With
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            cmd.Dispose()
            If conn IsNot Nothing Then
                conn.Close()
            End If
        End Try
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        'Adapter.Update(dt)
        Try
            With cmd
                Dim stream As New IO.MemoryStream()
                conn.Open()
                .Connection = conn
                .CommandText = "select cPicture from Table where ID=@uID"
                .Parameters.Add("@uID", OleDbType.Integer, 50).Value = TextBox6.Text
                Dim image As Byte() = DirectCast(cmd.ExecuteScalar(), Byte())
                stream.Write(image, 0, image.Length)
                Dim bitmap As New Bitmap(stream)
                PictureBox1.Image = bitmap '---&gt;I have used another picturebox to display image from database.
                stream.Close()
                .Parameters.Clear()
            End With
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            cmd.Dispose()
            If conn IsNot Nothing Then
                conn.Close()
            End If
        End Try
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim dialog As New OpenFileDialog()
        dialog.Title = "Browse Picture"
        dialog.Filter = "Image Files(*.BMP;*.JPG;*.GIF;*.PNG)|*.BMP;*.JPG;*.GIF;*.PNG"
        If dialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
            PictureBox1.Image = Image.FromFile(dialog.FileName)
            'TextBox1.Text = dialog.FileName.ToString
        End If
    End Sub
    Private Sub RefreshData()
        Using con As New OleDbConnection(ServerStatus)
            Using cmd As New OleDbCommand("SELECT * FROM Table", con)
                cmd.CommandType = CommandType.Text
                Using sda As New OleDbDataAdapter(cmd)
                    Using dt As New DataTable()
                        sda.Fill(dt)

                        TextBox1.Text = dt.Rows(0).Item(1)
                        TextBox2.Text = dt.Rows(0).Item(2)
                        TextBox3.Text = dt.Rows(0).Item(3)
                        TextBox4.Text = dt.Rows(0).Item(4)
                        TextBox5.Text = dt.Rows(0).Item(5)
                        TextBox6.Text = dt.Rows(0).Item(0)

                        DataDisplay.DataSource = dt
                    End Using
                End Using
            End Using
        End Using
        Try
            With cmd
                Dim stream As New IO.MemoryStream()
                conn.Open()
                .Connection = conn
                .CommandText = "select cPicture from Table where ID=@uID"
                .Parameters.Add("@uID", OleDbType.Integer, 50).Value = TextBox6.Text
                Dim image As Byte() = DirectCast(cmd.ExecuteScalar(), Byte())
                stream.Write(image, 0, image.Length)
                Dim bitmap As New Bitmap(stream)
                PictureBox1.Image = bitmap '---&gt;I have used another picturebox to display image from database.
                stream.Close()
                .Parameters.Clear()
            End With
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            cmd.Dispose()
            If conn IsNot Nothing Then
                conn.Close()
            End If
        End Try

    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Try
            With cmd
                Dim ms As New IO.MemoryStream()
                PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)
                Dim arrimage() As Byte = ms.GetBuffer
                conn.Open()
                .Connection = conn
                .Parameters.Add("@uName", OleDbType.VarChar, 50).Value = TextBox1.Text
                .Parameters.Add("@uNumber", OleDbType.Integer, 50).Value = TextBox2.Text
                .Parameters.Add("@uSupp", OleDbType.VarChar, 50).Value = TextBox3.Text
                .Parameters.Add("@uStore", OleDbType.VarChar, 50).Value = TextBox4.Text
                .Parameters.Add("@uCount", OleDbType.Integer, 50).Value = TextBox5.Text
                .Parameters.Add("@Picture", OleDbType.Binary).Value = arrimage
                .Parameters.AddWithValue("@uID", TextBox6.Text)
                .CommandText = "UPDATE Table SET cName = @uName,cNumber = @uNumber,cSupplier = @uSupp,cStore = @uStore,cCount = @uCount,cPicture = @Picture WHERE ID = @uID"
                .ExecuteNonQuery()
                .Parameters.Clear()
                ms.Close()
            End With
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            cmd.Dispose()
            If conn IsNot Nothing Then
                conn.Close()
            End If
            RefreshData()
        End Try
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Try
            With cmd
                Dim ms As New IO.MemoryStream()
                PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)
                Dim arrimage() As Byte = ms.GetBuffer
                conn.Open()
                .Connection = conn
                .CommandText = "INSERT INTO Table (cName,cNumber,cSupplier,cStore,cCount,cPicture) VALUES (@uName,@uYazaki,@uSupp,@uStore,@uCount,@picture)"
                .Parameters.Add("@uName", OleDbType.VarChar, 50).Value = TextBox1.Text
                .Parameters.Add("@uNumber", OleDbType.Integer, 50).Value = TextBox2.Text
                .Parameters.Add("@uSupp", OleDbType.VarChar, 50).Value = TextBox3.Text
                .Parameters.Add("@uStore", OleDbType.VarChar, 50).Value = TextBox4.Text
                .Parameters.Add("@uCount", OleDbType.Integer, 50).Value = TextBox5.Text
                .Parameters.Add("@Picture", OleDbType.Binary).Value = arrimage
                .ExecuteNonQuery()
                .Parameters.Clear()
                ms.Close()
            End With
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            cmd.Dispose()
            If conn IsNot Nothing Then
                conn.Close()
            End If
        End Try
    End Sub

End Class</pre>

Diverse Illustration

Hey gang, #BlackLivesMatter.

One tiny way I thought we could help here on this site, aside from our efforts as individuals, is to highlight some design resources that are both excellent and feature Black people. Representation matters.

Here’s one. You know Pablo Stanley? Pablo is a wonderful illustrator who combines his illustration work with modern design tooling. He has these illustration libraries that come as Sketch and Figma plugins so you can mix and match characters and their clothes, hair, skin color, and such.

Like Humaaans! Look at the possibilities:

Or OpenPeeps that has a different style but the same spirit:

Pablo and a team of folks are building Blush, which brings these things together into one product. Not just Pablo’s work, but the work of more illustrators like Susana Ortiz, Elina Cecila Giglio, Isabela Humphrey, and Else Ramirez to name a few so far.

I literally needed some people illustration the other day for an upcoming project, so I signed up and had a great time with it. I didn’t even know plugins like this were even possible in Figma!

Notice how absolutely non-white-centric all this is.

What I needed for my project was business-style people doing vague business-like things, and when I shopped around my usual stock art place, I get results like this:

It’s not that this company didn’t have diverse illustrations too. The more I looked around, I found plenty of good stuff, but the search results really did have a heavy tilt toward illustrations of groups of white people. That certainly would not have been appropriate for my project, which is ultimately going to be a part of a social experience for a very global product. I’d think a flock of white-only people as a graphic is rarely a good fit for any project.

If you take issue with that paragraph I just wrote, here’s some diverse Buttsss that you can kiss lolz:

And speaking of diverse illustrations, how about getting straight to it with Black Illustrations.

There’s some free stuff, and things you can buy, which cover design aspect that also suffer from lack of representation, like icon sets:

unDraw from Katerina Limpitsouni has great stuff too!

This last thing isn’t an illustration example, but y’all CSS people are likely to get a kick out of it:

100% of the proceeds of that shirt go to to the Black Lives Matter foundation.

I know, I know, ID’s can’t start with a number. If an element had an id="000000", you’d have to select it with #\30 00000 in CSS because it’s just weird like that. But the point is still made ;).

The post Diverse Illustration appeared first on CSS-Tricks.