Skip to content

Instantly share code, notes, and snippets.

Avatar

George Kastrinis gkastrinis

View GitHub Profile
View numbers.groovy
@groovy.transform.Canonical
class Candidate {
def result
def invalids = []
}
def brute(def list, def ok, def okInOrder, def candidates) {
def newCandidates = []
candidates.findResults { candidate ->
View hack1.md

Dionysis Zindros, March 2017 - Attack failed

Dionysis asked me whether I could help him with a simple python script he was working on. He claimed he was trying to get the plain text from a ciphertext, but he was getting a weird runtime error message.

He gave me a gist with the script and wnated to know if I could see something he was missing. He suggested I run the script and see the message myself.

@gkastrinis
gkastrinis / post3.md
Last active Jun 3, 2020
SSH Tunneling (a.k.a. Port Forwarding)
View post3.md

SSH Tunneling (a.k.a. Port Forwarding)

In general, SSH tunneling creates a secure connection between a local computer and a remote machine through which services can be relayed (the important part). Because the connection is encrypted, SSH tunneling is useful for transmitting information that uses an unencrypted protocol, such as IMAP, VNC, or IRC (the not-so-important part).

A case where I found this to be a useful technique was when I had a remote machine running a web server but because of various reasons (e.g. security concerns) there was no public open port available (that I could use). If such a port existed (e.g. 9876), I could simply access the web server from my favorite web browser just by providing the appropriate URL address (e.g. http://example.com:9876). But fortunately enough, I had SSH access to that remote machine.

This is how it works:

View hamming.c
#include <stdio.h>
#include <stdint.h>
#include <string.h>
void magic(char* str, int i, int changesLeft) {
if (changesLeft == 0) {
printf("%s\n", str);
return;
}
if (i < 0) return;
View ping_uoa.java
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
public class Main {
final static int SLEEP_TIME = 7;
public static void main(String[] args) {
@gkastrinis
gkastrinis / post2.md
Last active Nov 27, 2020
Tablet as second PC monitor
View post2.md

Tablet as second PC monitor

Lately I've been thinking about using my old nexus 7 (from 2012) as a second PC monitor.

I've read articles regarding android apps for this purpose as well as comments from Google Play. Some examples can be found here and here. Bottom line, you have to pay and most likely you will end up struggling with (huge?) lag and/or compatibility issues. I tried splashtop but it felt lacking in some way, it was just mirroring my main monitor and it was free just for the first 5 minutes.

@gkastrinis
gkastrinis / post1.md
Last active Jul 8, 2018
Unspecified (or undefined) behavior & sequence points in C++
View post1.md

Unspecified (or undefined) behavior & sequence points

Assume the following code snippet of test.cpp. Our goal was to read integers from stdin and map them to the order in which they first appeared in our input. Keep in mind this is just a test and probably there are better ways to implement the intended behavior of this cut-down version.

If we use g++ to compile our code we get the following output. This was not the output we were expecting.

@gkastrinis
gkastrinis / post0.md
Last active Nov 21, 2015
Hello World
View post0.md

Code blogging using GitHub gists

Every now and then I might find something interesting related to coding. I might spent some time doing some research, and maybe write about it in an email or in a post in a course-oriented forum. But in the end it is probably forgotten and should the need arises for me to mention my findings again, I have to do a great portion of the process again.

Recently, I thought about using GitHubGist as a blogging platform of some kind. They provide all the nice things you might be familiar with in GitHub, there is

You can’t perform that action at this time.