Skip to content

Instantly share code, notes, and snippets.

View mapmeld's full-sized avatar

Nick Doiron mapmeld

  • Chicago, IL
View GitHub Profile
@mapmeld
mapmeld / gpt2-pipeline.py
Last active August 12, 2019 19:43
SKLearn Pipeline with ELI5
from sklearn.pipeline import make_pipeline
from sklearn.feature_extraction.text import VectorizerMixin
import eli5
from eli5.lime import TextExplainer
# wrapping up my GPT-2 vectorizing code
class V(VectorizerMixin):
def fit (self, X, y=None):
return self
@mapmeld
mapmeld / gpt2.py
Created August 12, 2019 14:56
SKLearn with GPT-2
import torch
from pytorch_transformers import GPT2Tokenizer, GPT2Model
tokenizer = GPT2Tokenizer.from_pretrained('gpt2-medium')
model = GPT2Model.from_pretrained('gpt2-medium')
x = []
y = []
with torch.no_grad():
for line in datarows:
@mapmeld
mapmeld / po-to-json.js
Created February 12, 2019 06:03
Convert PO file to JSON (assumes no weird exceptions like escaped-double characters, newlines)
const fs = require('fs');
fs.readFile('./out-blockly-0-all_ig.po', (err, content) => {
if (err) {
throw err;
}
let structure = {
"@metadata": {
"authors": [
@mapmeld
mapmeld / qiskit-js-demo.js
Created August 8, 2018 06:15
QISkit-js-demo
const Cloud = require('@qiskit/cloud');
const cloud = new Cloud();
let API_KEY = '...';
// qasm
let circuit = 'include "qelib1.inc";qreg q[1];creg c[1];measure q -> c;';
cloud.login(API_KEY).then(() => {
  cloud.backends().then( async function (res) {
let job = await cloud.run(circuit, { backend: 'ibmqx4', engine: 'ibmqx4' });
@mapmeld
mapmeld / goal.cs
Created August 7, 2018 17:37
Q# sample
// Task 1.3. Sign flip: |+〉 to |-〉 and vice versa.
// Input: A qubit in state |ψ⟩ = α |0⟩ + β |1⟩.
// Goal: Change the qubit state to α |0⟩ - β |1⟩ (flip the sign of |1⟩ component of the superposition).
operation SignFlip (q : Qubit) : ()
{
body
{
Z(q);
}
adjoint self;
@mapmeld
mapmeld / mdrb.swift
Last active May 11, 2018 05:00
Mudaraba structure - part 1
Mudaraba :: (any) {
// the contract can be created by anyone
public init(bank: Address, business: Address, profitShare: Int) {
self.bank = bank
self.business = business
self.initialInvestmentBank = 0
self.initialInvestmentBiz = 0
self.started = false
self.profitShareBank = profitShare
}
@mapmeld
mapmeld / vr.md
Last active March 4, 2018 08:21
Video Game/VR from my dream

There was a VR game or something in my dream which I played in a giant real-world dome... it was actually unclear to me how much was in the game and how much was "real life" as it was a dream anyway... This was supposedly part of the backstory from the Thing in the Fantastic 4, but I heard some other superhero names and it is more like Alien.

The setting is a giant dome inside a spaceship where astronauts have been in hibernation during transport

Unfortunately these reptilian aliens invaded and you can see some of the dead alien and astronaut up in the dome.

Before the game starts, the reptilians have adapted to copy the appearance of people on the ship. You will have people and reptilian replicants awake from hibernation. You are in one position on the edge of the dome and snipe reptilians as they

@mapmeld
mapmeld / Burmese-Samples.md
Created January 1, 2018 13:19
Burmese Samples
  1. ကိုယ်တွင်း၌ အသုံးပြုခဲ့သည်။ ထို့ကြောင့် အခြား အရေးအသားများကို အခြားအရာဝတ္ထုတို့ကို ပြောင်းလဲလာခဲ့သည် ။ထို့ကြောင့် အခြားသော ကြောင့် ကျေးရွာသည် မြန်မာနိုင်ငံ အစောပိုင်းတွင် တွေ့ရှိခဲ့ကြသည်။အခြားသော အ ခြား ကြောင်းများကို ကျောက်ကြီးရောဂါ ပေးရန် အတွက် အခြား ကြောင်းကို အသုံးပြုကြသည့် ကျောက်ဆည်မြို့နှင့် ကျောက်စာများတွင် အသုံးပြုခြင်း ဖြစ်သည်။
  2. ကျောက်စာတွင် ပြုလုပ်ရန် အမိန့်တော် များ ရှိသေးသည်။ ထို့ကြောင့် အင်္ဂလိပ်စာပြများ အတွက် ပြန်ပေးသောအခါ အများအပြာ ရှိသည့် အချက်အလက် မျိုးမျာ အမျိုးအစားဖြစ်သည့် မြန်မာ နိုင်ငံတော်ကို ပထမဆုံး သတ်မှတ်ခဲ့သည်။ ထို့နောက် မိုင်းရိုးမြို့၌ မြန်မာနိုင်ငံတွင် အခြေအနေအရ ပြန်လည်ရှေးဟောင်း အသင်းအဖွဲ့ချုပ် ကို အသုံးပြုခဲ့ကြသော အမေရိကန်ပြည်ထောင်စုတို့ကို အမျိုးသားလွှတ်တော်အတွက် အသုံးပြုခဲ့သည်။ ထိုအချိန်တွင် အမေရိကန်ပြည်ထောင်စု၏ အမျိုးသား ကွန်မြူနစ်ပါတီ၏ အခွင့်အရေးများကို အမေရိကန်ပြည်ထောင်စု အမှတ် ၁ အရ အောက်ပါအတိုင်း ဖွဲ့စည်းခဲ့သည်။ ၁၉၅၉ ခုနှစ်၊ ဇွန်လ ၂၅ ရွ်နေ့တွင် ကေအိုင် အေအီ အီဂျစ်နိုင်ငံတွင် ပါဝင်ခဲ့သည်။ ၁၉၇၇ ခုနှစ်၊ ဧပြီလတွင် ဗကပဗေဒင်ပါတီက အီတလီနိုင်ငံတွင် ပြန်လည် ရောက်ရှိခဲ့သေးသည်။
@mapmeld
mapmeld / kiwix-strip-html.py
Created December 20, 2017 12:38
Kiwix Strip HTML script
# pip3 install pyquery
import os
from pyquery import PyQuery as pq
directory = './burmese-articles'
originalArticles = os.listdir(directory)
count = 0
total = len(originalArticles)
@mapmeld
mapmeld / tekstoj.py
Created December 20, 2017 12:37
Process Tekstoj XML for Neural Network
# pip3 install lxml
import os
from lxml import etree
directory = './tekstoj'
originalArticles = os.listdir(directory)
count = 0
total = len(originalArticles)