usando la libreria ffmpeg
import commands
import os
def execute():
cmd = 'c:/ffmpeg/ffmpeg.exe -y -itsoffset -4 -i c:/input.mpg -vframes 1 -s 100x90 -f image2 c:/uploads/img_gen.jpg'
#c = commands.getoutput(cmd) # linux
c = os.system(self.cmd) #windows
return c
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2058"></script>
def testImages(request):
from PIL import Image
path = ('c:/images/soluciones__1.jpg')
#content = 'c:/images/soluciones1.jpg'
content = 'c:/images/image.gif'
image = Image.open(content)
image.thumbnail((200,150), Image.ANTIALIAS)
image.save(path, image.format)
savelog(image.format)
del image
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2057"></script>
from django.db import load_backend, transaction, connection
#manipular datos de una bd externa
def sincronizeDB(self):
myBackend = load_backend('mysql') # or 'mysql', 'sqlite3', 'oracle'
myConnection = myBackend.DatabaseWrapper({
'DATABASE_HOST': '192.168.1.11',
'DATABASE_NAME': 'agenciaperu_local',
'DATABASE_OPTIONS': {},
'DATABASE_PASSWORD': "",
'DATABASE_PORT': "",
'DATABASE_USER': "root",})
# Now we can do all the standard raw sql stuff with myConnection.
myCursor = myConnection.cursor()
id = 22
name = "tecnologia para jos"
slug = "tecnologia_para_jos"
row = myCursor.execute("INSERT INTO category(name, slug ) values(%s,%s);", [name, slug])
row = myConnection._commit()
#row = transaction.rollback_unless_managed() -----> sería cuando trabajamos en local
# select simple
#row = myCursor.execute("select *from category where id = %s and highlight = %s;",[id,0])
myCursor.fetchall()
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2056"></script>
values = ['Enero','Enero','Enero','Febrero']
print [(x,values.count(x)) for x in set(values)]
====>>[('Enero', 3), ('Febrero', 1)]
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2055"></script>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Blog Posts</title>
<style type="text/css">
<!--
.rss{
width:200px;
display:block;
float:left;}
.rss h3 a{
color:#89b81d}
-->
</style>
</head>
<body>
<h2>Foo</h2>
<?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
$i = 0;
function startElement($parser, $name, $attrs) {
global $insideitem,
$tag,
$title,
$description,
$link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem,
$tag,
$title,
$description,
$link,
$i;
if ($name == "ITEM" && $i < 1) {
//Ohne Beschränkung
//printf("<p>%s</p></div>",utf8_decode(htmlspecialchars(trim($description))));
//Mit Beschränkung
$short =
explode("n",
wordwrap($description,
150,
"n"));
//Ausgabe auf n Zeichen kürzen
$title = "";
$description = "";
$link = "";
$insideitem = false;
$i++;
}
}
function characterData($parser, $data) {
global $insideitem,
$tag,
$title,
$description,
$link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$fp =
fopen("http://blogurl.com/rss.php",
"r")
or
die("Error reading RSS data.");
while ($data =
fread($fp,
4096))
?>
</body>
</html>
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2054"></script>
$videofile = "fichier.flv";
passthru("ffmpeg -i "{$videofile}" 2>&1");
$search='/Duration: (.*?),/';
$duration=
preg_match($search,
$duration,
$matches, PREG_OFFSET_CAPTURE,
3);
Pour récupérer la durée, en seconde, on peut utiliser cette fonction :
echo hms2sec
($matches[1][0]);
function hms2sec ($hms) {
$seconds = 0;
$seconds +=
(intval($h) *
3600);
$seconds +=
(intval($m) *
60);
return $seconds;
}
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2052"></script>
tar cvfz myproject.tgz --exclude='path/dir_to_exclude1' --exclude='path/dir_to_exclude2' myproject
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2049"></script>
# Pour une raison ou pour une autre, on peut avoir besoin de vérifier si la date du jour est le dernier jour du mois. Sauf que le dernier jour du mois peut être un 28, un 29, un 30 ou un 31.
# La commande date du projet GNU (ne fonctionne pas sur Solaris) permet de retourner une date autre que celle du jour. Il suffit alors de vérifier si "demain" sera le premier, et d'exécuter la commande de son choix en conséquence...
test `date +'%d' -d '1 day'` -eq "1" && echo "hello world"
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2048"></script>
@font-face {
font-family: Anivers;
src: url(../fonts/Anivers.otf) format("opentype");
}
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2047"></script>
#template
{% load humanize %}
{{ my_num|intcomma }}
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2046"></script>