Skip to content

Instantly share code, notes, and snippets.

@marekyggdrasil
marekyggdrasil / README.md
Created February 4, 2019 09:19
How to fix Ruby TLS support

OSX Sierra version 10.12.6

if you are getting error like

ERROR:  Could not find a valid gem '<some package name>' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect retur

test your TLS v1.2 support

@marekyggdrasil
marekyggdrasil / run.py
Last active November 24, 2022 17:29
Simulation of the 1D Tight-Binding Model, full tutorial https://mareknarozniak.com/2020/05/07/tight-binding/
import matplotlib.pyplot as plt
import numpy as np
from qutip import basis
def _ket(n, N):
return basis(N, n)
def _bra(n, N):
@marekyggdrasil
marekyggdrasil / aqc.py
Last active October 2, 2018 04:43
Running AQC (Adiabatic Quantum Computation) on spin chain of size N=8 and N=2 for debugging. Printing probabilities of each sping configuration for N=8 in the middle of time evolution and for N=2 at the end of time evolution (for debugging).
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from qutip import *
from scipy import *
def operators(N) :
si = qeye(2)
@marekyggdrasil
marekyggdrasil / exampleDLX.py
Created September 28, 2018 10:59
There is a publicly available library for DLX algorithm (also known as 'Algorithm X' or 'Dancing Links' algorithm) available at https://pypi.org/project/dlx/, unfortunately it comes with no documentation, I needed it so I made couple of (dirty) wrapper functions to make it work and came up with this example. Hope you'll find it useful!
from dlx import DLX
def genInstance(labels, rows) :
columns = []
indices_l = {}
for i in range(len(labels)) :
label = labels[i]
indices_l[label] = i
columns.append(tuple([label,0]))
return labels, rows, columns, indices_l
@marekyggdrasil
marekyggdrasil / exampleDLX.py
Created September 28, 2018 10:58
There is a publicly available library for DLX algorithm (also known as 'Algorithm X' or 'Dancing Links' algorithm) available at https://pypi.org/project/dlx/
from dlx import DLX
def genInstance(labels, rows) :
columns = []
indices_l = {}
for i in range(len(labels)) :
label = labels[i]
indices_l[label] = i
columns.append(tuple([label,0]))
return labels, rows, columns, indices_l
@marekyggdrasil
marekyggdrasil / gen.py
Created September 18, 2018 01:31
Example how to read/write large files in incremental way using cPickle. Run `gen.py` to generate a file containing list of integers then use `read.py` to read this list incrementally from the file.
import cPickle as pickle
import io
lst = range(16)
with io.open('list.p', 'wb') as f :
pickler = pickle.Pickler(f)
for l in lst :
pickler.dump(l)
@marekyggdrasil
marekyggdrasil / el4.py
Created June 18, 2018 03:12
File that tests functionality of integral MathML parser for issue: https://github.com/allofphysicsgraph/graph/issues/7
from tools.ContentMathML import mml2sympy
from lxml import etree
xml = """
<apply>
<int/>
<bvar><ci>x</ci></bvar>
<lowlimit><cn>a</cn></lowlimit>
<uplimit><ci>b</ci></uplimit>
<apply>
@marekyggdrasil
marekyggdrasil / README.md
Last active August 12, 2017 08:25
This gist is a reference about different Gym agent algorithms that accept only Box as observation space. Here's the link https://discuss.openai.com/t/any-algorithms-compatible-with-observation-space-other-than-box/2276 to the thread, if you want to give feedback please write it there.
@marekyggdrasil
marekyggdrasil / lodash_find_gets_reference.js
Last active March 19, 2016 04:03
Does the lodash _.find returns reference to the object?
code:
console.log('socket.io', token);
console.log(realtime);
let session = yield _.find(realtime, function(data) {
return data.token === token;
});
console.log('session object to be set');
console.log(session);
if (!session.socket) {