Skip to content

Instantly share code, notes, and snippets.

View ORESoftware's full-sized avatar
🏐
Focusing

Alexander Mills ORESoftware

🏐
Focusing
View GitHub Profile
@ORESoftware
ORESoftware / main.gleam
Created February 25, 2024 08:18
Main gleamlang file
import gleam_cowboy
import gleam/http.{Request, Response}
import gleam/http/response.{ok}
pub fn main() {
gleam_cowboy.start(fn(_req: Request) {
ok("Hello, Gleam!")
}, on_port: 3000)
}
@ORESoftware
ORESoftware / pool.md
Last active January 17, 2024 20:36
goroutine reuse for logging purposes

Code looks fine to me. There might be a hidden race condition. The p.Count++ and p.Count-- are atomic ops. For every ++ it's corresponding -- should be called TBD.

package pool

import (
@ORESoftware
ORESoftware / resize-base64.js
Last active October 28, 2023 19:27
resizing an image on the front-end before sending to a server
// Using this code, we can retrieve an image from a user's filesystem, resize the image, and then upload the image
// to a server using AJAX. Because we use base64 encoding, we can just include the image data as just another string value
// in a JSON payload.
// So we can use AJAX to send the file to a server, which is convenient.
// We have one line of relevant html
// get file in the first place => <input type="file" custom-on-change="onAcqImageFileChange" class="form-control">
@ORESoftware
ORESoftware / git.commits.md
Created May 18, 2019 17:41
Removing old unneeded commits - saving disk space and making git clones faster

Say my git repo has 5,000 commits, how can I remove the first 4,000 commits that are quite old and no longer needed, in order to save disk space?

by Sebass van Boxel, Solutions Engineer at GitHub (2018-present)

First of all, I would try less destructive ways to clean up disk space in your git project. If you're collaborating on a repository with others, it's considered a bad practice to rewrite published history. If you’ve already decided that this is what you want to do, please skip the first part. One of the great powers of Git is that it preserves all history. Often you only realize that you really needed that history when it isn’t there anymore. For new people that join your project, it can be of great value to know what happened for what reason, by “removing” those old commits, they'll lose that context. My advice, before anything else, would be to run Git’s built-in housekeeping task:

@ORESoftware
ORESoftware / cleanup.md
Last active January 7, 2023 06:47
Cleanup docker artifacts/items

Clean up docker images/containers/volumes/networks

#!/usr/bin/env bash


set +e;

we can use this domain middleware

const Domain = require('domain');

app.use((req,res,next) => {
@ORESoftware
ORESoftware / fixed.js
Last active December 27, 2022 09:53
here is fix for code
const getBBBMeetingInfo = async (meetingID) => {
const getMeetingInfo = api.monitoring.getMeetingInfo(meetingID);
const result = await bbb.http(getMeetingInfo);
result.meetingID = meetingID;
if(result.returncode == 'FAILED'){
updateNotificationCallStatus(meetingID)
}

This is some bad code, but illustrates the difficulty, futility, and pointlessness of implementing map/filter with Iterables.

Note that these are lazy (not eager). Nothing runs until the for..of is called on an instance, etc.

class IterableWMapFilter<T> {

  vals : T[]= [];
@ORESoftware
ORESoftware / server.js
Last active December 23, 2022 22:23
basic node server
const http = require('http');
const server = http.createServer((request, response) => {
response.end(`
<html> hello world this is julian, here is an image: <br>
<img src="https://static.wikia.nocookie.net/history/images/6/6a/Classical_greece..jpg"></img>
</html>
@ORESoftware
ORESoftware / iterable-int.md
Created December 22, 2022 01:59
iterable int in javascript / typescript

this code does what you'd expect and useful for avoiding unnecessary arrays (although a standard for-loop is usually fine...)

export class IterableInt {

  point = 0;
  start: number = 0;
  end: number = 0;