This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Getting Ruby above 1.8.7 up and running on Site 5 | |
| Start with http://kb.site5.com/ruby-on-rails/select-a-version-of-ruby-for-your-hosting-account/ is a little off | |
| For some reason - my .bashrc is not picked up - but I can just | |
| source .bashrc | |
| and that works then | |
| Check your Ruby is 1.9 something or 2.0 something | |
| Now you need to install bundler AFTER doing that | |
| verify your bundle command is now in ~/ruby/gems |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'mechanize' | |
| require 'logger' | |
| require 'json' | |
| ROOT = "http://www.kmdvalg.dk/main" | |
| def get_agent | |
| agent = Mechanize.new | |
| agent.log = Logger.new "mech.log" | |
| agent.user_agent_alias = 'Mac Safari' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"error": 42716.2954, "samples": 506, "value": [22.532806324110698], "label": "RM <= 6.94", "type": "split", "children": [{"error": 17317.3210, "samples": 430, "value": [19.93372093023257], "label": "LSTAT <= 14.40", "type": "split", "children": [{"error": 6632.2175, "samples": 255, "value": [23.349803921568636], "label": "DIS <= 1.38", "type": "split", "children": [{"error": 390.7280, "samples": 5, "value": [45.58], "label": "CRIM <= 10.59", "type": "split", "children": [{"error": 0.0000, "samples": 4, "value": [50.0], "label": "Leaf - 4", "type": "leaf"}, {"error": 0.0000, "samples": 1, "value": [27.9], "label": "Leaf - 5", "type": "leaf"}]}, {"error": 3721.1632, "samples": 250, "value": [22.90520000000001], "label": "RM <= 6.54", "type": "split", "children": [{"error": 1636.0675, "samples": 195, "value": [21.629743589743576], "label": "LSTAT <= 7.57", "type": "split", "children": [{"error": 129.6307, "samples": 43, "value": [23.969767441860473], "label": "TAX <= 222.50", "type": "split", "children": [{"err |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| c = {} | |
| def cached_collatz(n,c) | |
| c[1] = [1] | |
| i = n | |
| s = [] | |
| while c[i].nil? | |
| s.push(i) | |
| i = (i % 2 == 0 ? i/2 : 3*i+1) | |
| end | |
| while s.count > 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Let's implement turing machines in ruby arithemtic | |
| # we want to encode tape, state and position in a single integer and - given a turing machine - write | |
| # a function that emulates the turing machine. | |
| # We limit our selves to simple machines - 100 states tops, 100000 positions on the tape | |
| NSTATES = 100 | |
| NPOSITIONS=100000 | |
| # check for zero | |
| def d(x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import argparse | |
| import pandas as pd | |
| import mysql.connector | |
| from sqlalchemy import create_engine | |
| from string import Template | |
| import os | |
| import argparse | |
| parser = argparse.ArgumentParser() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/ruby | |
| require 'erb' | |
| require 'json' | |
| require 'yaml' | |
| require 'fileutils' | |
| @from = ARGV.shift || 'files' | |
| @to = ARGV.shift || 'dist' | |
| # definitions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class IntrospectBinding | |
| attr_accessor :binding, :evals | |
| def initialize(binding) | |
| @binding = binding | |
| @evals = [] | |
| end | |
| def eval(string, filename = '', lineno = 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env python | |
| # | |
| # Mixpanel, Inc. -- http://mixpanel.com/ | |
| # | |
| # Python API client library to consume mixpanel.com analytics data. | |
| # | |
| # Copyright 2010-2013 Mixpanel, Inc | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import pandas as pd | |
| import lda | |
| import lda.datasets | |
| from sklearn.feature_extraction.text import CountVectorizer | |
| def load_questions(): | |
| sheet = pd.read_excel('android_watch.xlsx') | |
| Qs = sheet['Question'] |