Skip to content

Instantly share code, notes, and snippets.

Alexander Rosenthal PantherHawk

Block or report user

Report or block PantherHawk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View HAALP.py
class UserHome(UserPagesMixin, ListView):
...
def post(self, request, *args, **kwargs):
print('----------we are in post------------')
if 'eshel' in request.POST:
if 'yes_eshel' in request.POST:
print("YES ESHEL")
instance = Settings.objects.get(pk=self.request.user)
@PantherHawk
PantherHawk / make-bank.sql
Created Oct 18, 2018
some sql to make a bank, just a way to save stuff
View make-bank.sql
drop table users;
drop table role;
create table role
(id number primary key not null,
is_admin number not null);
create table users
(name varchar(20) not null,
passhash nvarchar2(20) not null,
id number(19, 0) not null,
@PantherHawk
PantherHawk / App.js
Created Sep 27, 2018
Assessment for Tophat
View App.js
import React, { Component } from 'react';
import { imageSearch } from './api';
import './App.css';
const AppContext = React.createContext();
let timeOutId = 0;
export default class App extends Component {
constructor(props) {
super(props);
@PantherHawk
PantherHawk / archiving.md
Last active Jul 29, 2018
E-Mail Archiving Project 2018
View archiving.md

E-Mail Archiving for Outlook v.20x+ on Windows

Problem: Inbox Inundation

E-mail, like everything else, goes the way of entropy. Left unchecked, an inbox will bloat and create a categorization nightmare. Although wrangling Outlook into a seemly and organized file system may feel like a Sisyphean task, we will approach step by step.

  • Backup the Inbox
  • Clean the .pst file (waiting on SCANPST.exe)
  • Archive Inbox
  • Customize Outlook
  • Compact Archive folder
View linked-list-has-cycle.md

Requirements

Return true if a singly linked list has a loop.

Strategy

Use two pointers, the second moving twice the speed of the first, and see if the two pointers ever land on the same node.

Justification of strategy

Consider two runners on a track. The faster runner will lap the slower one. The faster runner in our case is a pointer incremented douple the incrementation of the slower pointer.
The edge case we have to account for is when the slow or the fast or the immediate child of the fast node is null.

Define Test Cases

let linkedList = new LinkedList();

View minimum-value-to-equal-array.md

Requirements

Given a list of integers, return the number of times it takes produce a list of equal integers by incrementing n - 1 elements by one.

Strategy

Maths!

Justification of strategy

The largest number in the list, x, is greater than or equal to the product of s, the smallest number, 1, the number we increment the smallest number by, and m, the number of times we increment, and the value we're after. ![equation](x <= 1 * m) Refactoring, we find that the product of m and the number of elements we increment equals the difference between the sum of all elements and the product of the largest element and the number of elements. ![equation](m*(n-1) = sum-x*n >= sum-(minNum+m)n)

View minimum-moves-to-equal-array.js
function minMoves(list) {
var sum = list.reduce((a, b) => a + b)
var minNum = Math.min(...list)
var n = list.length;
return sum-(minNum)*n
}
View min-stack.md

Requirements

Create a stack prototype with a method that returns the smallest value in constant time.

Strategy

Constructor has a push, pop, and get minimum value methods. Update the minimum value whenever we push or pop a value.

Justification of strategy

To get that sweet, sweet constant time look up for our minimum value, we have to compare the minimum value stored in our instance to any value we add, and then iterate through the stack to find a new smallest value whenever we pop.

Define test cases

  • push(3), push(2), getMin() should return 2
  • push(0 ... 500), getMin() should return 0
  • push(-2), push(-3), push(-5), pop(), getMin() should return -3
View Leet Code: min stack
var MinStack = function() {
this.stack = [];
this.min;
};
MinStack.prototype.push = function(x) {
this.stack.push(x);
if (!this.min && this.min !== 0) {
this.min = x;
} else if (x < this.min) {
View integer-to-roman-numeral.md

Requirements

Given a number, return the roman numeral.

Strategy

We're going back in time to the third century! Subtract the integer value of a roman numeral from the input value until the value is less than that the roman numeral value. Then move to the next roman numeral.

Justification of strategy

Roman numerals are just sums of particular integers. We want to find the sum created by the discrete number of integers provided by roman numerals. So we have to break the integer down, starting with our biggest building blocks. We only need to move to a smaller roman numeral if after dividing our input by the roman numeral there's a remainder. We handle the thousands, and then the hundreds, and finally the units. Once we find a value that is smaller or equal to our number, we will push the matching letter to our solution and subtract this value from our number.

Define test cases

  • intToRoman(123) should return "CXXIII"
You can’t perform that action at this time.