Skip to content

Instantly share code, notes, and snippets.

View kuczmama's full-sized avatar
🔥
Building Cool Stuff

Mark Kuczmarski kuczmama

🔥
Building Cool Stuff
View GitHub Profile
<!DOCTYPE html>
<!-- Replace your api_key, upload_preset, and cloud_name. For more information please see the blog post at -->
<html>
<body>
<script type="text/javascript">
let doUpload = () => {
var files = document.getElementById("myid").files;
var formData = new FormData();
for (file of files) {
formData.append('file', file);
@kuczmama
kuczmama / sha256.rb
Created August 6, 2018 23:14
What is sha 256
require 'digest'
database = ['123456', 'monkey', '1ljflkdjsiolk', 'abcdefghijk']
def sha256(digest)
Digest::SHA256.hexdigest(digest)
end
puts "unencrypted passwords"
puts database
@kuczmama
kuczmama / ubuntu-bootstrap.sh
Last active October 15, 2018 23:21
Install script to setup ubuntu 18.04
#/bin/bash
usage() { echo "The usage is"; }
while getopts ':h:u:p:r:' opt; do
case "${opt}" in
h) HOST=${OPTARG};;
u) UNAME=${OPTARG};;
p) PWORD=${OPTARG};;
r) RUBY_VERSION=${OPTARG};;
@kuczmama
kuczmama / markov_chain.rb
Last active May 16, 2019 03:23
n level markov chain to randomly generate text
class String
def blank?
self.nil? || self.empty?
end
def present?
!self.blank?
end
end
@kuczmama
kuczmama / schema.sh
Created May 21, 2019 03:03
Heroku to RDS migration script from single to multi-tenant
#/bin/sh
usage() { echo "Usage: $0 APP_NAME DESTINATION SCHEMA_NAME" 1>&2; exit 1; }
if [ "$#" -ne 3 ]; then
usage
fi
function pathParts() {
url=$1
@kuczmama
kuczmama / increase-swap.sh
Created October 3, 2019 05:37
Increase swap space in ubuntu 18.04
sudo fallocate -l 16G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
sudo mount -a
swapon -s
function connect() {
const URL = 'wss://localhost:8080';
const RECONNECT_DELAY = 1000;
const WAIT_FOR_NO_MESSAGE = 30000;
const handler = null;
var ws = new WebSocket(URL);
ws.onmessage = function(e) {
clearTimeout(handler);
setTimeout(() => ws.close(), WAIT_FOR_NO_MESSAGE);
# https://deeplizard.com/learn/video/0VCOG8IeVf8
import torch
import torch.nn as nn
import torch.nn.functional as F
import os.path
# Optimizer to update the weights
import torch.optim as optim
import torchvision
@kuczmama
kuczmama / decision_tree.rb
Last active March 5, 2020 12:11
A decision tree written in ruby
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'set'
require 'pry'
require 'csv'
require 'optparse'
require 'time'
@kuczmama
kuczmama / async-callbacks.js
Created June 14, 2020 10:57
Async Callbacks in javascript
function fetchSports(prefix, callback) {
console.log("prefix", prefix);
const sports = ["vikings", "vipers"];
setTimeout(() => callback(sports), 500);
}
function fetchNews(prefix, callback) {
const news = ["victory", "votes"];
setTimeout(() => {
callback(news);