Skip to content

Instantly share code, notes, and snippets.

@ZiTAL
ZiTAL / mail.py
Created March 28, 2014 10:29
python send mail
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, re, smtplib
class Mail(object):
params = {}
server = {}
// first select start and end dates
var sum = 0;
var a = document.querySelectorAll('.bar-wrapper.single > ul > li > span > em');
var l = a.length;
for(var i=0;i<l;i++)
sum = sum + Math.round(a[i].childNodes[0].nodeValue);
window.alert(sum);
@ZiTAL
ZiTAL / bom.py
Last active August 29, 2015 14:01
Python: Remove BOM from UTF-8 files
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, os, re, binascii
if(len(sys.argv)<2):
print 'Errorea: Karpeta argumentu bidez sartu'
sys.exit()
else:
dir = sys.argv[1]
@ZiTAL
ZiTAL / gist:e03fb854f9925754d54b
Last active August 29, 2015 14:06
php file_get_contents from ftp
<?php
$a = tmpfile();
$metaData = stream_get_meta_data($a);
$ftp = ftp_connect('localhost', 21, 30);
ftp_login($ftp, 'zital', 'zital');
ftp_fget($ftp, $a, 'a.txt', FTP_BINARY, 0);
fseek($a, 0);
@ZiTAL
ZiTAL / rmdirr
Created October 1, 2014 10:38
php delete folders recursively
function rmdirr($folder)
{
$aDeny = array('.', '..');
$resources = scandir($folder);
foreach($resources as $r)
{
if(!in_array($r, $aDeny))
{
$tmp = $folder."/".$r;
if(is_dir($tmp))
@ZiTAL
ZiTAL / zitalbot.py
Created November 4, 2014 22:00
#zitalbot python twitter bot
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# requirements:
# pip install tweepy
import sys, re, tweepy
class Txio(object):
params = {}
@ZiTAL
ZiTAL / apt.sh
Last active August 29, 2015 14:08
debian apt
#!/bin/bash
# /usr/local/bin/apt
user=`whoami`
commands="apt-get clean; apt-get update; aptitude upgrade; aptitude dist-upgrade"
if [ $user != "root" ]; then
su root -c "${commands}"
else
eval $commands
fi
@ZiTAL
ZiTAL / index.html
Created November 7, 2014 09:56
pangramak egiteko programatxoa :D
<!DOCTYPE html>
<html>
<head>
<title>Pangramak</title>
<style type="text/css">
textarea
{
width: 90%;
min-height: 200px;
}
@ZiTAL
ZiTAL / ftp_raw_list.php
Created January 14, 2015 14:50
php: ftp raw list desglosea
<?php
$params = array
(
'host' => '127.0.0.1',
'port' => 21,
'user' => 'ftpuser',
'passwd' => 'ftpuser'
);
$conn_id = ftp_connect($params['host'], $params['port']);
$login_result = ftp_login($conn_id, $params['user'], $params['passwd']);
@ZiTAL
ZiTAL / validator.php
Last active August 29, 2015 14:14
php: html validator
<?php
/*
<!-- validator.txt content -->
<form action="archivo.php" method="get">
<input id="aa" type="text" name="nombre" value="buscar" />
<input id="dd" type="submit" value="buscar" />
</form>
*/
$text = file_get_contents('validator.txt');