Skip to content

Instantly share code, notes, and snippets.

Copyright 2002 jayendra0parmar@gmail.com
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
# 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)
import ast
import astor
class MyListComp(ast.ListComp):
def __init__(self, target, value):
self._target = target
self._value = value
class MySourceGenerator(astor.SourceGenerator):
@jayendra13
jayendra13 / datasets.py
Created January 10, 2022 15:24
Merging Two datasets
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)
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)
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
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
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)
# 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/
# To query which package contains my file if installed
dpkg-query -S ASTConsumer.h
libclang-6.0-dev: /usr/lib/llvm-6.0/include/clang/AST/ASTConsumer.h
# if not installed search here
https://packages.ubuntu.com/
# More general case
# https://www.ostechnix.com/find-package-provides-specific-file-linux/
# Arch Linux, Antergos, Manjaro Linux