This file contains hidden or 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
Source | Emissions in grams per KWH | |
---|---|---|
BIOMASS | 230 | |
FOSSIL_GAS | 490 | |
FOSSIL_HARD_COAL | 820 | |
FOSSIL_OIL | 820 | |
HYDRO_PUMPED_STORAGE | 51 | |
HYDRO_RUN_OF_RIVER_AND_POUNDAGE | 24 | |
HYDRO_WATER_RESERVOIR | 24 | |
SOLAR | 27 | |
WASTE | 500 |
This file contains hidden or 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
import requests | |
import re | |
s = requests.Session() | |
s.headers.update({'User-Agent': 'M'}) | |
for n in range(91563, 91563+1000): | |
u = f'https://regards.monuments-nationaux.fr/fr/asset/id/{n}/x/idFeatureFrom/798/thumbIndex/0/mosaicCount/177/ajax/1/format/json' | |
h = s.get(u).json()['html'] | |
title = re.search('<h1 title="([^"]+)"', h).group(1) |
This file contains hidden or 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::fmt::Debug; | |
#[derive(Debug)] | |
struct S { | |
x: Option<u32>, | |
y: u32, | |
} | |
/// Generates a funtion named $field the returns the existing value for | |
/// $field in self if it's not None, and otherwise computes it in |
This file contains hidden or 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
""" | |
Solution to https://gist.github.com/lovasoa/a4efdd4f30cc0ee4cd9f0563fb7ec64e | |
execute with: | |
mkfifo fifo | |
python3 crack.py < fifo | python3 challenge.py | tee fifo | |
""" | |
password = "" | |
for i in range(64): |
This file contains hidden or 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
function exec(a,b){ | |
let pgm = document.body.innerText.split(',').map(x=>parseInt(x)); | |
pgm[1] = a; pgm[2] = b; | |
for(let p=0; ; p+= 4){ | |
if(pgm[p]==1) pgm[pgm[p+3]] = pgm[pgm[p+1]] + pgm[pgm[p+2]]; | |
else if(pgm[p]==2) pgm[pgm[p+3]] = pgm[pgm[p+1]] * pgm[pgm[p+2]]; | |
else if(pgm[p]==99) break; | |
else throw new Error("invalid opcode "+pgm[p]); | |
} | |
return pgm[0]; |
This file contains hidden or 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
#!/usr/bin/env python3 | |
import random | |
SECRET = ''.join(random.choice("0123456789") for i in range(64)) | |
class Sandbox: | |
def ask_age(self): | |
self.age = input("How old are you ? ") | |
self.width = input("How wide do you want the nice box to be ? ") |
This file contains hidden or 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
-- Run online at: https://repl.it/repls/WeeSlightExams | |
-- hackernews thread: https://news.ycombinator.com/item?id=21543377 | |
solve funcs = filter (matches funcs) (possibilities funcs) | |
matches funcs truths = truths == zipWith (($).($truths).flip) funcs [0..] | |
possibilities [] = [[]] | |
possibilities (x:xs) = concatMap (sequence [(True:), (False:)]) (possibilities xs) | |
all_of = ((and.).) | |
one_of = ((or.).) |
This file contains hidden or 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
function get_tile_counts(width, height, tile_width, tile_height, numtiles) { | |
var level_count = 0, level_widths=[], level_heights=[], level_tile_count=[], level_tile_count_x=[], level_tile_count_y=[]; | |
var imageW = width; | |
var imageH = height; | |
var tileWidth = tile_width; | |
var tileHeight = tile_height; | |
width = imageW; | |
height = imageH; | |
while (width > tileWidth || height > tileHeight) { |
This file contains hidden or 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
/* | |
compile with: | |
rustc -C target-cpu=native -C opt-level=3 -C inline-threshold=1 -O mul_add.rs | |
*/ | |
use std::env; | |
fn main(){ | |
use std::time::{Instant}; | |
let args: Vec<String> = env::args().collect(); | |
let n=args[1].parse::<usize>().unwrap(); |
This file contains hidden or 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
/*** | |
Tower of Hanoi solver. | |
https://en.wikipedia.org/wiki/Tower_of_Hanoi | |
Example : | |
``` | |
$ rustc hanoi.rs | |
$ ./hanoi 3 |