Skip to content

Instantly share code, notes, and snippets.

View tovask's full-sized avatar

Levente Kováts tovask

View GitHub Profile
@tovask
tovask / save_page_as_image.js
Last active December 6, 2017 08:15
simple javascript code to save the page as an image, using http://html2canvas.hertzen.com/ , no external script required (, designed to run from scratchpad/console)
var script = document.createElement('script');
script.onload = function () {
html2canvas(document.body, {
allowTaint: true,
//taintTest: false,
logging: true,
onrendered: function(canvas) {
var img = canvas.toDataURL("image/png"); // window.location.href = img.replace("image/png", "image/octet-stream");
var link = document.createElement("a");
link.download = "page.png";
@tovask
tovask / AoC2017-1.swift
Last active December 30, 2019 15:04
solutions for AdventOfCode2017 in Swift https://adventofcode.com/
func part1(digits: String){
//print("solving \(digits): \n\t",terminator: "")
let chars = digits.characters.map { String($0) }
var sum = 0
for i in stride(from: 0, to: chars.count, by: 1) {
if Int( chars[i] )! == Int( chars[ (i+1) % chars.count] )! {
//print( Int( chars[i] )! )
sum = sum + Int( chars[i] )!
}
}
@tovask
tovask / mininet_mptcp_setup.sh
Last active June 23, 2023 12:34
Setup an MPTCP test in mininet
# creating a virtual Ubuntu (14.04) on AWS EC2 (t2.micro)
# install MPTCP
sudo apt-key adv --keyserver hkp://keys.gnupg.net --recv-keys 379CE192D401AB61
sudo echo -e "\n\n# for MPTCP\ndeb https://dl.bintray.com/cpaasch/deb jessie main\n" >> /etc/apt/sources.list
sudo apt-get update
sudo apt-get install linux-mptcp
# reboot
sudo reboot
# verify
@tovask
tovask / android_control_with_adb_from_browser.php
Last active October 6, 2017 13:05
minimal php to access android touch inputs
<?php
if(!isset($_SERVER['REMOTE_ADDR']) || $_SERVER['SERVER_ADDR'] != $_SERVER['REMOTE_ADDR']){
// for security, deny access outside of localhost (comment it out if you want to allow control from outside)
exit();
}
//error_reporting(E_ALL);
//ini_set('display_errors', 1);
$adb_command = './adb';
@tovask
tovask / Controll_android_only_usb.md
Last active January 23, 2024 17:38
get controll over Samsung Galaxy S4 (GT-I9505, totally broken screen, USB debug NOT enabled) from linux with the help of CWM and adb

My friend give me an android phone (Samsung Galaxy S4 I9505XXUHPK2) because he didn't want to use it any more. It was a perfectly working modern device with only one problem: it's screen was broken. It usually happens to big touch screen phone, that their screen get crashes somehow, but their other functionalities keep working fine. So i was happy, that i got a fully functionalling phone, until he describe that broken screen means it's totally broken: no touch detection and no display! But unless this small drawback, it seem to be all right: it automatically connented to a known wifi and it's alarm clock also turned on sometimes. But yet the only response from it was a status led in the top-left corner (witch helped to detect if it's currently booting); the backlight of the menu and the back button (witch was the only way to find out, if i just turned on or off the screen); and the vibration (witch was also indicated a boot start (, or a new mess

@tovask
tovask / minify_css_same_values.php
Last active September 19, 2017 12:43
CSS minifier: additional functions to shorten some propertie's value
// https://github.com/matthiasmullie/minify
/**
* Merge same values to a shorter formula:
* 4 to 3, e.g.: "padding: 1px 2px 3px 2px" -> "padding: 1px 2px 3px"
* 3 to 2, e.g.: "padding: 1px 2px 1px" -> "padding: 1px 2px"
* 2 to 1, e.g.: "padding: 1px 1px" -> "padding: 1px"
* (if all the 4 values are the same, it will be shorten to 3, then to 2, then to 1. )
* Care about calc values too.
#!/usr/bin/python
import urllib
import json
ips = set() # store only unique values
log = open('log.csv','r').read().split('\r\n')
for record in log:
if len(record)==0: # last one
# https://github.com/lgandx/PoC/blob/master/SMBv3%20Tree%20Connect/Win10.py
# corrected for Python 3.4.3
import sys, struct, socketserver
from collections import OrderedDict
from datetime import datetime
from calendar import timegm
class Packet():
fields = OrderedDict([
#include <stdio.h>
int main(){
int i,a=0;
for( i=0; i<3; i++){
if(i%3)
if(i%2)
printf("%d\n", (a = a+=2) );
else
<?php
// kill boolean
// dbcolumn keeped
if($_SERVER['REQUEST_METHOD']=='POST'){
header('Content-Type: text/plain; charset=utf-8');
$csv = $_POST['csv'];
$csv = trim($csv); // cut whitespaces