Skip to content

Instantly share code, notes, and snippets.

View jdiez17's full-sized avatar

José Manuel Díez jdiez17

View GitHub Profile
import React from "react";
import Plot from "react-plotly.js";
import SPESimulator from "../math/spe_sim"
export default class SolarPanelEfficiency extends React.Component {
constructor(props) {
super(props);
this.d_step = 0.5;
root@project:~# cat /service/hal/run
#!/bin/bash
echo "$(date): waiting for dependency1 to be up"
s6-svwait -u /service/dependency1
echo "$(date): starting hal"
exec 2>&1 /opt/ninox/hal
root@project:~# ps aux | grep s6
root 2684 0.0 0.1 1676 932 pts/2 S+ 12:58 0:00 s6-svscan /service
import requests
import re
url = "https://permanent-redirect.xyz/pages/1515222320"
body = None
while body is None or "301 Permanent Redirect" in body:
body = requests.get(url).text
if "500 Internal Server Error" in body:
print("Internal server error, continuing")
def day1(seq, cmp):
return functools.reduce(operator.add, map(lambda ic: int(ic[1]), filter(cmp, enumerate(seq))))
def day1_part1(seq):
return day1(seq, lambda ic: ic[1] == seq[ic[0]-1])
def day1_part2(seq):
return day1(seq, lambda ic: ic[1] == seq[(ic[0] + (len(seq) // 2)) % len(seq)])
use piece::Piece;
use coords::Coords;
#[derive(Debug)]
pub struct Move {
pub piece: Piece,
pub dst: Coords
}
#[derive(Debug)]
mod piece;
mod square;
mod sentence;
mod board;
mod coords;
use sentence::Sentence;
use board::Board;
use piece::Color;
use std::fmt;
use std::char;
#[derive(Debug, Clone, Copy)]
enum Piece {
King,
Queen,
Rook,
Bishop,
Knight,
import json
class Config:
def __init__(self):
self._path = None
self._config = {}
def open(self, path):
self._path = path
@jdiez17
jdiez17 / bson.rs
Last active December 29, 2016 21:10
use std::collections::HashMap;
use std::vec::Vec;
use std::iter::Iterator;
use std::str;
use byteorder::{ByteOrder, LittleEndian};
type SizeMap<'a> = HashMap<Vec<&'a str>, usize>;
fn element_size<'a, I>(path: I, bytes: &'a [u8]) -> (SizeMap<'a>, usize)
where I: IntoIterator<Item = &'a str> {
// ...
type SizeMap = HashMap<Vec<String>, u32>;
fn document_size(bytes: &[u8]) -> SizeMap {
// ...
}
#[cfg(test)]
mod tests {