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
# Replace String to int at line 33 | |
:33 s/String/int/ | |
# Replace String to int from line 33 to 40 | |
:33,40 s/String/int/ |
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 t5 | |
import tensorflow.compat.v1 as tf | |
tpu = tf.distribute.cluster_resolver.TPUClusterResolver("node-1") | |
tpu_address = tpu.get_master() | |
tf.disable_v2_behavior() | |
def data_gen(split, shuffle_files=False): | |
ds = tf.data.Dataset.from_tensor_slices(["foobar"]).repeat(100) |
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 math | |
import numpy as np | |
def original_mirror(x, direction=0, reverse=False): | |
"""Mirrors left to right or top to bottom as per the direction.""" | |
x_ = np.copy(x) | |
height, width = x.shape | |
if direction == 0: | |
half_break = math.ceil(height/2) | |
shift = height % 2 |
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 mmap | |
from cffi import FFI | |
""" | |
add.c | |
double add(double a, double b) { | |
return a+b | |
} | |
~$ gcc -O3 -c add.c | |
~$ objdump -d add.o |
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 gin | |
import jax | |
import jax.numpy as jnp | |
import haiku as hk | |
@gin.configurable | |
class Model(hk.Module): | |
def __init__(self, num_classes, name=None): | |
super().__init__(name=name) |
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 tensorflow as tf | |
def approach_1(): | |
def gen(): | |
l = ["foo", "bar", "baz"] | |
l1 = [f"{x}_py" for x in l] | |
l2 = [f"{x}_java" for x in l] | |
d1 = tf.data.Dataset.from_tensor_slices(l1) |
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 ast | |
import astor | |
class MyListComp(ast.ListComp): | |
def __init__(self, target, value): | |
self._target = target | |
self._value = value | |
class MySourceGenerator(astor.SourceGenerator): |
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
# https://www.tifr.res.in/~vahia/tithi-calculations.pdf | |
import datetime | |
from astropy.coordinates import get_body | |
from astropy.time import Time | |
from astropy.coordinates import EarthLocation | |
NUM_TITHIS = 15 | |
def get_tithi(timestamp, location): | |
sun = get_body('sun', timestamp, location) |
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
Copyright 2002 [email protected] | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH |
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
#[derive(Debug)] | |
struct Pipeline { | |
context: String, | |
} | |
impl Pipeline { | |
fn new(context: String) -> Pipeline { | |
Pipeline { | |
context: context, | |
} |