Skip to content

Instantly share code, notes, and snippets.

View arjun-kava's full-sized avatar
🎯
Focusing

Arjun Kava arjun-kava

🎯
Focusing
View GitHub Profile
@arjun-kava
arjun-kava / 2019-https-localhost.md
Created September 3, 2020 13:15 — forked from cecilemuller/2019-https-localhost.md
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@arjun-kava
arjun-kava / nodejs-ubuntu-bind-port-80.md
Created July 30, 2020 12:51 — forked from guifromrio/nodejs-ubuntu-bind-port-80.md
Allow Node.js to bind to privileged ports without root access on Ubuntu

How to: Allow Node to bind to port 80 without sudo

TL;DR

Only do this if you understand the consequences: all node programs will be able to bind on ports < 1024

sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/node

Important: your node location may vary. Use which node to find it, or use it directly in the command:

@arjun-kava
arjun-kava / publish.sh
Created March 4, 2019 13:31
Script for publishing package on github
# script used to publish package to npm and push new tag
# step 1 - change version from package json
# step 2 - run ./scripts/publish-npm.sh $version i.e ./scripts/publish-npm.sh 0.0.3
set -e
if [ $# -eq 0 ]
then
echo "Please specify version."
exit
fi
mogrify -set comment 'Extraneous bytes removed' *.jpg
from keras.datasets import mnist
import cv2
import os
from tqdm import tqdm
from config import *
(x_train, y_train), (x_test, y_test) = mnist.load_data()
def extract(x,y,dir_path):
import { print, isSpecifiedScalarType, isSpecifiedDirective } from 'graphql';
export function printSchemaWithDirectives(schema) {
const str = Object
.keys(schema.getTypeMap())
.filter(k => !k.match(/^__/))
.reduce((accum, name) => {
const type = schema.getType(name);
return !isSpecifiedScalarType(type)
? accum += `${print(type.astNode)}\n`
#### KERAS ####
import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.3
set_session(tf.Session(config=config))
#### TF ####
config = tf.ConfigProto(
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.5),
@arjun-kava
arjun-kava / lstm_imdb.py
Last active August 19, 2018 06:22
Simple LSTM example using keras
from __future__ import print_function
from keras.preprocessing import sequence
from keras.models import Sequential
from keras.layers import Dense, Embedding
from keras.layers import LSTM
from keras.datasets import imdb
max_features = 20000
maxlen = 80 # cut texts after this number of words (among top max_features most common words)
# -*- coding: utf-8 -*-
"""ResNet50 model for Keras with fused intermediate layers
# Reference:
https://arxiv.org/pdf/1604.00133.pdf
Adapted from original resnet
"""
from __future__ import print_function
from __future__ import absolute_import
import warnings
@arjun-kava
arjun-kava / fee_gpu_memory_keras.py
Created August 14, 2018 05:36
Free GPU memory keras
from keras import backend as K
cfg = K.tf.ConfigProto()
cfg.gpu_options.allow_growth = True
K.set_session(K.tf.Session(config=cfg))
K.clear_session()