Skip to content

Instantly share code, notes, and snippets.

View primaryobjects's full-sized avatar

Kory Becker primaryobjects

View GitHub Profile
@primaryobjects
primaryobjects / swap.py
Last active August 5, 2021 19:37
A quantum computing circuit to swap two bits in Qiskit.
def swap(b, a):
"""
A quantum circuit that swaps the input bits.
01 => 10
"""
swap = QuantumCircuit(2, 2)
if a:
swap.x(0)
if b:
@primaryobjects
primaryobjects / ghz.md
Created August 5, 2021 19:16
GHZ quantum circuit in Qiskit.

A GHZ quantum circuit is a quantum computing system that includes 3 entangled qubits.

A Greenberger–Horne–Zeilinger state (GHZ state) is a certain type of entangled quantum state that involves at least three subsystems.

Demo in IBM Quantum Composer.

@primaryobjects
primaryobjects / bell-states.py
Created August 2, 2021 02:55
Creating the four Bell states with quantum computing in Qiskit. https://quantumcomputing.stackexchange.com/a/2260
def four_bell_states():
"""
Create all 4 Bell states.
https://quantumcomputing.stackexchange.com/a/2260
"""
# [00, 11] positive
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
@primaryobjects
primaryobjects / logic.py
Created July 31, 2021 15:16
Quantum Computing logic gates for XOR, AND, NAND, OR using Qiskit.
from qiskit import qiskit, QuantumCircuit
def execute(func):
print('0 0: {}'.format(func(0, 0)))
print('0 1: {}'.format(func(0, 1)))
print('1 0: {}'.format(func(1, 0)))
print('1 1: {}'.format(func(1, 1)))
def xor(a, b):
"""
@primaryobjects
primaryobjects / quantum.py
Last active July 30, 2021 02:51
Qiskit hello world examples, introduction to quantum computing.
from warnings import simplefilter
from numpy import math
from qiskit import QuantumCircuit, qiskit, Aer
from qiskit.visualization import plot_bloch_multivector
from qiskit.circuit.quantumregister import QuantumRegister
import matplotlib.pyplot as plt
def problem1():
qc = QuantumCircuit(1, 1)
qc.ry(3 * math.pi / 4, 0)
@primaryobjects
primaryobjects / chrome-version.py
Last active March 22, 2024 12:04
Detect the version of Chrome installed on Windows, Linux, Mac. Cross-platform using Python, native OS detection, does not require Selenium.
#
# Programmatically detect the version of the Chrome web browser installed on the PC.
# Compatible with Windows, Mac, Linux.
# Written in Python.
# Uses native OS detection. Does not require Selenium nor the Chrome web driver.
#
import os
import re
from sys import platform
@primaryobjects
primaryobjects / twoStrings.js
Created July 15, 2021 01:35
Check if two strings contain a common substring https://www.hackerrank.com/challenges/two-strings
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
@primaryobjects
primaryobjects / Program.cs
Created July 3, 2021 20:21
Example C# .NET program using GitHub Copilot in VSCode.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
namespace test
{
class Program
{
private static int[] GenerateRandomList1(int size)
@primaryobjects
primaryobjects / squarespace-images.md
Last active June 21, 2024 07:11
How to Upload an Image to Squarespace CDN

How to Upload an Image to Squarespace CDN

  1. Create a new Blank Page in Squarespace.
  2. Add a section to the page and select Image Gallery.
  3. Drag and drop images into the image gallery upload control.
  4. Wait for all images to complete uploading and display in the image gallery control.
  5. Click Save.
  6. When the preview of the image gallery displays, right-click the image in Chrome and select Inspect.
  7. Copy the URL from the IMG tag. This is your static CDN link.
@primaryobjects
primaryobjects / spreadsheet.md
Last active June 27, 2021 18:32
How to load a Google Docs Spreadsheet in a web page using JQuery, Javascript, HTML.

How to Load a Google Spreadsheet as JSON in a Web Page with jQuery

  1. Create a spreadsheet in Google Drive.
  2. If you are using an Excel or .XLSX file, open the file and click File->Save as Google Sheets and then open the Google Sheets version of the file.
  3. Click File->Publish to the web.
  4. Click Publish and click OK.
  5. Close the publish dialog.
  6. Click File->Share.
  7. Under Get link click Change.