Skip to content

Instantly share code, notes, and snippets.

View kronaemmanuel's full-sized avatar

Krona Emmanuel kronaemmanuel

View GitHub Profile
@kronaemmanuel
kronaemmanuel / nextHead.jsx
Created June 13, 2020 09:50
Next Head's basic usage
import Head from { next/head }
// A high level App component
const App = () => {
return(
<Head>
// Page will have "My App" as its title initially
<meta property="title" content="My App" key="title" />
</Head>
<Details />
@kronaemmanuel
kronaemmanuel / bar.jsx
Last active June 21, 2020 09:06
Nivo Bar Chart
import { ResponsiveBar } from '@nivo/bar'
// Code for Bar chart
const MyResponsiveBar = ({ data }) => (
<ResponsiveBar
data={data}
keys={[ 'hot dog', 'burger', 'sandwich', 'kebab', 'fries', 'donut' ]}
indexBy="country"
margin={{ top: 50, right: 130, bottom: 50, left: 60 }}
padding={0.3}
@kronaemmanuel
kronaemmanuel / data.js
Created June 21, 2020 09:07
Nivo Bar Chart Data
[
{
"country": "AD",
"hot dog": 49,
"hot dogColor": "hsl(151, 70%, 50%)",
"burger": 16,
"burgerColor": "hsl(91, 70%, 50%)",
"sandwich": 110,
"sandwichColor": "hsl(285, 70%, 50%)",
"kebab": 136,
@kronaemmanuel
kronaemmanuel / chart.js
Created June 21, 2020 12:36
Nivo chart POST request handler
const storage = require('./storage')
const uuid = require('uuid')
const express = require('express')
const server = express()
server.post('/chart', (req, res) => {
// Get all the data and parameters for the chart
const props = req.body
// Generate a random id for the chart
@kronaemmanuel
kronaemmanuel / storage.js
Created June 21, 2020 12:38
Nivo chart Storage
'use strict'
const store = {}
exports.set = (key, value) => {
store[key] = value
}
exports.get = key => {
return store[key]
@kronaemmanuel
kronaemmanuel / render.js
Created June 21, 2020 13:01
Nivo chart Render
const React = require('react')
const { renderToStaticMarkup } = require('react-dom/server')
const { Bar } = require('nivo')
const storage = require('../../utils/storage')
const theme = {}
const render = (props) => {
const rendered = renderToStaticMarkup(
React.createElement(
Bar,
@kronaemmanuel
kronaemmanuel / main.md
Last active September 14, 2020 20:19
Tor Project: OONI Explorer - Social Media Sharing

My goals

  • Better meta tags for OONI Explorer
  • og:image for both country and measurement pages
  • Share button to share measurements
  • Implement tests for all the components added
  • Research and improve SEO

What is done

  • Better meta tags for country pages implemented
  • PR merged
@kronaemmanuel
kronaemmanuel / twelve_days_of_xmas.rs
Last active February 14, 2021 14:46
Twelve Days of Christmas Poem on console with Rust
fn main() {
twelve_days_of_xmas();
}
fn twelve_days_of_xmas(){
let days = ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth"];
for (day_num, day) in days.iter().enumerate() {
println!("For the {} day of Christmas my true love sent to me", day);
@kronaemmanuel
kronaemmanuel / TwoBitAdder.py
Created May 19, 2021 09:12
Two Bit Adder Circuit With Qiskit
# We need 4 qubits for input, 7 for processing and 3 output bits
tba = QuantumCircuit(11, 3)
# Step 1: encode
# Here's how numbers are entered: E.g. 10 + 01 = 11
# q_0 = 0 and q_1 = 1 represent first number
# q_2 = 1 and q_3 = 0 represent second number
#tba.x(0) # For a=0, remove the this line. For a=1, leave it.
tba.x(1) # For b=0, remove the this line. For b=1, leave it.
tba.x(2) # For a=0, remove the this line. For a=1, leave it.
#tba.x(3) # For b=0, remove the this line. For b=1, leave it.
@kronaemmanuel
kronaemmanuel / system_setup.md
Last active September 27, 2021 12:20
System setup

How to setup my system

This guide is supposed to serve as a guide for me, so that I can quickly setup a system anytime I need to do so. I should probably turn all this into an shell install script so it will automatically set that up for me. Or maybe use smth like NixOS. But until I figure all that out, here are the instructions. Here I'm setting up a Pop_OS system. Even though I love the dark side of linux (Arch, manjaro, etc). I need the 'debian' stability for development.

  1. Install a Pop_OS iso image from a usb stick. I pretty much always have a bootable Pop_OS usb on hand.
  2. Download all available updates
  3. Download the following from Pop Shop:
    • Spotify
    • VSCode
    • Kitty terminal
  4. Install the snap store: