cd /etc/systemd/system
sudo touch <name>.service
sudo vim <name>.service # Use your editor of choice
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::collections::VecDeque; | |
| #[derive(Debug)] | |
| enum Associativity { | |
| Left, | |
| Right, | |
| } | |
| #[derive(Debug, Clone, Copy)] | |
| pub enum Operator { |
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::ops::Sub; | |
| fn two_sum<'a, T>(numbers: &'a [T], target: &'a T) -> Option<(usize, usize)> | |
| where | |
| T: Ord, | |
| &'a T: Sub<Output = T>, | |
| { | |
| let mut indexed_numbers: Vec<_> = numbers.iter().enumerate().collect(); | |
| indexed_numbers.sort_unstable_by_key(|&(_, number)| number); |
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
| const LINE_SIZE: usize = 5; | |
| fn hexdump<T>(reference: &T) { | |
| let ptr = reference as *const T as *const u8; | |
| let type_size = size_of::<T>(); | |
| for line in (0..type_size).step_by(LINE_SIZE) { | |
| for byte_offset in line..(line + LINE_SIZE).min(type_size) { | |
| print!("{:02X} ", unsafe { *ptr.add(byte_offset) }); | |
| } |
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
| #include "vigenere.h" | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| int main() { | |
| struct vig_key_t *key = key_from_string("XMWUJBVYHXZ"); | |
| if (key == NULL) { | |
| fprintf(stderr, "key_from_string() error"); | |
| return EXIT_FAILURE; | |
| } |
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::time::Instant; | |
| mod hundred { | |
| pub fn solve(size: usize) -> Option<Matrix> { | |
| let goal = size.pow(2); | |
| // The matrix is linearized for better cache-efficiency | |
| let mut matrix = vec![0; goal]; | |
| let mut moves = vec![]; | |
| // Initial position in the center, the first move assigns the number 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
| # -*- coding: utf-8 -*- | |
| from timeit import Timer | |
| # from program01 import dumbothello | |
| # from chonji import dumbothello as chonji | |
| # from dangun import dumbothello as dangun | |
| # from dosan import dumbothello as dosan | |
| # from wonhyo import dumbothello as wonhyo | |
| # from yulgok import dumbothello as yulgok | |
| from joonggun import dumbothello as joonggun |
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
| async function load(sources, callback) { | |
| for (const src of sources) | |
| await new Promise( | |
| resolve => { | |
| const image = new Image(); | |
| image.onload = _ => resolve(src); | |
| image.src = src | |
| } | |
| ).then(src => callback(src)); | |
| } |
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
| #include <iostream> | |
| #include <bitset> | |
| using namespace std; | |
| int main() | |
| { | |
| int memory; | |
| cout << "Insert a value between 0 and 255: "; | |
| cin >> memory; |
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
| #include <iostream> | |
| #include <bitset> | |
| using namespace std; | |
| int main() | |
| { | |
| int memory; | |
| cout << "Insert a value between 0 and 255: "; | |
| cin >> memory; |
NewerOlder