Skip to content

Instantly share code, notes, and snippets.

😶
No comments.

Marcin Laber mlask

😶
No comments.
Block or report user

Report or block mlask

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mlask
mlask / update_curl.sh
Last active May 25, 2017 — forked from fideloper/update_curl.sh
Update curl on Ubuntu 14.04
View update_curl.sh
#! /usr/bin/env bash
# Install any build dependencies needed for curl
sudo apt-get build-dep curl
# Get latest (as of Feb 25, 2016) libcurl
mkdri
cd ~/curl
wget https://curl.haxx.se/download/curl-7.54.0.tar.bz2
tar -xvjf curl-7.54.0.tar.bz2
@mlask
mlask / svn-changes
Created Jun 27, 2016
Export changed (and, optionally, uncommited) files from SVN repository
View svn-changes
#!/usr/bin/php
<?php
/**
* Options:
* -r rev_from:rev_to -- revision range to export
* -u username -- svn username (optional)
* -p password -- svn password (optional)
* -n -- export with uncommited files (optional)
*/
$opts = getopt('r:u:p:n');
@mlask
mlask / svn-sync
Last active May 23, 2017
SVN repository quick sync script
View svn-sync
#!/usr/bin/php
<?php
$status = shell_exec('svn status --non-interactive');
if (strlen(trim($status)) > 0)
{
$status = explode("\n", trim($status));
echo("Syncing repository...\n");
foreach ($status as $item)
{
if (preg_match('/^\?\s+(.*)(?<!CVS\/Entries\.Log)$/', $item, $match))
@mlask
mlask / pwz.php
Created Sep 23, 2014
Weryfikacja numeru PWZ
View pwz.php
<?php
function check_pwz_number ($number)
{
if (strlen($number) != 7 || preg_match('/^0+$/', $number)) return false;
$c = (int)$number[0];
$n = substr($number, 1);
$s = 0;
for ($i = 1; $i <= 6; $i ++) $s += (int)$n[$i - 1] * $i;
return ($s % 11) == $c ? true : false;
}
@mlask
mlask / dowod_osobisty.php
Created Sep 23, 2014
Weryfikacja numeru Dowodu Osobistego
View dowod_osobisty.php
<?php
function check_do_number ($number)
{
$t = 0;
$n = array();
$w = array(7, 3, 1);
if (!preg_match('/^([A-Z]+)(\d{1})(\d+)$/', strtoupper($number), $n)) return false;
foreach (str_split($n[1] . $n[3]) as $i => $l)
$t += $w[$i % 3] * (is_numeric($l) ? $l : (ord($l) - 55));
return ($t % 10) == (int)$n[2] ? true : false;
@mlask
mlask / regon.php
Created Sep 23, 2014
Weryfikacja numeru REGON
View regon.php
<?php
function check_regon_number ($number)
{
$w = array(7 => array(2, 3, 4, 5, 6, 7), 9 => array(8, 9, 2, 3, 4, 5, 6, 7), 14 => array(2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8));
if (!isset($w[$l = strlen($number = preg_replace('/[^0-9]/', '', $number))])) return false;
for ($s = $i = 0; $i < $l - 1; $i ++)
$s += $number[$i] * $w[$l][$i];
return $number[$l - 1] == (($s % 11) % 10);
}
@mlask
mlask / nip.php
Created Sep 23, 2014
Weryfikacja numeru NIP
View nip.php
<?php
function check_nip_number ($number)
{
$w = array(6, 5, 7, 2, 3, 4, 5, 6, 7);
if (($l = strlen($number = preg_replace('/[^0-9]/', '', $number))) !== count($w) + 1) return false;
for ($s = $i = 0; $i < $l - 1; $i ++)
$s += $number[$i] * $w[$i];
return (10 > ($c = ($s % 11))) && $number[$l - 1] == $c;
}
@mlask
mlask / pesel.php
Created Sep 23, 2014
Weryfikacja numeru PESEL
View pesel.php
<?php
function check_pesel_number ($number)
{
$w = array(1, 3, 7, 9, 1, 3, 7, 9, 1, 3);
if (($l = strlen($number = preg_replace('/[^0-9]/', '', $number))) !== count($w) + 1) return false;
for ($s = $i = 0; $i < $l - 1; $i ++)
$s += $number[$i] * $w[$i];
return $number[$l - 1] == ((10 - ($s % 10)) % 10);
}
You can’t perform that action at this time.