Skip to content

Instantly share code, notes, and snippets.

@jtarang
jtarang / async_client.py
Last active September 6, 2019 04:51
Populate Cache on CDN for EpgReady
from aiohttp import ( ClientSession, TCPConnector)
from aiohttp.client_exceptions import ContentTypeError
from ssl import create_default_context
# allows us to customize the session with cert files
def custom_session(path_to_cert=None, custom_headers=None):
if path_to_cert:
try:
# with open | no need for importing `os` to do path.exists
@jtarang
jtarang / compareCars.go
Last active March 18, 2019 17:59
Go excercise compare cars
package main
import "fmt"
type CarSpecs struct {
horsepower int
torque int
}
type Car struct {
from random import randint
def pick_the_first_recurring(choices=None, tracker=None):
keep_going = True
while keep_going:
for _ in choices:
rr = choices[randint(0,len(choices))-1]
if rr in tracker:
keep_going = False
tracker[rr] += 1
#!/usr/bin/python
__author__ = "J_Hack92"
import requests
import json
from lxml import html
from re import sub as re
def try_except(arg_passed=None):
if arg_passed is not None:
try:
arg_passed['name'] # this will fail cause we passed in a string not a dict
except KeyError as e:
print('First Except: No key named {} was found'.format(e)) #
from requests import get
host = "https://jsonmock.hackerrank.com/api/movies/search/?Title={}"
proxies_dict = {
"http" : ""
}
def doGet(url=None, proxy=None):
@jtarang
jtarang / mac_installer.py
Created November 8, 2018 07:02
Creates a mac installer usb
from sys import argv
from glob import glob
from os import system
class usbCreator:
def __init__(self):
self.volumes = self.getVolumes()
self.installers = self.getInstallers()
self.selctedInstaller = None
class FileWriter():
def __init__(self):
print('runs asap')
self.filename = 'crap.txt'
def write2file(self, data):
with open(self.filename, 'w') as f:
f.write(data)
from flask import Flask
from flask import request
from flask import jsonify
app = Flask(__name__)
# Creates a user
class UserObject:
def __init__(self, name, username, password):
import tornado.ioloop
import tornado.web
import json
# Creates a user
class UserObject:
def __init__(self, name, username, password):
self.user = username
self.passwd = password