Skip to content

Instantly share code, notes, and snippets.

View sahuguet's full-sized avatar

Arnaud Sahuguet sahuguet

View GitHub Profile
@sahuguet
sahuguet / index.html
Created October 5, 2018 21:44
Vue.js Shopping Cart
<div class="main-wrapper">
<div class="header"><h1>Vue Shopping Cart</h1></div>
<div id="vue">
<cart :cart="cart" :cart-sub-total="cartSubTotal" :tax="tax" :cart-total="cartTotal" :checkout-bool="checkoutBool"></cart>
<products :cart="cart" :cart-sub-total="cartSubTotal" :tax="tax" :cart-total="cartTotal" :products-data="productsData"></products>
<checkout-area v-if="checkoutBool" :cart="cart" :tax="tax" :cart-sub-total="cartSubTotal" :cart-total="cartTotal" :products-data="productsData" :total-with-tax="totalWithTax"></checkout-area>
</div>
</div>
@sahuguet
sahuguet / poker.py
Created March 13, 2017 16:08
Code to enumerate poker hands with two pairs from 5 cards out of a 52 card deck
# Function that checks if 5 cards build a two-pairs hand
# A card is a number between 0 and 51.
# The value of a card is its number modulo 13.
# The suit of a card is its number div 4.
def is_two_pairs(c1, c2, c3, c4, c5):
assert len({c1, c2, c3, c4, c5}) == 5
counts = dict()
for i in (c1, c2, c3, c4, c5):
counts[i % 13] = counts.get(i % 13 , 0) + 1
return len(counts) == 3 and sorted(counts.values())[-1] == 2
@sahuguet
sahuguet / poker.rs
Last active March 13, 2017 19:54
Code to enumerate poker hands with two pairs from 5 cards out of a 52 card deck
use std::collections::HashMap;
fn is_two_pairs(c1: u32, c2: u32, c3: u32, c4: u32, c5: u32) -> bool {
let mut hand: HashMap<u32, u32> = HashMap::new();
*hand.entry(c1 % 13).or_insert(0) += 1;
*hand.entry(c2 % 13).or_insert(0) += 1;
*hand.entry(c3 % 13).or_insert(0) += 1;
*hand.entry(c4 % 13).or_insert(0) += 1;
*hand.entry(c5 % 13).or_insert(0) += 1;
if (hand.len() != 3) {
@sahuguet
sahuguet / cs5356-vagrant-fix.sh
Created August 24, 2016 15:10
Script to fix Vagrant ssh bug
mkdir -p /home/vagrant/.ssh
rm /home/vagrant/.ssh/*
wget --no-check-certificate https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys
chmod 0700 /home/vagrant/.ssh
chmod 0600 /home/vagrant/.ssh/authorized_keys
chown -R vagrant /home/vagrant/.ssh
# We define our solver.
solver = pywraplp.Solver('StudentProjectGridCBC', pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING)
# We define the set of assignments that represent a solution; each cell is either 0 or 1.
matches = {}
for student in STUDENTS:
for project in PROJECTS:
matches[student, project] = solver.IntVar(0, 1, 'matches[%s,%s]' % (student, project))
# We define the objective function we want to minimize.
Verifying that +sahuguet is my Bitcoin username. You can send me #bitcoin here: https://onename.io/sahuguet