Skip to content

Instantly share code, notes, and snippets.

View guinslym's full-sized avatar

Guinslym guinslym

View GitHub Profile
@guinslym
guinslym / cal-heatmap-tester.markdown
Created August 17, 2018 20:12
cal-heatmap Tester
import os
import uuid
import sys
import glob
from pprint import pprint
import pandas as pd
# pip install python-slugify, pandas
from slugify import slugify, Slugify, UniqueSlugify
custom_slugify = UniqueSlugify()
from collections import OrderedDict
class Codebook():
def __init__(self, xmlns):
self.element_name = 'codeBook'
self.xmlns = xmlns
def toOderedDict(self):
return OrderedDict(
[('codeBook',
install.packages(c("forecast", "caTools", "MASS", "corrplot", "Metrics"))
library(forecast);
library(MASS);
library(caTools);
library(corrplot);
library(Metrics);
a = data(Boston)
rrcr <- cor(Boston)
import json
from pprint import pprint
from bs4 import BeautifulSoup
from docx import Document
from docx.shared import Inches
with open("cns-En4243-e-2012.xml", 'rb') as fp:
soup = BeautifulSoup(fp, "lxml")
vars = soup.find_all("var")
<?xml version='1.0' encoding='UTF-8'?>
<codeBook version="1.2.2" ID="EPA-71M0001-F-2017-septembre" xml-lang="en" xmlns="http://www.icpsr.umich.edu/DDI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.icpsr.umich.edu/DDI http://www.icpsr.umich.edu/DDI/Version1-2-2.xsd">
<docDscr>
<citation>
<titlStmt>
<titl>
Enquête sur la population active, septembre 2017 [Canada]
</titl>
<subTitl>
Enquête sur la population active, septembre 2017
@guinslym
guinslym / questions
Last active December 6, 2017 00:29
questions ddi
I want to be able to read and write some DDI file (an XML standard). My issue is in the implementation. Right now I am using BeautifulSoup4 to read and write. I was wondering if I should create a Class for each of the DDI element? Because following the XML Schema each of the XML element might have different attribute(s).
I feel that I over complicating the parser (or my mind is working too much :)
excerpt of one of the class...
class Survey:
def __init__(self, filename):
self.soup = self.parse_this_xml_file(filename)
@guinslym
guinslym / 1_nanobox_cli.sh
Created November 10, 2017 11:17 — forked from LeCoupa/1_nanobox_cli.sh
Nanobox Cheatsheet: CLI commands and Boxfile --> https://github.com/LeCoupa/awesome-cheatsheets
# *****************************************************************************
# UPDATED VERSION AVAILABLE HERE:
# https://github.com/LeCoupa/awesome-cheatsheets/blob/master/tools/nanobox_cli.sh
# *****************************************************************************
# *****************************************************************************
# LOCAL ENVIRONMENT
# *****************************************************************************
➜ ~ dmesg | tail -20
[ 1519.185525] ata2.00: ACPI cmd e3/00:1f:00:00:00:a0 (IDLE) succeeded
[ 1519.186298] ata2.00: ACPI cmd e3/00:02:00:00:00:a0 (IDLE) succeeded
[ 1519.186562] ata2.00: configured for UDMA/100
[ 1519.201823] ata1.00: ACPI cmd ef/02:00:00:00:00:a0 (SET FEATURES) succeeded
[ 1519.201827] ata1.00: ACPI cmd f5/00:00:00:00:00:a0 (SECURITY FREEZE LOCK) filtered out
[ 1519.211960] ata1.00: configured for UDMA/133
[ 1519.476326] psmouse serio1: synaptics: queried max coordinates: x [..5470], y [..4498]
[ 1519.567145] PM: resume of devices complete after 729.346 msecs
[ 1519.567623] PM: Finishing wakeup.