Skip to content

Instantly share code, notes, and snippets.

Ronie Uliana ruliana

Block or report user

Report or block ruliana

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ruliana
ruliana / wip.ss
Created Aug 9, 2019
Fighting scheme macros
View wip.ss
(define empty? null?)
(define empty '())
(define first car)
(define rest cdr)
(define (split2 item lst)
(let loop ([remaining lst]
[left empty])
(cond [(empty? remaining) (values (reverse left) empty)]
[(equal? item (first remaining)) (values (reverse left) (rest remaining))]
@ruliana
ruliana / power-let.ss
Created Aug 6, 2019
Scheme "power-let" exploring
View power-let.ss
(trace-define-syntax power-let
(syntax-rules (<-)
[(_ (v <- expr) rest ...) (let [(v expr)] (power-let rest ...))]
[(_ body0 body* ...) (begin body0 body* ...)]))
(define-syntax def
(syntax-rules ()
((_ (name args ...) body ...)
(define (name args ...)
(power-let body ...)))))
@ruliana
ruliana / word_game.js
Last active Aug 2, 2019
Making the "Preposition Game" a little better (still not there)
View word_game.js
function wordGame(words) {
let clicks = 0;
let correct = 0;
function updateScore() {
let score = document.querySelectorAll('.word-game-score-panel')[0];
if (clicks == 0) {
score.innerHTML = "The Preposition Game<br>Accuracy: 0%";
} else {
let accuracy = Math.round(correct / clicks * 100);
@ruliana
ruliana / preposition_game.js
Created Aug 1, 2019
Let's guess what's the correct preposition (on, at, in). Create as bookmarket with it :)
View preposition_game.js
function printSolution(element) {
let answer = element.getAttribute("data-answer");
let selectedOptions = Array.from(element.selectedOptions).map(e => e.text);
if (selectedOptions.includes(answer)) {
element.style.border = "2px solid green";
} else {
element.style.border = "2px solid red";
}
}
let prepositions = ["", "on", "at", "in"];
@ruliana
ruliana / svc_predict_vs_predict_proba.py
Created Nov 9, 2018
First part of predict vs predict_proba for SVC in Scikit-Learn
View svc_predict_vs_predict_proba.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from itertools import count
import re
import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler
from sklearn.cross_validation import train_test_split
from sklearn.svm import SVC
@ruliana
ruliana / simple-bootstrapping.py
Created Sep 5, 2018
Simple bootstrapping with numpy
View simple-bootstrapping.py
def bootstrap(np_array, func, n_samples=1000, size=None):
size = size if size else len(np_array)
return np.apply_along_axis(func, 1, np.random.choice(np_array, size=(n_samples, size)))
# Example use
bootstrap(some_array, np.mean)
@ruliana
ruliana / edit-distance.rkt
Last active Aug 2, 2018
String Edit Distance in Racket using recursion and caching (dynamic programming like, but still recursive)
View edit-distance.rkt
#lang racket
(module+ test
(require rackunit))
(module+ test
(check-equal? (editions "" "") empty)
(check-equal? (editions "a" "a") (list (op-match #\a)))
(check-equal? (editions "ab" "ab") (list (op-match #\a) (op-match #\b)))
(check-equal? (editions "a" "") (list (op-insert #\a)))
(check-equal? (editions "" "b") (list (op-delete #\b)))
@ruliana
ruliana / traffic.py
Created Jul 2, 2018
Nagel-Schreckenberg Traffic Simulation Cellular Automata
View traffic.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from itertools import takewhile
from random import random
MAX_VELOCITY = 5
def space():
return " "
@ruliana
ruliana / rubocop.yml
Created Jun 13, 2018
My basic rubocop configuration
View rubocop.yml
AllCops:
TargetRubyVersion: 2.4
DisplayCopNames: true
DisplayStyleGuide: true
Style/FrozenStringLiteralComment:
AutoCorrect: true
Style/RegexpLiteral:
Exclude:
@ruliana
ruliana / define-pattern-example-of-use.rkt
Last active Jan 12, 2018
Example of "define-pattern" use
View define-pattern-example-of-use.rkt
(define-pattern (inner a) (list a (... ...))) ; This line defines a new pattern
(define inner-lists (list (list 1 2) (list 3 4))) ; Same as (define inner-lists '((1 2) (3 4)))
(match inner-lists
[(inner (list _ x _ ...)) (printf "x = ~a\n" x)]) ; Matches inner lists, returns (2 4)
You can’t perform that action at this time.