Tag: webdev

Entries for tag "webdev", ordered from most recent. Entry count: 17.

Warning! Some information on this page is older than 5 years now. I keep it for reference, but it probably doesn't reflect my current knowledge and beliefs.

Pages: 1 2 3 >

# Changes on My Website

08:29
Mon
28
Aug 2017

I've dedicated my free time last week to improving this website. I made it myself from scratch more than 10 years ago, using some old version of PHP, MySQL, and HTML 4.01, so it definitely needed some refresh. I introduced many changes to the code, most notably:

There are still things to do. The website, as well as database, still uses ISO-8859-2 codepage instead of UTF-8 (it was a standard for encoding Polish characters before Unicode became popular). The scripts still generate the page using lots of print()-s instead of some template system. But maybe I will fix that next time :)

Comments | #webdev Share

# How to Restrict Access to Apache Server to Local Machine?

21:12
Tue
22
Aug 2017

I wanted to do some web development locally, so I installed Apache 2.2, PHP, and MySQL on my Windows 10 machine. When configuring it, I wanted to restrict access to the Apache server to two machines only - local one and another one in my local network.

The way to do it is to enable and use mod_authz_host module. In file C:\Apache2\conf\httpd.conf I needed to make sure that following line is not commented:

LoadModule authz_host_module modules/mod_authz_host.so

Then I could add appropriate directives to <Directory ...> section of this file, or alternatively use them in .htaccess file located next to files of my website.

To deny access from all addresses except my two computers, I started from this:

Order deny,allow
Deny from all
Allow from 192.168.0.21
Allow from 192.168.0.23

After restarting Apache (needed to apply any changes in configuration), I found out that I could access my website from the other computer, but not from the local one. I quickly recalled that connections to the same machine go through special loopback interface and use special address: localhost, which has IP 127.0.0.1. So I changed my configuration to this:

Order deny,allow
Deny from all
Allow from 192.168.0.21
Allow from 192.168.0.23
Allow from 127.0.0.1

It didn't work either. That's when I started to search for address where the local connection comes from, using Process Hacker - Network tab, as well as Apache log in file C:\Apache2\logs\access.log. What I found out is that the loopback connection uses IPv6, where address of localhost is: "::1" - however strange it may seem. Explanation of this format can be found here: IPv6 at Wikipedia.

Apache accepts this form of address, so following configuration finally allowed me to connect from my local computer, as well as the other computer from my network:

Order deny,allow
Deny from all
Allow from 192.168.0.21
Allow from 192.168.0.23
Allow from 127.0.0.1
Allow from ::1

Comments | #webdev #networking Share

# Nearest-Neighbor Filtering in HTML

20:25
Wed
05
Dec 2012

In 3D graphics programming, when a texture is enlarged, sampler performs filtering to interpolate between texture pixels. That's also what happens by default when an image is resized on HTML page - browser does some interpolation (e.g. bilinear or bicubic), which makes the image blurry.

What if you have a small pixel-art image and you want to show it on a web page as pixelated, not blurred? It turns out there are nonstandard CSS attributes for this. I found these two - first one is for Internet Explorer and the second one works in Firefox.

-ms-interpolation-mode: nearest-neighbor;
image-rendering: -moz-crisp-edges;

Comments | #webdev #css #html Share

# Improved RSS Feed

20:02
Sat
28
Jan 2012

I improved the script for generating news feed for my website. It now shows entire contents of my blog posts, including HTML formatting. So if you visit my blog sometimes and haven't done it yet, subscribe to my...

RSS Feed: Adam Sawicki - Homepage (Blog) RSS Feed

using some desktop or online reader, like the popular Google Reader. I use this one for some time and I like it a lot. RSS/Atom is really good technology. With it you can see unread updates from dozens of your favourite blogs in a single place and read them all without actually visiting the website.

Comments | #homepage #webdev #web Share

# Resizing Images to Generate Thumbnails in PHP

20:32
Fri
06
Jan 2012

Some time ago I came across a problem of calculating an image size for automatically generated thumbnail for gallery script coded in PHP. It required a moment's thought, so I'd like to share this algorithm. In fact there will be two algorithms.

First code scales the image down with following rules: Destination size will not exceed given thumbnail size, but the width or height can be smaller to always preserve aspect ratio. Images smaller than thumbnail size are not magnified.

Inputs:
$src_size_x, $src_size_y - Source image size.
THUMBNAIL_SIZE_X, THUMBNAIL_SIZE_Y - Constants defining thumbnail size.

Outputs:
$dst_size_x, $dst_size_y - Destination thumbnail size.

if( $src_size_x <= THUMBNAIL_SIZE_X && $src_size_y <= THUMBNAIL_SIZE_Y )
{
  $dst_size_x = $src_size_x;
  $dst_size_y = $src_size_y;
}
else
{
  $dst_size_x = THUMBNAIL_SIZE_X;
  $dst_size_y = (int)( $src_size_y * THUMBNAIL_SIZE_X / $src_size_x );
  
  if( $dst_size_y > THUMBNAIL_SIZE_Y )
  {
    $dst_size_x = (int)( $src_size_x * THUMBNAIL_SIZE_Y / $src_size_y );
    $dst_size_y = THUMBNAIL_SIZE_Y;
  }
}

Second algorithm also helps with generating image thumbnails, but works differently. It assumes that destination image will always be of size (THUMBNAIL_SIZE_X, THUMBNAIL_SIZE_Y), while source iamge can be cropped to select only the center of the image if it has different aspect ratio than the thumbnail.

Inputs to this algorithm are the same, while outputs are:

$src_x, $src_y - Offset in the source image to begin copying from.
$src_w, $src_h - Size of the rectangle to select from cropped source image.

The code that uses this algorithm should then select from the source image a rectangle with left-top position ($src_x, $src_y), size ($src_w, $src_h) and copy it, with scaling and resampling, to the destination image with the size exactly (THUMBNAIL_SIZE_X, THUMBNAIL_SIZE_Y). That's what imagecopyresampled function from GD library can do. This algorithm does not handle cases where source image is smaller than thumbnail.

$src_h = $src_size_y;
$src_w = (int)( $src_h * THUMBNAIL_SIZE_X / THUMBNAIL_SIZE_Y );

if( $src_w <= $src_size_x )
{
  $src_x = ( $src_size_x - $src_w ) / 2;
  $src_y = 0;
}
else
{
  $src_w = $src_size_x;
  $src_h = (int)( $src_w * THUMBNAIL_SIZE_Y / THUMBNAIL_SIZE_X );
  $src_x = 0;
  $src_y = ( $src_size_y - $src_h ) / 2;
}

Comments | #webdev #algorithms #php Share

# DevMeeting and Demoscene Night

20:45
Sun
24
Jul 2011

Yesterday I attended two events related to my interests. First was about collision detection in JavaScript games, organized by Marek Paw³owski from devmeetings.pl. During this almost 12-hour workshop we could learn about JavaScript, as well as some theory of 2D collision detection and space partitioning techniques. Nothing new for me, but I liked formula of this workshop. We could learn some theory from slides, but most of the time we had some tasks to code on our laptops - first to implement a simple library for aspects in JavaScript and then to code Asteroids game, including precise collision detection and QuadTree. Most of the code for this game was ready - we were given a framework, as well as libraries with math and a class for QuadTree. Our task was to just to connect it together. I think it's a good way of teaching programming in practice.

Web technologies are not my main interest, but I like JavaScript. I even think  it's the most beautiful scripting language in terms of syntax. Being able to freely draw 2D (using HTML Canvas) as well as 3D graphics (using WebGL) makes it a good technology for learning and prototyping geometry or gameplay algorithms. Marek also pointed on the DevMeeting an interesting conclusion that it's very easy to port algorithms from C/C++ to JavaScript. But on the other hand, Dab reminded me today that Lua is a scripting language with very similar features, but faster and more lightweight interpreter, so it's still better choice as a scripting language embedded in high-performance software like games.


More photos

Second event was Noc z Demoscen± - Demoscene Night. It took place in Fabryka Kot³ów club (former No Mercy). During that night we could see some olschool, as well as newschool demos presented on a a big screen and, what is most important, meet some nice people there. Thanks Voyager for organizing this event! It was great especially because the 3-day demoscene party RiverWash, which took place here in Warsaw in last 2 years, this year is in £ód¼ and I can't attend it. This night was very inspiring and now I feel like developing a technology to make a demo :)

Comments | #demoscene #webdev #javascript #math #events Share

# Hakaton - HTML5 Programming Event

23:32
Sat
16
Apr 2011

Today I was on Hakaton - a full day event organized by Google at Warsaw University of Technology. It was actually a contest in HTML5 programming. I had no previous experience in HTML5, but as a team with two other participants we scored 2nd place out of 17, won nice backpacks and books on web design :)

The theme was "Creative Science", but as always in such contests, participants just coded different stuff. Our entry is a simulation game where creatures of different species (red, green and blue) move around and do different things. Red creatures are predators - they have to eat blue ones or else they die from starvation. Blue ones try to avoid reds, eat green plants and form couples to generate offspring. Finally, green creatures do not move - they are plants, they just grow by generating new elements. Interesting situations can emerge from such simple rules. For example, sometimes only plants remain and grow infinitely, but sometimes blue creatures consume all plants and breed to a large number. We even managed to make it interactive - you can put new creatures on the map with mouse clicks. The game is coded in HTML5 and JavaScript using <canvas>. It requires a modern web browser with support for these technologies. You can play our game online here:

RGBCreatures

What I also liked was extensive use of Twitter during the party. #hakaton was second most popular hashtag in Poland today! Some screenshots:

RGB Creatures

Comments | #webdev #events #competitions #html Share

# Smarty Cheatsheet

20:16
Fri
04
Jun 2010

I knew about this before, but today I've found some time to deeply study Smarty - a free template engine for PHP. Templates in webdev (not to confuse with templates in C++) look like an interesting concept, because they separate PHP code from HTML code. I wish I used them from the start during coding my homepage and the www.gamedev.pl website instead of print()-ing HTML tags directly...

Anyway, I've written a small Smarty Cheatseet. Of course it makes sense only after studying the original library documentation, it cannot replace it.

By the way, I was also looking for some PHP library for creating RSS or ATOM feeds and I've found Feedcreator. Now I'm going to make something useful with it...

NEW: This "something" is an RSS feed for newest screenshots uploaded into www.gamedev.pl website: Feed Warsztat - Screeny, as well as for projects: Feed Warsztat - Projekty.

Comments | #webdev #php #libraries Share

Pages: 1 2 3 >

STAT NO AD
[Stat] [STAT NO AD] [Download] [Dropbox] [pub] [Mirror]
Copyright © 2004-2017