>>> L = [0,10,20,40]
>>> L[::-1]
[40, 20, 10, 0]
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(9, 9))
# plot your data
fig.savefig('file.pdf', dpi=200)
I've found so far that figsize=(9, 9) and dpi=200 make a good compromise.
~/.config/sublime-text-2/Packages/Default/'Default (Linux).sublime-mousemap'
Add the following entry to the JSON data:
{ "button": "button8", "modifiers": [], "press_command": "save" }
The lateral mouse button is button number 8. In order to know what are the current button numbers, use the '''xev''' utility.
$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:git-core/ppa
$ sudo apt-get update
$ sudo apt-get install git
Next, confirm on the commandline that you are using the newer version:
$ git --version
git version 2.4.6
$ pandoc file.md | lynx -stdin
lynx is installed as the lynx-cur package
You need to install poppler-utils.
Use pdfimages a PDF image extractor tool that saves images from a PDF file to PPM, PBM or JPEG file(s) format.
Usage: pdfimages [options]
Example: Save images in JPEG format
$ pdfimages -j in.pdf /tmp/out
Will save images from PDF file in.pdf in files /tmp/out-000.jpg (or /tmp/out-000.pbm; see below), /tmp/out-001.jpg, etc.
Extracted from pdfimages man page.
-j: Normally, all images are written as PBM (for monochrome images) or PPM for non-monochrome images) files. With this option, images in DCT format are saved as JPEG files. All non-DCT images are saved in PBM/PPM format as usual.
EDIT: Notice that this trick applies to the extraction of raster images!
$ ffmpeg -i input -c:v libx264 -preset slow -crf 22 -c:a copy output.mkv
Note: ffmpeg must be compiled with x264 support. See this link for more info.
$ inkscape -f FILENAME.svg -e FILENAME.png
loads FILENAME.svg and exports it to FILENAME.png
$ inkscape -f FILENAME.svg -w WIDTH -h HEIGHT -e FILENAME.png
loads FILENAME.svg and exports it to FILENAME.png with width size, WIDTH, and height size, HEIGHT, in pixels
$ inkscape -f FILENAME.svg -A FILENAME.pdf
loads FILENAME.svg and exports it to FILENAME.pdf
$ inkscape -f FILENAME.svg -P FILENAME.ps
loads FILENAME.svg and exports it to FILENAME.ps
$ inkscape -f FILENAME.svg -E FILENAME.eps
loads FILENAME.svg and exports it to FILENAME.eps
$ sudo apt-get install texlive pstoedit
Alternatively, you can use the textext extension. It is similar to the build-in LaTeX support,
but has a slightly more polished input interface."
$ sudo add-apt-repository "deb http://archive.canonical.com/ trusty partner"
$ sudo apt-get update
$ sudo apt-get install adobe-flashplugin
$ pdftk book.pdf cat 51 output page.pdf
in this case, the page 51 from the file book.pdf is extracted into the file page.pdf
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
The fix is the same as the fix for the sound issues in Skype. For launching Audacity from the desktop do:
$ sudo sed -i 's/^Exec=.*/Exec=env PULSE_LATENCY_MSEC=30 audacity %U/' /usr/share/applications/audacity.desktop
for launching the program from the command line the hack is make the same than for skype, create a bash script to wrap the PULSE_LATENCY_MSEC variable only for audacity:
$ sudo bash
$ cd /usr/bin # here is audacity
$ cp audacity audacity.bin
$ pico audacity
once pico is opened, write the script:
#!/bin/bash
PULSE_LATENCY_MSEC=30
export PULSE_LATENCY_MSEC
/usr/bin/audacity.bin $@
then give it global execution permissions
$ chmod ugo+x audacity
#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for f in *
do
echo "$f"
done
IFS=$SAVEIFS
$ echo "My text" | convert -background black -fill white -font Ubuntu-Mono-Bold -pointsize 40 label:@- text.jpg
In order to check the available fonts for ImageMagik:
$ convert -list font
mysql> select STDEV_SAMP(precipitation_av) from p_year_averages where lon='-6.25' and lat='35.05';
ERROR 1548 (HY000): Cannot load from mysql.proc. The table is probably corrupted
Googling a bit, it seems that the fix is simple. In Ubuntu:
$ sudo mysql_upgrade -u root -p
It will ask your system password, then your Mysql password. Then the problem is gone.
# this is a comment
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
Note that these can be either relative or absolute paths. Then you can encode your files with:
$ ffmpeg -f concat -i mylist.txt -c copy output
$ rar a -m5 -v12m myarchive.rar movie.avi
if it is a directory:
$ rar a -m5 -v12m myarchive.rar dir/*
A list of files (myarchive.part1.rar, myarchive.part2.rar, ..) will be created in current directory.
You may change the compression quality, -m5 is the best and the slowest, while -m0 do no compression at all (-m3 is default).
Use -v4480m in order to get 4Gb chuncks (to put in a whole DVD each one)
$ sudo apt-get install libpulse0:i386
Once done this pulseuadio will be recognized, but the sound will be garbled the fix is
#!/bin/bash
PULSE_LATENCY_MSEC=60 skype.bin
$ sed -i 's/ugly/beautiful/g' /home/bruno/old-friends/sue.txt
Well, that command speaks for itself "sed" edits "-i in place ( on the spot ) and replaces the word "ugly with "beautiful" in the file "/home/bruno/old-friends/sue.txt"
$ sudo apt-get install pandoc
Then use it:
$ pandoc -f markdown -t docx fileIn.md -o fileOut.docx
c=1;
for q in `seq 1 11`;
do
echo $q;
montage giros-${c}.jpg giros-`echo $c + 1| bc`.jpg \
-geometry 2544x3508 - | convert - -resize 3508x2544 \
-rotate 90 join/`printf %02d $q`.jpg ;
let c=$c+2;
done;
The processed images will be in the join/ directory. Then, in order to create a sinlge pdf with all the images, use this python script:
#!/usr/bin/env python
import sys
import os
import glob
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter, A4
if len(sys.argv) < 1:
print "no args"
print "usage: this_script outfile.pdf"
exit
outpdf=sys.argv[1]
w, h = letter
c = canvas.Canvas(outpdf, pagesize=letter)
for filename in sorted(glob.glob("*jpg")):
s = c.drawImage( filename, 0,0, width=w, height=h, mask=None)
print "[", filename,"]"
c.showPage()
c.save()
~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml
find the line
<property name="<Super>Tab" type="string" value="switch_window_key"/>
and change it to
<property name="<Super>Tab" type="empty"/>
reboot or whatever and then tab will work properly!
I have no idea why but when using vnc this file seems to override tab's normal behaviour and makes it into a switch window key."
$ gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dGraphicsAlphaBits=4 -sOutputFile=page_%02d.png -r600 problem_file.ps
this creates png files at 600ppi (don't worry, due to the -r600 the document won't be pixelated). Then, the png are converted into pdfs:
$ convert page_01.png page_01.pdf
do this for each png generated by gs. Finally, assemble everything into a single pdf:
$ pdftk page_01.pdf page_02.pdf page_0n.pdf cat output fixed_file.pdf
$ mencoder "mf://*.JPG" -mf fps=30 -ovc x264 -vf scale=1980:1080 -o mymovie3.avi
$ sudo gedit /etc/sane.d/dll.conf
if the following two lines look like:
#epson
epson2
change them to:
epson
#epson2
Save, and re-open xsane.
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-jdk7-installer
UPDATE for java8/9:
$ sudo apt-get install oracle-java8-installer
michael$ echo > __main__.py "print 'Hello world'"
michael$ python __main__.py
Hello world
michael$ zip test.zip __main__.py
adding: __main__.py (stored 0%)
michael$ python test.zip
Hello world
UPDATE: Floris Bruynooghe notes in the comments that you can add a hash-bang line to a zipfile and make it executable:
$ cat > __main__.py
print('hi there')
^D
$ zip test.zip __main__.py
adding: __main__.py (stored 0%)
$ cat > hashbang.txt
#!/usr/bin/env python3.0
^D
$ cat hashbang.txt test.zip > my_exec
$ chmod +x my_exec
$ ./my_exec
hi there
$
$ sudo apt-get install latex-cjk-common
$ sudo apt-get install latex-cjk-japanese
A minimum document:
\documentclass{memoir}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK}{UTF8}{min}未練なく散も桜はさくら哉\end{CJK} \\
\begin{CJK}{UTF8}{maru}未練なく散も桜はさくら哉\end{CJK} \\
\begin{CJK}{UTF8}{goth}未練なく散も桜はさくら哉\end{CJK} \\
without regret \\
they fall and scatter\ldots \\
cherry blossoms
\end{document}
The min, maru, and goth selects the font. In order to write furigana (for children and begginers as me ;) ) use the ruby package:
\documentclass{memoir}
\usepackage{CJKutf8}
\usepackage[overlap,CJK]{ruby}
\begin{document}
%% I find the default \rubysep (-0.5ex) too tight, so
%% let's enlarge it a little.
\renewcommand\rubysep{-0.2ex}
\begin{CJK}{UTF8}{min}
イスキエルド\ruby{先生}{せんせい}は\ruby{私}{わたし}を\ruby{愛}{あい}して
\end{CJK}
\end{document}
Alternatively, xelatex can be used instead.
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Type: application/vnd.ms-excel"); //* Decent browsers only need
header("Content-Disposition: attachment; filename=coupons.xls" ); //* these two headers
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize("file.xls") );
readfile("file.xls");
$ mplayer -vo null -ao pcm:file=audio.wav video.avi
or
$ mplayer -vo null -vc null -ao pcm:fast -ao pcm:file=audio.wav video.avi
<?php
header(“Content-type: application/vnd.ms-excel”);
header(“Content-Disposition: attachment; filename=excel.xls”);
...
And it’s just that easy. If you open the page, you’ll see a download-window asking you where to place the file. The headers will tell your computer that it’s an Excel-file, which will parse your html-table (assuming you’ve written it without errors) and display it nicely.
rsync --verbose --progress --stats --recursive --times \
--perms --links --delete /path/to/origin /path/to/destination
$ mv skype skype.bin
Create in the same directory a new file called skype and put in it:
#!/bin/bash
LD_PRELOAD=/usr/lib32/libv4l/v4l1compat.so /usr/bin/skype.bin $@
Change the permissions to make it executable:
$ chmod ugo+x /usr/bin/skype
and voilà!
#!/bin/bash
a="MANUEL ARTURO IZQUIERDO"
l=`echo ${#a}-1 | bc`
for q in `seq 0 $l`
do
echo "|'''"${a:$q:1}"'''"
done
get the output:
|'''M'''
|'''A'''
|'''N'''
|'''U'''
|'''E'''
|'''L'''
|''' '''
|'''A'''
|'''R'''
|'''T'''
|'''U'''
|'''R'''
|'''O'''
|''' '''
|'''I'''
|'''Z'''
|'''Q'''
|'''U'''
|'''I'''
|'''E'''
|'''R'''
|'''D'''
|'''O'''
The access to the string goes in the form:
${varname:index:lenght}
$ mkntfs -L TRASTEOS -Q /dev/sdg1
Note: the partition must to have the fstype flag set to 7
$ scanimage --resolution 300 > scan.ppm
Imagemagick can be used to convert the output to jpeg:
$ scanimage --resolution 90 | convert - -quality 80% image.jpg
See the scanimage manpage for more info.
A20C3M1_precip_1930_Europe.ascii
A20C3M1_precip_1931_Europe.ascii
A20C3M1_precip_1932_Europe.ascii
A20C3M1_precip_1933_Europe.ascii
A20C3M1_precip_1934_Europe.ascii
A20C3M1_precip_1935_Europe.ascii
...
Each file had data like:
36.761, -15.000, 21.732, 12.170, 7.797, 23.551, 12.186, 19.196, 30.779, 27.348, 32.999, 31.810, 16.109, 17.105
39.296, -15.000, 84.459, 3.269, 5.787, 19.614, 19.731, 11.071, 25.962, 20.152, 20.350, 19.952, 9.661, 16.531
41.831, -15.000, 99.225, 0.090, 0.000, 9.166, 18.276, 0.000, 0.000, 0.000, 6.851, 31.107, 3.937, 19.640
44.366, -15.000, 64.088, 0.000, 0.000, 2.215, 7.657, 0.410, 0.000, 0.000, 6.258, 35.478, 0.388, 15.106
...
So I had a year series, a file for each year. Now inside the file I had a pair of coordinates (lat,lon) in the fist two columns denoting a "weather station". Then columns 3 to 14 marked a precipitation value for each month of that year.
My mission was to reformat this info in one file for each station, having the values in this layout:
STATION_[36.761,0.000].dat
1930 1 3676
1930 2 0
1930 3 6439
1930 4 7340
1930 5 5179
1930 6 5577
1930 7 6001
1930 8 5937
1930 9 7331
1930 10 3211
1930 11 2632
1930 12 9107
1931 1 3676
1931 2 0
1931 3 11038
1931 4 3409
1931 5 6754
1931 6 3821
1931 7 2231
1931 8 7168
1931 9 6209
1931 10 10026
1931 11 8913
1931 12 14465
1932 1 3676
1932 2 0
1932 3 9029
...
which is the input format for the SPI program. My mission was to use the program with the provided data, so I had to reformat the entire dataset. This bash script does the job (perhaps not very time-efficient, but effective!!)
#!/bin/bash
##########################################################################
## Reformats the precipitation dataset to SPI input format
## Manuel Arturo Izquierdo (c) 2011
## Run this script inside the directory with the origianl ascii files
##########################################################################
mkdir SPI_INPUT
header=1
# Use A20* for the A20C3M1 dataset
#for dataf in A20*
# Use HLG* for the HLGM15B dataset
for dataf in HLG*
do
year=`echo $dataf | cut -d'_' -f4` #use -f4 for HLG* , -f3 for A20*
year=`echo $year+1700 |bc` # HLG* only
{
echo "Year: $year"
while :
do
read a
if test "$a" == ""
then
break
fi
lon=`echo $a | cut -d',' -f1`
lat=`echo $a | cut -d',' -f2`
coord=`echo $lon$lat|cut -d' ' -f1`,`echo $lon$lat|cut -d' ' -f2`
station='STATION_['$coord'].dat'
if test "$header" -eq "1"
then
echo $station >> SPI_INPUT/$station
fi
for m in `seq 3 14`
do
let month=$m-2
aridity=`echo $a | cut -d',' -f$month`
aridity=`echo "(($aridity*100)+0.5)/1"| bc` #aridity x 100 and integer
echo "$year $month $aridity" >> SPI_INPUT/$station
done
done
} < $dataf
header=`echo $header+1|bc`
done
The script generates a collection of files STATION_[''lat'',''lon''].dat for each station, in the required format. I found the trick to convert from float to int using bc: http://www.alecjacobson.com/weblog/?p=256.
et voilà!!
import pyExcelerator as xl
def save_in_excel(headers,values):
#Open new workbook
mydoc=xl.Workbook()
#Add a worksheet
mysheet=mydoc.add_sheet("test")
#write headers
header_font=xl.Font() #make a font object
header_font.bold=True
header_font.underline=True
#font needs to be style actually
header_style = xl.XFStyle(); header_style.font = header_font
for col,value in enumerate(headers):
mysheet.write(0,col,value,header_style)
#write values and highlight those that match my criteria
highlighted_row_font=xl.Font() #no real highlighting available?
highlighted_row_font.bold=True
highlighted_row_font.colour_index=2 #2 is red,
highlighted_row_style = xl.XFStyle(); highlighted_row_style.font = highlighted_row_font
for row_num,row_values in enumerate(values):
row_num+=1 #start at row 1
if row_values[1]=='Manatee':
for col,value in enumerate(row_values):
#make Manatee's (sp) red
mysheet.write(row_num,col,value,highlighted_row_style)
else:
for col,value in enumerate(row_values):
#normal row
mysheet.write(row_num,col,value)
#save file
mydoc.save(r'testpyexel.xlt')
headers=['Date','Name','Localatity']
data=[
['June 11, 2006','Greg','San Jose'],
['June 11, 2006','Greg','San Jose'],
['June 11, 2006','Greg','San Jose'],
['June 11, 2006','Greg','San Jose'],
['June 11, 2006','Manatee','San Jose'],
['June 11, 2006','Greg','San Jose'],
['June 11, 2006','Manatee','San Jose'],
]
save_in_excel(headers,data)
$ sqlite3 database.sqlite
Then,
sqlite> .mode csv
sqlite> .import /path/to/csv/file.csv table_name
Alternatively, sqlite-manager can do the job as well.
import time
time.sleep(secs)
The argument may be a floating point number to indicate a more precise sleep time.
$ convert SLIDE_-01.ppm -resize 720x486\! pp.png
The \! is important.
import string
text = open(fname).read()
print string.count(text, 'the_string')
convert logo.png -monochrome monochrome.gif
$ for a in *; do convmv -f latin1 -t utf8 --notest "$a"; done
for a in *JPG;
do gm convert $a -rotate -90 -colorspace gray PPM:- | gm convert - -threshold $v CBR/${a%.JPG}.png;
echo $a;
done
gm stands for graphicmagick, which is a *faster* clone of Imagemagick
$v is a calibration value between 0 and 255 (in Imagemagick it spans between 0 and 65535 ).
rar a book_title.cbr *png
convert IMG_6454.JPG ppm:- > pp.ppm
-----
^----> that's the trick
convert IMG_6160.JPG -rotate -90 -level 35,60% -colorspace gray pp.jpg
from: http://magic.aladdin.cs.cmu.edu/2005/07/02/splitting-and-joining-pdfs-by-pdftk/
even better, use the pdfpages package in tex. as easy as:
\usepackage{pdfpages}
\includepdf[specify pages, mode, how many per page]{file.pdf}
pdflatex foo.tex
Trick source: http://ca.php.net/manual/en/function.header.php Example 1570.
If you want the user to be prompted to save the data you are sending, such as a generated PDF file, you can use the » Content-Disposition header to supply a recommended filename and force the browser to display the save dialog.
<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');
// The PDF source is in original.pdf
readfile('original.pdf');
?>
montage -title "item_tortero" -label "%f" -geometry 300x250+10+8 *jpg index.jpg
convert 15194.jpg -resize 200% -blur 3 - | convert - -scale 50% filter/15196.jpg
do the same a make the image brighter:
convert 15194.jpg -resize 200% -blur 3 -level 0,55% - | convert - -scale 50% filter/15197.jpg