Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 math import ceil, sqrt | |
def isprime(n): | |
for x in range(2, ceil(sqrt(n + 1))): | |
if n % x == 0: | |
return False | |
return True | |
This file contains 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 mod sync { | |
use crate::prelude::*; | |
use std::ops::{Deref, DerefMut}; | |
#[derive(Debug, Eq, PartialEq, Copy, Clone)] | |
pub enum DeferredState { | |
Created, | |
Pending, | |
Resolved, | |
Rejected, |
This file contains 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 torch | |
import torch.nn.functional as F | |
import numpy as np | |
def _grid(in_w, in_h, out_w, out_h, x_coerce,y_coerce): | |
result = np.zeros((out_h, out_w, 2), dtype=np.float64) | |
for j in range(out_h): | |
for i in range(out_w): | |
if i * (in_w - 1) % (out_w - 1) == 0: | |
tx = i * 2.0 / (out_w - 1) - 1 |
This file contains 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
# Usage: gdl <URL> <OUTPUT> | |
function gdl() { | |
URL=$1 | |
tmp_file=$(mktemp) | |
code=$(wget --save-cookies $tmp_file --keep-session-cookies --no-check-certificate $URL -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1/p') | |
echo $code | |
URL+="&confirm=$code" | |
wget --load-cookies $tmp_file $URL -O $2 | |
rm $tmp_file | |
} |
This file contains 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
""" | |
Created on Mon Jun 26 14:46:56 2017 | |
@author: luohao | |
Modified by Houjing Huang, 2017-12-22. | |
- This version accepts distance matrix instead of raw features. | |
- The difference of `/` division between python 2 and 3 is handled. | |
- numpy.float16 is replaced by numpy.float32 for numerical precision. | |
""" | |
""" |