Skip to content

Instantly share code, notes, and snippets.

View samg11's full-sized avatar
:octocat:
Focusing

Sam Girshovich samg11

:octocat:
Focusing
  • Harriton High School
  • 127.0.0.1
View GitHub Profile
@samg11
samg11 / secure_password_generator.py
Created November 11, 2022 13:22
Quickly generates a secure password in your terminal
import sys
import random
def generate_password(length, no_symbols=False):
chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
if not no_symbols:
chars += '~!@#$%^&*()_-+={[}]|:;<,>.?/'
@samg11
samg11 / scrollFromBottom.js
Created April 12, 2021 14:23
Chatre: get distance from bottom of scroll with jquery. Should console log distance from bottom when scrolling.
let scrollBarHeight;
// ONLY RUN WHEN SCROLLED TO BOTTOM
window.scrollBarHeight = (document.querySelector("#messages").scrollHeight) - ($("#messages").height() + $("#messages").scrollTop());
// END OF ONLY RUN WHEN SCROLLED TO BOTTOM
$("#messages").scroll(() => {
const a = document.querySelector("#messages").scrollHeight;
const b = $("#messages").height() * 2;
const c = $("#messages").height() - $("#messages").scrollTop();
@samg11
samg11 / index.html
Created February 25, 2021 16:17
Scoreboard
<div class="scoreboard">
<div class="score away">
<h3>14</h3>
<h5>Patriots</h5>
</div>
<div class="timeAndQuarter">
<h2>4th</h2>
<h3>4:43</h3>
</div>
@samg11
samg11 / index.jsx
Created February 22, 2021 23:38
express app with react frontend client
const React = require('react');
function Index(props) {
return <h1>Hello {props.name}!</h1>;
}
export default Index;
@samg11
samg11 / index.js
Created February 22, 2021 23:30
Express app with react
const express = require('express');
const app = express();
const PORT = process.env.PORT || 8080;
app.set('views', __dirname + '/views');
app.set('view engine', 'jsx');
app.engine('jsx', require('express-react-views').createEngine());
@samg11
samg11 / quadraticFormula.js
Created February 16, 2021 06:47
Solve With Quadratic Formula Javascript
export const quadraticFormula = (a,b,c) => ([
((-b)+Math.sqrt((b)**2-(4*a*c)))/(2*a),
((-b)-Math.sqrt((b)**2-(4*a*c)))/(2*a)
]);
@samg11
samg11 / sort.py
Created January 1, 2021 00:55
An implementation of bubble sort in python
def sort(arr):
arrLen = len(arr)
times_sorted = 0
for _ in range(arrLen):
for i in range(arrLen - times_sorted):
if i < arrLen-1:
if arr[i] > arr[i+1]:
a = arr[i]
b = arr[i+1]
arr[i] = b