Skip to content

Instantly share code, notes, and snippets.

View ahojukka5's full-sized avatar

Jukka Aho ahojukka5

View GitHub Profile
import ctypes
import os
import subprocess
import tempfile
__code__ = """
#include <stdbool.h>
bool check(unsigned long long int n) {
int sum = 0;
@ahojukka5
ahojukka5 / README.md
Created February 24, 2021 10:02
Prosesseja, prosesseja
16:59 $ ps aux |grep main_static
jukka     686308  0.0  0.0   1072     8 pts/9    S+   17:00   0:00 ./main_static
jukka     686314  0.0  0.0   1072     8 pts/12   S+   17:01   0:00 ./main_static
jukka     686324  0.0  0.0  11572   740 pts/11   S+   17:01   0:00 grep --color=auto main_static
@ahojukka5
ahojukka5 / vector2.c
Last active February 21, 2021 15:51
ccall julia
#include <stdlib.h>
#include <stdio.h>
// gcc -shared -o vector2.so vector2.c
typedef struct Vec {
long int length;
double* data;
} Vec;
@ahojukka5
ahojukka5 / surffailija.py
Last active February 8, 2021 07:19
Satunnainen surffailija surffailee netissä miljoona kertaa
import random
random.seed(0)
# Mille sivuille voi päätyä miltäkin sivulta
G = {
"A": ("B", "C", "D"),
"B": ("C", "D"),
"C": ("A",),
"D": ("A", "C")
}
@ahojukka5
ahojukka5 / docker-image-size-comparison.md
Created January 3, 2021 16:31
Docker file sizes with different strategies

Docker file sizes

Test image is alpine, size of image is 5.58MB.

Version 1

FROM alpine

RUN dd if=/dev/zero of=output1.data bs=10M count=1
import React from 'react';
import ReactDOM from 'react-dom';
function App() {
return <div className="App">Hello, world!</div>;
}
ReactDOM.render(
<React.StrictMode>
<App />
03:28 $ docker history ahojukka5/cli-tools:latest
IMAGE CREATED CREATED BY SIZE COMMENT
793390336ae7 2 hours ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
ba5ab62aafdc 2 hours ago /bin/sh -c adduser -D -s /bin/bash -h /wrk j… 4.64kB
c1e51627beaa 2 hours ago /bin/sh -c npm install -g @aws-amplify/cli 545MB
0af384189c12 2 hours ago /bin/sh -c pip install awsebcli 100MB
053a92423510 2 hours ago /bin/sh -c apk add openssl-dev 2.05MB
16b5466140ae 2 hours ago /bin/sh -c apk add libffi libffi-dev 5.49MB
7bfa201ac375 2 hours ago /bin/sh -c gem install travis 11.5MB
88e5bee6bb78 2 hours ago /bin/sh -c apk add make 843kB
#!/bin/bash
expose() {
REMOTE_HOST=lakka.kapsi.fi
declare -A REMOTE_PORTS
REMOTE_PORTS=(
["jukka.kapsi.fi"]=52400
)
if [[ -z "$1" ]] || [[ -z "$2" ]]
then
@ahojukka5
ahojukka5 / test.py
Created October 11, 2020 16:31
Testing function with stdin and stdout
from io import StringIO
def adding():
x = int(input('Anna luku 1'))
y = int(input('Anna luku 2'))
print("Summa on %d" % (x + y))
def test_adding(monkeypatch, capsys):

Testiä pukkaa!

def f(x):
  print("Hello world!")
SELECT
 name