Skip to content

Instantly share code, notes, and snippets.

@nokimaro
nokimaro / weather.md
Last active December 25, 2025 19:27
API для погоды
<?php
//via http://php.net/manual/en/function.getimagesize.php#109063
$header = unpack('@6/vwidth/vheight', $binaryData);
$width = $header['width']
$height = $header['height'];
<?php
require_once "jBBCode" . DIRECTORY_SEPARATOR . "Parser.php";
/**
* Implements a [list] code definition that provides the following syntax:
*
* [list]
* [*] first item
* [*] second item
<?php
require_once "jBBCode" . DIRECTORY_SEPARATOR . "Parser.php";
/**
* Implements an [img=alt] tag that supports an optional class argument.
*
*/
class ImageWithClass extends \JBBCode\CodeDefinition
{
@nokimaro
nokimaro / unparse_jBBCode.php
Last active August 29, 2015 14:09
unparse function for jBBCode
<?php
//to Parser.php
public function unparse($str)
{
$tags_with_options = array();
$tags_without_options = array();
foreach ($this->bbcodes as $code)
{
@nokimaro
nokimaro / php_curl_copy.php
Last active August 11, 2020 11:12
PHP Curl functions
<?php
//via http://stackoverflow.com/questions/6409462/downloading-a-large-file-using-curl
function curl_copy($from = '', $to = '', $proxy = '')
{
if(empty($from) || empty($to))
{
return false;
}
@nokimaro
nokimaro / php read file.php
Created November 9, 2013 14:43
PHP read big file without memory limit error
<?php
$fp = fopen($cuts_list_file, 'rb');
while(!feof($fp))
{
$line = fgets($fp); //fgets reads one line at a time
}