Recent posteets

Sort by: Date / Title /

  1. 2 days ago by macks
    usando la libreria ffmpeg
    1. import commands
    2. import os
    3.  
    4. def execute():
    5.         cmd = 'c:/ffmpeg/ffmpeg.exe -y -itsoffset -4 -i c:/input.mpg -vframes 1 -s 100x90 -f image2 c:/uploads/img_gen.jpg'
    6.         #c = commands.getoutput(cmd) # linux
    7.         c = os.system(self.cmd) #windows
    8.         return c
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2058"></script>
  2. 2 days ago by macks
    1. def testImages(request):
    2.     from PIL import Image
    3.     path = ('c:/images/soluciones__1.jpg')
    4.     #content = 'c:/images/soluciones1.jpg'
    5.     content = 'c:/images/image.gif'
    6.     image = Image.open(content)
    7.     image.thumbnail((200,150), Image.ANTIALIAS)
    8.     image.save(path, image.format)
    9.     savelog(image.format)
    10.     del image
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2057"></script>
  3. 1 week ago by macks
    1. from django.db import load_backend, transaction, connection
    2.  
    3. #manipular datos de una bd externa
    4.  
    5. def sincronizeDB(self):
    6.         myBackend = load_backend('mysql') # or 'mysql', 'sqlite3', 'oracle'
    7.         myConnection = myBackend.DatabaseWrapper({
    8.             'DATABASE_HOST': '192.168.1.11',
    9.             'DATABASE_NAME': 'agenciaperu_local',
    10.             'DATABASE_OPTIONS': {},
    11.             'DATABASE_PASSWORD': "",
    12.             'DATABASE_PORT': "",
    13.             'DATABASE_USER': "root",})
    14.         # Now we can do all the standard raw sql stuff with myConnection.
    15.         myCursor = myConnection.cursor()       
    16.         id = 22
    17.         name = "tecnologia para jos"
    18.         slug = "tecnologia_para_jos"
    19.         row = myCursor.execute("INSERT INTO category(name, slug )  values(%s,%s);", [name, slug])
    20.         row = myConnection._commit()
    21.         #row = transaction.rollback_unless_managed()  -----> sería cuando trabajamos en local
    22.  
    23. # select simple
    24.         #row = myCursor.execute("select *from category where id = %s and highlight = %s;",[id,0])
    25.         myCursor.fetchall()
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2056"></script>
  4. sponsorised links
  5. 2 weeks ago by macks
    1. values = ['Enero','Enero','Enero','Febrero']
    2. print  [(x,values.count(x)) for x in set(values)]
    3.  
    4. ====>>[('Enero', 3), ('Febrero', 1)]
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2055"></script>
  6. 2 weeks ago by sm0k1nggnu
    1. <html>
    2. <head>
    3. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    4.  
    5. <title>Blog Posts</title>
    6. <style type="text/css">
    7. <!--
    8. .rss{
    9. width:200px;
    10. display:block;
    11. float:left;}
    12.  
    13. .rss h3 a{
    14. color:#89b81d}
    15.  
    16. -->
    17. </style>
    18. </head>
    19. <body>
    20. <h2>Foo</h2>
    21. <?php
    22.  
    23. $insideitem = false;
    24. $tag = "";
    25. $title = "";
    26. $description = "";
    27. $link = "";
    28. $i = 0;
    29.  
    30.  
    31. function startElement($parser, $name, $attrs) {
    32.         global $insideitem, $tag, $title, $description, $link;
    33.         if ($insideitem) {
    34.                 $tag = $name;
    35.         } elseif ($name == "ITEM") {
    36.                 $insideitem = true;
    37.         }
    38. }
    39.  
    40. function endElement($parser, $name) {
    41.         global $insideitem, $tag, $title, $description, $link,$i;
    42.        
    43.                 if ($name == "ITEM" && $i < 1) {
    44.                 printf("<div class="rss"><h3 class="rssHeader"><a href='%s'>%s</a></h3>", trim($link),utf8_decode(htmlspecialchars(trim($title))));
    45.                
    46.                 //Ohne Beschränkung
    47.                 //printf("<p>%s</p></div>",utf8_decode(htmlspecialchars(trim($description))));
    48.                
    49.                 //Mit Beschränkung
    50.                 $short = explode("n", wordwrap($description, 150, "n")); //Ausgabe auf n Zeichen kürzen
    51.                 printf("<p>%s ...</p><a href='".trim($link)."'>mehr</a></div>",htmlspecialchars(trim($short[0])));
    52.                
    53.                 $title = "";
    54.                 $description = "";
    55.                 $link = "";
    56.                 $insideitem = false;
    57.                 $i++;
    58.         }
    59. }
    60.  
    61.  
    62. function characterData($parser, $data) {
    63.         global $insideitem, $tag, $title, $description, $link;
    64.         if ($insideitem) {
    65.         switch ($tag) {
    66.                 case "TITLE":
    67.                 $title .= $data;
    68.                 break;
    69.                 case "DESCRIPTION":
    70.                 $description .= $data;
    71.                 break;
    72.                 case "LINK":
    73.                 $link .= $data;
    74.                 break;
    75.         }
    76.         }
    77. }
    78.  
    79. $xml_parser = xml_parser_create();
    80. xml_set_element_handler($xml_parser, "startElement", "endElement");
    81. xml_set_character_data_handler($xml_parser, "characterData");
    82. $fp = fopen("http://blogurl.com/rss.php","r")
    83.         or die("Error reading RSS data.");
    84. while ($data = fread($fp, 4096))
    85.         xml_parse($xml_parser, $data, feof($fp))
    86.                 or die(sprintf("XML error: %s at line %d",
    87.                         xml_error_string(xml_get_error_code($xml_parser)),
    88.                         xml_get_current_line_number($xml_parser)));
    89. fclose($fp);
    90. xml_parser_free($xml_parser);
    91.  
    92. ?>
    93. </body>
    94. </html>
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2054"></script>
  7. 3 weeks ago by cyo
    1. $videofile = "fichier.flv";
    2.  
    3. passthru("ffmpeg -i "{$videofile}" 2>&1");
    4. $duration = ob_get_contents();
    5.  
    6. $search='/Duration: (.*?),/';
    7. $duration=preg_match($search, $duration, $matches, PREG_OFFSET_CAPTURE, 3);
    8.  
    9. echo $matches[1][0];
    10.  
    11.  
    12. Pour récupérer la durée, en seconde, on peut utiliser cette fonction :
    13.  
    14. echo hms2sec($matches[1][0]);
    15.  
    16.  
    17. function hms2sec ($hms) {
    18.         list($h, $m, $s) = explode (":", $hms);
    19.         $seconds = 0;
    20.         $seconds += (intval($h) * 3600);
    21.         $seconds += (intval($m) * 60);
    22.         $seconds += (intval($s));
    23.         return $seconds;
    24. }
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2052"></script>
  8. 3 weeks ago by cyo
    1. 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>
  9. 3 weeks ago by benoitbalon
    1. # 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.
    2.  
    3. # 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...
    4.  
    5. 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>
  10. 4 weeks ago by stephanzr
    1. @font-face {
    2.  
    3.      font-family: Anivers;
    4.  
    5.      src: url(../fonts/Anivers.otf) format("opentype");
    6.  
    7. }
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2047"></script>
  11. 4 weeks ago by macks
    1. #template
    2. {% load humanize %}
    3. {{ my_num|intcomma }}
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2046"></script>

First / Previous / Next / Last / Page 1 of 26 (260 posteets)