Skip to content

Instantly share code, notes, and snippets.

View gregyjames's full-sized avatar
:octocat:
Available

Greg gregyjames

:octocat:
Available
View GitHub Profile
@gregyjames
gregyjames / tiny.dockerfile
Created December 24, 2023 11:24
Tiniest possible GO Docker image
FROM golang:alpine as golang
# Create appuser (only for scratch)
ENV USER=appuser
ENV UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
@gregyjames
gregyjames / mingo.dockerfile
Created December 23, 2023 21:10
Minimal size docker file for go
FROM golang:latest as golang
WORKDIR /app
COPY . .
RUN go mod download
RUN go mod verify
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /server .
We can't make this file beautiful and searchable because it's too large.
Customer,Item
1,citrus fruit
1,margarine
1,ready soups
1,semi-finished bread
2,coffee
2,tropical fruit
2,yogurt
3,whole milk
4,cream cheese
@gregyjames
gregyjames / main.cpp
Created August 19, 2020 20:28
Embed Python in C++
#include <iostream>
#include "Python.h"
int main()
{
//Initialize the python instance
Py_Initialize();
//Run a simple string
PyRun_SimpleString("from time import time,ctime\n"
import time
start = time.time()
# [OPERATION]
end = time.time()
exec_time = end-start
@gregyjames
gregyjames / pipeline.py
Created July 31, 2020 13:22 — forked from sampsyo/pipeline.py
multithreaded pipelines for Python coroutines
"""Simple but robust implementation of generator/coroutine-based
pipelines in Python. The pipelines may be run either sequentially
(single-threaded) or in parallel (one thread per pipeline stage).
This implementation supports pipeline bubbles (indications that the
processing for a certain item should abort). To use them, yield the
BUBBLE constant from any stage coroutine except the last.
In the parallel case, the implementation transparently handles thread
shutdown when the processing is complete and when a stage raises an
@gregyjames
gregyjames / clean.sh
Created October 31, 2019 08:19
Shell script to organize a folder based on file extension.
#!/bin/bash
#Get all files in the directory
for file in *
do
#Get the filenames and extensions
filename=$(basename -- "$file")
extension="${filename##*.}"
#If the file isn't the cleaning script
Perceptron <- function(data, learningRate) {
#Make the weights vector with 0s for each data coloumn
w <- c(rep(0, ncol(data) -1))
#The number of rows in the dataframe
n <- nrow(data)
#Get the labels from the dataframe
label <- data[ , 1]
#Get the data from from the dataframe
obs <- data[ , 2:ncol(data)]
#We start assuming that the data is misclassifies
#include <algorithm>
//Array to sort
int arr = []
//Get length of array
const int length = sizeof(arr)/sizeof(arr[0]);
int count = length;
bool swapped = false;
@gregyjames
gregyjames / queue.cpp
Created July 9, 2018 08:28 — forked from sudheesh001/queue.cpp
C++ implementation of queue
#include <iostream>
using namespace std;
template <class etype>
class queue
{
class qnode
{
public:
etype element;