Skip to content

Instantly share code, notes, and snippets.

View mariot's full-sized avatar

Mariot Tsitoara mariot

View GitHub Profile
@mariot
mariot / ansible-macos-homebrew-packages.yml
Last active May 17, 2022 07:19 — forked from mrlesmithjr/ansible-macos-homebrew-packages.yml
Install MacOS Homebrew Packages With Ansible
---
- name: Install MacOS Packages
hosts: localhost
become: false
vars:
brew_cask_packages:
- docker
- firefox
- google-chrome
- iterm2
$ cargo run
Compiling shared-state v0.1.0 (file:///projects/shared-state)
error[E0382]: use of moved value: `compteur`
--> src/main.rs:9:36
|
5 | let compteur = Mutex::new(0);
| -------- move occurs because `compteur` has type `std::sync::Mutex<i32>`, which does not implement the `Copy` trait
...
9 | let manipulateur = thread::spawn(move || {
| ^^^^^^^ value moved into closure here, in previous iteration of loop
use std::sync::Mutex;
use std::thread;
fn main() {
let compteur = Mutex::new(0);
let mut manipulateurs = vec![];
for _ in 0..10 {
let manipulateur = thread::spawn(move || {
let mut nombre = compteur.lock().unwrap();

Docs

This is a project to test out rustdoc.

Here is a link!

Example

fn foo() -&gt; i32 {
@mariot
mariot / cargo run.sh
Created September 24, 2021 13:06
Erreurs d'ownership
$ cargo run
Compiling ownership v0.1.0 (file:///projects/ownership)
error[E0382]: borrow of moved value: `s1`
--> src/main.rs:5:28
|
2 | let s1 = String::from("hello");
| -- move occurs because `s1` has type `String`, which does not implement the `Copy` trait
3 | let s2 = s1;
| -- value moved here
4 |
@mariot
mariot / hello_rust.rs
Created September 24, 2021 13:03
Exemple ownership
fn main() {
let s1 = String::from("hello");
let s2 = s1;
println!("{}, world!", s1);
}
@mariot
mariot / bad.py
Created March 9, 2017 11:21
The good, the bad, the ugly
campaign_details = campaign_details_daily(args.get('campaign_id'), args.get('month'), args.get('year'), args.get('include_offline'))
final_output = []
ads = []
""" put each campaign details in an array """
for cd in campaign_details:
campaign_detail = CampaignDetail(cd.get("impressions"), cd.get("clicks"), cd.get("date"), cd.get("uniques"))
ads.append(AdBundle(cd.get("ad_id"), cd.get("ad_name"), cd.get("name"), campaign_detail))
""" divide the array by ad_id """