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 autograd.numpy as np # Important: Use autograd's wrapped numpy | |
| from autograd import grad | |
| import matplotlib.pyplot as plt | |
| # ========================================== | |
| # 1. Dataset Preparation | |
| # ========================================== | |
| # Represent XOR Inputs as a Numpy array | |
| X = np.array([ | |
| [0,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
| pub struct Sprite <'a> { | |
| x: i32, | |
| y: i32, | |
| velocity: i32, | |
| pub object: Object <'a>, | |
| } | |
| impl <'a> Sprite <'a> { | |
| pub fn new(x: i32, y: i32, velocity: i32, object: Object<'a>) -> Sprite<'a>{ | |
| Self { |
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
| # get all lines between two timestamps in a log | |
| sed -n '/2012-08-20 11:34/,/2012-08-22 16:34/p' file |
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
| certbot delete --cert-name example.com |
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 seeAllEvt(myObj) { | |
| for(var key in myObj){ | |
| if(key.search('on') === 0) { | |
| myObj.addEventListener(key.slice(2), function (e) { | |
| console.log(e.currentTarget + " " + e.type); | |
| }); | |
| } | |
| } | |
| } |
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
| // hashmap example - for reference | |
| let mut sample: HashMap<String, i32> = HashMap::new(); | |
| sample.insert("one".to_string(), 1); | |
| sample.insert("two".to_string(), 2); | |
| sample.insert("three".to_string(), 3); | |
| sample.insert("four".to_string(), 4); | |
| for (key, value) in sample.iter() { | |
| println!("{} - {}", key, value); | |
| } |
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
| from pip._internal import main | |
| pkg = "numpy" # example | |
| main(['install', pkg]) |
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 | |
| split_fields = lambda addr: [int(f) for f in addr.split(".")] | |
| def check_subnet(prefix_addr: str, prefix_length: int, to_check: str): | |
| """ | |
| Determine if the IPv4 address to_check is within the given subnet | |
| :param prefix_addr: address prefix as shown in CIDR notation | |
| :param prefix_length: the number of bits in the network section |
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 | |
| def reduce2(func, ls): | |
| if len(ls) == 1: | |
| return ls[0] | |
| return func(reduce2(func, ls[:-1]), ls[-1]) | |
| # test | |
| testset = [1, 2, 3, 4, 5] |
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
| #!/bin/bash | |
| # identify all files larger that 1 GB | |
| find / -xdev -type f -size +1G -exec ls -lah {} \; |
NewerOlder