Skip to content

Instantly share code, notes, and snippets.

@ravyg
ravyg / DeleteNode.cpp
Last active April 18, 2021 16:06
C++ Leetcode
Node* deleteNode(Node* head, int val) {
if (head != NULL) {
Node* curr = head;
Node* prev = nullptr;
while(curr->val != val) {
prev = curr;
if (curr->next != nullptr) curr=curr->next;
else return nullptr;
}
if (prev != nullptr) prev->next = curr->next;
@ravyg
ravyg / dnn_ravyg.py
Last active February 15, 2017 16:56
[1,2,5 Layer] Deep Neural Network implementation NOTE: Use you own vector data [Read Comment to select number of layers]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Parts of this code have be taken from Dr.Calix's ITS520 Class at Purdue University.
# Co-Authored: Ravish Gupta
##########################################################
import csv
import warnings
import matplotlib.pyplot as plt
import tensorflow as tf
import numpy as np
@ravyg
ravyg / word2vec_tweets_preprocessor.py
Created February 8, 2017 06:18
Clean tweets json for tensorflow or gensim based word2vec plain text
# -*- coding: utf-8 -*-
import json
import re
import os
import nltk
input_file = open('<JSON FILE To INPUT>','r').readlines()
for line in input_file:
try:
tweet = json.loads(line)
@ravyg
ravyg / Terminal Commands
Last active May 25, 2018 16:05
General Unix Commands
# Find the number of line in a file type recuresively.
find . -name '*.php' | xargs wc -l
# Find occurence on on word say "carrot" in many files.
grep -ir carrot . | wc -l
# This helps in moving files so keep backup!!!
# Moves files with json extension from sub-folders recursively to single output folder.
find <parent/folders/subfolders> -type f -name '*.json' -exec mv -i {} <new/folder> \;
@ravyg
ravyg / Hadoop Commands
Last active November 12, 2016 02:57
Data Sciences Commands
# Command pipeline
# Non hadoop way using only linux commands.
cat data | map | sort | reduce
# some text to mapper.
echo "foo foo quux labs foo bar quux" | <dirto/>mapper.py
# Some text to mapper then sort and then reducer.
echo "foo foo quux labs foo bar quux" | <dirto/>mapper.py | sort-K1, 1 | <dirto/>reducer.py
# Doing with file.
cat myfilename.txt | <dirto/>mapper.py | sort-K1, 1 | <dirto/>reducer.py
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@ravyg
ravyg / Mongo commands
Last active January 22, 2017 15:20
AWS, Mongo, Dynamo Commands
# Importing a db with multiple bson files
# Note each bson is a collection.
mongorestore -d db_name path/
# To start db use:
mongo db_name
# To see collections use:
show collections
@ravyg
ravyg / README.md
Created November 19, 2015 18:18 — forked from lopezjurip/README.md
Write to NTFS on OSX Yosemite and El Capitan

Install Homebrew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Update Homebrew formulae:

brew update
@ravyg
ravyg / Handy DRUSH Commands
Last active August 29, 2015 14:06
Geek Lyrics!
VARIABLE SET:
drush vset --yes file_private_path <path-to-private-files> | drush vset --yes file_temporary_path <path-to-temporary-file> |
NOT NEEDED ADMIN AND NEEDED ADMIN MENU
drush dis admin -y | drush en admin_menu diff field_ui -y
DRUSH KICKSTART
drush dl [drupal-version]
drush si --db-url=mysql://[dbusername]:[dbpassword]@localhost/[dbname]
drush upwd admin --password=[MyEasyDevPassword]
@ravyg
ravyg / Drupal Theme Basics
Last active August 29, 2015 14:06
Drupal Theming Basics
- Knowing the ".info" files
Tell drupal about your theme.
- Playing with ".tpl.php" (Template) files
Place for your all HTML structure.
- Variables in ".tptl.php" files
Dynamic bits of content which is to be printed in your template file.
- Theme Functions overriding.