Skip to content

Instantly share code, notes, and snippets.

View vadviktor's full-sized avatar
๐Ÿ€
Mining Ruby ๐Ÿ’Ž โ›๏ธ

Viktor (Ikon) VAD ๐Ÿ€ vadviktor

๐Ÿ€
Mining Ruby ๐Ÿ’Ž โ›๏ธ
View GitHub Profile
@vadviktor
vadviktor / gist:d888b13139c17dc0040add879264b313
Created April 25, 2018 06:32 — forked from thomas11/gist:2909362
Log memory usage every n seconds in Go #golang
import (
"runtime"
"time"
)
...
go func() {
for {
var m runtime.MemStats
@vadviktor
vadviktor / download.py
Created February 15, 2018 19:44
Downloading with Python "requests"
#!/usr/bin/env python3
import requests
import re
from os.path import basename
r = requests.get('http://www.nuclearlaunchdetected.com/')
links = set(re.findall(
r"http://s3\.amazonaws\.com/nuclearlaunchdetected/mp3/[a-z0-9\-_]+\.mp3",
r.text,
@vadviktor
vadviktor / compress.go
Created November 8, 2017 13:30 — forked from iamralch/compress.go
ZIP archives in Golang
import (
"archive/zip"
"io"
"os"
"path/filepath"
"strings"
)
func zipit(source, target string) error {
zipfile, err := os.Create(target)
@vadviktor
vadviktor / shell.sh
Created November 1, 2017 14:39
Crack a simple PDFs simple password (digits only)
pdfcrack -n 4 -m 4โ€‚โ€‚-c 0123456789 simple.pdf
@vadviktor
vadviktor / disable-ulps.go
Created September 9, 2017 21:10
Disable ULPS in Windows registry
package main
import (
"fmt"
"log"
"golang.org/x/sys/windows/registry"
)
const targetKey = "EnableUlps"
@vadviktor
vadviktor / JSON.js
Created July 25, 2017 17:12 — forked from mca-gif/JSON.js
JSON Data Extractor for the IntelliJ IDEA Platform
function eachWithIdx(iterable, f) { var i = iterable.iterator(); var idx = 0; while (i.hasNext()) f(i.next(), idx++); }
function mapEach(iterable, f) { var vs = []; eachWithIdx(iterable, function (i) { vs.push(f(i));}); return vs; }
OUT.append(JSON.stringify( mapEach(ROWS, function(row, row_idx) {
var r = {};
eachWithIdx(COLUMNS, function(col, col_idx) { r[ col.name() ] = row.value(col); });
return r;
})));
@vadviktor
vadviktor / waitforapt.md
Last active June 26, 2017 22:32
Ubuntu: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)

A very simple approach would be a script that waited for the lock to not be open. Let's call it waitforapt and stick it in /usr/local/bin. Then just run sudo waitforapt && sudo apt-get install whatever.

#!/bin/sh

while sudo fuser /var/lib/dpkg/lock >/dev/null 2>&1; do
   sleep 1
done
@vadviktor
vadviktor / split.sh
Last active April 21, 2017 09:30
Gather all mkv files that are above 800MB in size and split them into 500MB chunks with a suffix starting at ".00"
find ./ -type f -name "*.mkv" -size +800M -exec split --verbose -b 500M -a2 -d {} "{}." \;
@vadviktor
vadviktor / multiples_up_to.rb
Created January 16, 2017 16:19
Ruby generator producing multiples of a number up to a specified value
require 'pp'
def multiples_of_number_up_to(n, upto)
i = n
Enumerator.new do |y|
loop do
y << i
i += n
break if i >= upto
end
@vadviktor
vadviktor / multiple.rb
Created January 16, 2017 15:41
Ruby function using enumerator to get the multiples of a number
require 'pp'
def multiples_of(n)
i = n
Enumerator.new do |y|
loop do
y << i
i += n
end
end