View random_exercices.c
This file contains 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
#include <stdio.h> | |
#include <stdlib.h> | |
// Some answers to exercices that a friend has to do for his school that I did for fun | |
// SUM OF PARAM | |
int size_of_string(char * str) { | |
int l = 0; | |
while (str[l]) { |
View .block
This file contains 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
license: mit |
View main.rs
This file contains 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
use std::cmp::Ordering; | |
use std::io; | |
use rand::Rng; | |
use std::io::Write; | |
use std::format; | |
// My first program in rust to test the language | |
// Kept to laught at myself in several months | |
// Inspired from the guessing game of the Rust book |
View relaxedbinpacking.cpp
This file contains 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
// I was bored so I programmed the binpacking relaxed problem | |
#include <iostream> | |
#include <array> | |
#include <algorithm> | |
#include <functional> | |
struct Item { | |
unsigned int number; | |
unsigned int utility; | |
double weight; |
View filter.js
This file contains 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
// Today I discovered that we can write horrible code in Javascript thanks to the thisArg argument of Array.reduce.filter | |
function myFilter(e) { | |
if (e % 2) { | |
this.val += e; | |
} | |
return e % 3 == 0; | |
} | |
var arr = [1,2,3,4,5,6,7,8,9,10]; |
View FunctionAsTemplateParameter.cpp
This file contains 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
// "How to pass a function in a template parameter ?" | |
// (I wanted to pass a lambda but it is not possible) | |
// 2019-12-27 | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <array> |
View main.rs
This file contains 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
/// Code example of how to have mutable data in an object passed by ref | |
/// The use case of this snippet is to cache some computed data | |
use core::cell::RefCell; | |
struct Cat { | |
age: RefCell<Option<i32>> | |
} | |
View synchronize_sophia.sh
This file contains 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
#!/bin/bash | |
cd sophia_rs | |
git checkout master | |
git fetch pchampin | |
git rebase pchampin/master | |
git push | |
cd ../PRIWA/wasm_example/ | |
rm Cargo.lock | |
./run_server.sh reload |
View intvect.rs
This file contains 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
extern crate wasm_bindgen; | |
extern crate js_sys; | |
use wasm_bindgen::prelude::*; | |
use std::collections::BTreeSet; | |
#[wasm_bindgen] | |
pub struct IntVector { | |
values: Vec<i32> |
View idk.hpp
This file contains 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
template <bool try_lock_return> | |
class DebugMutex { | |
#ifdef DEBUG | |
private: std::mutex _mutex; | |
public: | |
void lock() { _mutex.lock(); } | |
void unlock() { _mutex.unlock(); } | |
bool try_lock() { return _mutex.try_lock(); } | |
#else | |
public: |
OlderNewer