Here's a script to convert image so they can be displayed as 1x1 colored elements in htmlfrom PIL import Image
im = Image.open("image.jpg")
x = im.size[0]
y = im.size[1]
listo = []
w = 0
h = 0
pix = im.load()
for j in range(y):
for i in range(x):
listo.append( '#%02x%02x%02x' % (pix[i,j]))
width = int(input('Please enter width: ')) - 2
q = open('output.html', 'w')
for i in listo:
if w > width:
w = 0
h += 1
elif 'ffffff' in i:
w += 1
else:
q.write('<div style="position: absolute; left: {0}px; top: {1}px; width: 1px; height: 1px; background-color: {2};"></div>'.format(str(w), str(h), i))
w += 1
q.close()
And remember, 4chan is not thea place for bullying.
why not post this as a gist or something? there are things that you could update to make this script less susceptible to breaking.
also
>listo as variable name
ugh
> 1x1 colored elements in html
Were you the OP in that thread from awhile ago asking about that, or are you somebody who decided to make it for them?
>>57481606
Both
made a crappy little wrapper for apt, since i was tired of doing update, upgrade, clean, etc.
>>57481752
>what are aliases
>>57481764
it's a little function in a script that i added to my bin folder.
so just barely above an alias.
import time
print("""long cat is\n /\___/\\1 \n / \\2 \n | # # |3\n \ @ |4\n \ _|_ /5\n / \______6\n / _______ ___ \\7\n |_____ \ \__/8\n | \__/9\n | |10""")
count = 10
time.sleep(2.0)
while True:
count = count +1
if count > 8995:
break
print(" | |"+str(count))
print(" | |8996\n / \ 8997\n / ____ \ 8998\n | / \ |8999\n | | | |9000\n / | | \ 9001\n \__/ \__/)"+"Long!")
You have to have the requests module and openmpt123 (or any other MOD player) installed. Then, pure bliss.import requests
import subprocess
def save_module(): #Gets a module and saves it to audio_out
page_file = requests.get("http://lite.modarchive.org/index.php?request=view_by_random")
page = page_file.text
i = page.index("eid=") #We want to know the XXXXXXX and "eid=" is the closest unique string
mod = requests.get("http://api.modarchive.org/downloads.php?moduleid="+(page[i+4:page.index("#", i)]), stream=True)
with open("audio_out", "wb") as file:
for chunk in mod.iter_content():
file.write( chunk )
while(1):
save_module()
player = subprocess.call("openmpt123 audio_out",shell=False)
>>57481834
funny but ugly code
>>57481834
Get cancer and die
>>57481501
script to automatically scrape videos from my subscribed youtube channels and save them to my disk for later viewing#!/bin/env ruby
require 'json'
require 'uri'
require 'shellwords'
rate = "10M"
template = '/z/youtube/%(uploader)s/%(title)s-%(id)s.%(ext)s'
queue = JSON.parse(`notmuch show --format=json tag:rssqueue`)
queue.each do |thread|
msg = thread[0][0]
body = msg['body']
url = URI.extract(body[0]['content'])[1]
system "youtube-dl -r #{rate} -o #{Shellwords.escape template} #{Shellwords.escape url}"
system "notmuch tag -rssqueue +rss -- id:#{Shellwords.escape msg['id']}"
end
#!/usr/bin/env perl
# tmpx - extract archive to temp dir
use strict;
use warnings;
use autodie;
use File::Temp qw(tempdir);
use File::Path qw(remove_tree);
my $filename = $ARGV[0];
die "Usage: $0 <archive>\n" unless $filename and -e $filename;
open my $fp, "<:bytes", $filename;
read $fp, my $magic, 4;
close $fp;
$magic = unpack 'H8', $magic;
my $dir = tempdir() or die "Unable to create temporary directory\n";
my %signatures = (
"504b0304" => "unzip \'$filename\' -d $dir",
"52617221" => "unrar x \'$filename\' $dir",
"377abcaf" => "7z x \'$filename\' -o$dir", # untested
);
eval {
my $command = $signatures{$magic} or die "Unknown archive signature $magic\n";
system("$command > /dev/null"); die "Error $? running $command\n" if $?;
}; remove_tree($dir) and die $@ if $@;
print "$dir\n";
I use it to read manga, together with this shell script and my image viewer (meh):#!/bin/sh
tmpfolder=$(tmpx "$1")
if [ ! $? -eq 0 ]; then
echo "error running tmpx on $1"
exit 1
fi
find "$tmpfolder" -type f | sort -g | meh -list
rm -rf "$tmpfolder"
>>57481501
ran that on jpg
got
dan@cat:~/m$ ls *.jpg
mu.jpg
dan@cat:~/m$ ts
Traceback (most recent call last):
File "/home/dan/m/ts", line 16, in <module>
listo.append( '#%02x%02x%02x' % (pix[i,j]))
TypeError: not enough arguments for format string
user@cat:~/m$ ts
Traceback (most recent call last):
File "/home/user/m/ts", line 16, in <module>
listo.append( '#%02x%02x%02x' % (pix[i,j]))
TypeError: not enough arguments for format string
user@cat:~/m$
why