Skip to content

Instantly share code, notes, and snippets.

View sai-prasanna's full-sized avatar
🤖
=42

Sai sai-prasanna

🤖
=42
View GitHub Profile
@sai-prasanna
sai-prasanna / collisionLSH.py
Created August 8, 2021 17:01 — forked from unrealwill/collisionLSH.py
Proof of Concept : generating collisions on a neural perceptual hash
import tensorflow as tf #We need tensorflow 2.x
import numpy as np
#The hashlength in bits
hashLength = 256
def buildModel():
#we can set the seed to simulate the fact that this network is known and doesn't change between runs
#tf.random.set_seed(42)
model = tf.keras.Sequential()
@sai-prasanna
sai-prasanna / install.sh
Last active April 10, 2020 23:14
Reverse Engineer SpaCy Patterns - Pattern Matching
pip install git+https://github.com/sai-prasanna/spacy-pattern-builder.git
pip install streamlit
python -m spacy download en # Or any other model you wish to use.
streamlit run streamlit_pattern_builder.py
@sai-prasanna
sai-prasanna / hub_batched.py
Last active July 18, 2021 17:52
Hub fairseq translate batched
from collections import namedtuple
from typing import Any, List, Iterator, Tuple
import torch
import copy
class FairseqHubInferer:
"""
import streamlit as st
import numpy as np
from lmproof.scorer import TransformerLMScorer
from lmproof.candidate_generators import (MatchedGenerator,
EnglishInflectedGenerator,
SpellCorrectGenerator)
@st.cache(ignore_hash=True)
def model():
@sai-prasanna
sai-prasanna / multiprocess_seq2seq.py
Last active February 26, 2020 09:25
Multiprocess seq2seq reader using pytorch Dataloader, Dataset.
import csv
from typing import Dict, Optional
import logging
import torch
import random
from collections import Counter
import numpy as np
from overrides import overrides
from torch.utils.data import Dataset, IterableDataset, DataLoader, DistributedSampler
@sai-prasanna
sai-prasanna / .dir-locals.el
Last active April 25, 2019 13:11
Make lsp autocomplete work in emacs over TRAMP
;; Put this in root directory of your project
;; Install pyls in the project environment
;; pip install python-language-server
((python-mode . ((eval . (progn (require 'lsp-mode)
(lsp-register-client
(make-lsp-client :new-connection (lsp-tramp-connection "~/miniconda3/envs/znlp/bin/pyls")
:major-modes '(python-mode)
:remote? t
:server-id 'remote-pyls))))
(eval . (setq lsp-clients-python-command '("~/miniconda3/envs/znlp/bin/pyls")))
@sai-prasanna
sai-prasanna / sentencepiece_tokenizer.py
Created August 4, 2018 15:05
SentencePiece AllenNLP
import os
import tempfile
import logging
import sentencepiece as spm
from typing import List
from overrides import overrides
from allennlp.common import Params
from allennlp.data.tokenizers.token import Token
from allennlp.data.tokenizers.tokenizer import Tokenizer
@sai-prasanna
sai-prasanna / develop_ios_legacy_xcode.sh
Created January 2, 2017 05:44
Allows you to run development builds in new versions of iOS from old XCode
#!/bin/bash
OLD_XCODE_PATH=${1:-/Applications/Xcode7.app}
NEW_XCODE_PATH=${2:-/Applications/Xcode.app}
IOS_NEW_VERSION=10
DEVICE_SUPPORT_PATH=Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
ln -s $NEW_XCODE_PATH/$DEVICE_SUPPORT_PATH/$IOS_NEW_VERSION.* $OLD_XCODE_PATH/$DEVICE_SUPPORT_PATH/
/**
* @providesModule PatientList
*/
import NavigationBar from 'react-native-navbar';
import NavigationButtons from 'NavigationButtons';
import React, { ListView, Navigator, StyleSheet, Text, TextInput, TouchableHighlight, View } from 'react-native';
import { connect } from 'react-redux/native'
@connect(state => ({
patients: state.patients
@sai-prasanna
sai-prasanna / UITableView.swift
Created July 23, 2015 06:00
Reload Tableview animation
extension UITableView {
func reloadDataAnimated(animated:Bool) {
reloadData()
if animated {
let animation = CATransition()
animation.type = kCATransitionPush
animation.subtype = kCATransitionFromBottom
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)