Skip to content

Instantly share code, notes, and snippets.

@ZiTAL
ZiTAL / svn_revision.php
Created February 6, 2015 12:24
php: svn get revision files info
<?php
/*
su
aptitute install subversion
exit
*/
$params = array
(
'revision' => 100,
'user' => 'zital',
@ZiTAL
ZiTAL / pagination.php
Last active August 29, 2015 14:16
Pagination
<?php
function getPagination($page = 1, $amount = 10)
{
/*
1 -> 10 | 0 -> 9
2 -> 10 | 10 => 19
3 -> 10 | 20 => 29
4 -> 10 | 30 => 39
*/
$page = intval($page);
@ZiTAL
ZiTAL / bytes.js
Last active August 29, 2015 14:16
bytes converter
var bytes = 1028653056;
//var bytes = 28653056;
//var bytes = 1;
var types = ['Bytes', 'KiloBytes', 'MegaBytes', 'GigaBytes'];
var result;
var index;
for(var i=0;i<types.length;i++)
{
var z = 1;
@ZiTAL
ZiTAL / isValidDate.js
Created April 29, 2015 08:18
javascript: validate date
function isValidDate(data)
{
var m = data.match(/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})\ ([0-9]{2})\:([0-9]{2})\:([0-9]{2})$/);
if(m!=null)
{
var o =
{
d: m[1],
m: parseInt(m[2])-1,
Y: m[3],
@ZiTAL
ZiTAL / txio_random.py
Last active August 29, 2015 14:22
python: Twitterrera argazki aleatoidxuek idxeteko
#!/usr/bin/python2
# -*- coding: utf-8 -*-
#
# pip install TwitterAPI
from TwitterAPI import TwitterAPI
from os import path
from os import listdir
from random import randint
from sys import exit
@ZiTAL
ZiTAL / get_file_from_ftp.sh
Created June 12, 2015 14:18
bash: get file from ftp
#!/bin/bash
host='127.0.0.1'
user='user'
passwd='passwd'
local_folder='/home/projects/example/public_html/application/views/layout/heavymetal'
remote_folder='/public_html/application/views/layout/heavymetal'
file='heavymetal_eu.php'
@ZiTAL
ZiTAL / README.txt
Last active August 29, 2015 14:23
Ralink 148f:7601
# script-eri aldatu "_" "/" euren path-a jakitzeko
# gero github-etik proeiktue bajatu
cd /usr/src
git clone https://github.com/porjo/mt7601.git
# baimenak emon
chmod 755 /etc/init.d/ralink
chmod 755 /usr/local/sbin/ralink
@ZiTAL
ZiTAL / map.js
Last active August 29, 2015 14:27
// array guztiari funtzio bera aplikatzeko erabiliko dugu
var zenbakiak = [1, 2, 3];
// funtzioak parametro moduan array-aren balorea hartzen du (i)
var erantzuna = zenbakiak.map(function(i)
{
return i+1;
});
console.log(erantzuna);
// [ 2, 3, 4 ]
#!/bin/bash
host='127.0.0.1'
user='user'
pass='passwd'
local_folder='/home/projects/example/public_html/application/views/layout/home'
remote_folder='/public_html/application/views/layout/home'
file='home_eu.php'
@ZiTAL
ZiTAL / hm10.php
Last active October 15, 2015 12:17
php: get ibeacons address and distance from arduino's HM10 Bluetooth module
<?php
// HM10 Bluetooth arduino modules response example
$text = "OK+DISISOK+DISC:4C000215:74278BDAB64445208FOC720EAF059935:FFEOFFE1C5:78A5048CECAC:-0620K+DISC:4C000215:74278BDAB64445208F0C720EAf059935:FFFE0FFE1C5:78A50485AF2D:-0580K+DISCE";
//preg_match_all("/\+DISC\:([A-Z0-9]+\:[A-Z0-9]+\:[A-Z0-9]+\:[A-Z0-9]+)\:([A-Z0-9\-]+)/", $text, $m);
preg_match_all("/\+DISC\:(\w+\:\w+\:\w+\:\w+)\:([\w\-]+)/", $text, $m);
print_r($m);
// output