Skip to content

Instantly share code, notes, and snippets.

View pbindustries's full-sized avatar
🎯

pbindustries

🎯
  • Blue Bite
  • Manhattan
View GitHub Profile
@pbindustries
pbindustries / index.js
Created June 24, 2018 17:25
Check that you have node and needed dependencies
/* Check for Node.js */
var IS_NODE = false;
if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
IS_NODE = true;
// Get dependencies
request = require("request");
jQuery = require("cheerio");
$ = require("cheerio");
_ = require("underscore");
#!/usr/bin/python3
"""
DESCRIPTION
Simple python script to import a csv into ElasticSearch. It can also update existing Elastic data if
only parameter --id-column is provided
HOW IT WORKS
The script creates an ElasticSearch API PUT request for
each row in your CSV. It is similar to running an bulk insert by:
$ curl -XPUT localhost:9200/_bulk -d '{index: "", type: ""}
@pbindustries
pbindustries / check-json.py
Created October 20, 2018 15:50
json-to-elasticsearch
es = Elasticsearch(
['localhost'],
port=9200
)
es = Elasticsearch(ES_CLUSTER)
with open("C:\ElasticSearch\shakespeare_6.0.json") as json_file:
json_docs = json.load(json_file)
es.bulk(ES_INDEX, ES_TYPE, json_docs)
import json
import csv
employee_parsed = json.loads(employee_data)
emp_data = employee_parsed['employee_details']
# open a file for writing
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.common.by import By
from bs4 import BeautifulSoup
from urllib.request import urlretrieve
import os
import tkinter.filedialog as tkFileDialog
import tkinter as Tkinter
import tkinter.constants as Tkconstants
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.common.by import By
from bs4 import BeautifulSoup
from urllib.request import urlretrieve
import os
import tkinter.filedialog as tkFileDialog
import tkinter as Tkinter
import tkinter.constants as Tkconstants
"scripts": {
"jshint:dist": "jshint src/js/*.js",
"jshint": "npm run jshint:dist",
"jscs": "jscs src/*.js",
"browserify": "browserify -s Validating -o ./dist/js/build.js ./lib/index.js",
"browsersync": "browser-sync start --server --files 'src/*'",
"uglify:dist": "uglify src/js/**/*.js > dist/js/script.min.js",
"uglify": "npm run uglify:dist",
"test": "mocha",
"clean:dist": "rm -rf dist",
import csv, json, sys
#if you are not using utf-8 files, remove the next line
sys.setdefaultencoding("UTF-8") #set the encode to utf8
#check if you pass the input file and output file
if sys.argv[1] is not None and sys.argv[2] is not None:
fileInput = sys.argv[1]
fileOutput = sys.argv[2]
inputFile = open(fileInput) #open json file
outputFile = open(fileOutput, 'w') #load csv file
data = json.load(inputFile) #load json content
#!/bin/bash
# my testing was done with LXD/LXC so I had to set this on my hypervisor
# sysctl -w vm.max_map_count=262144
# set elasticsearch cluster name:
ES_CLUSTER_NAME="myescluster"
# set elasticsearch nodes ip/dns that will be part of the elasticsearch cluster
ES_NODES='["10.0.0.2", "10.0.0.3"]'
@pbindustries
pbindustries / The Technical Interview Cheat Sheet.md
Created December 23, 2018 20:00 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.