Skip to content

Instantly share code, notes, and snippets.

View stavrossk's full-sized avatar
🎯
Focusing

Stavros Skamagkis stavrossk

🎯
Focusing
View GitHub Profile
@stavrossk
stavrossk / JavaScript Analog Clock.html
Created December 3, 2014 07:08
Simple Analog Clock using HTML5 canvas and JavaScript.
<!doctype html>
<html>
<head>
<title>Analog Clock using Canvas</title>
</head>
<body>
@stavrossk
stavrossk / Functions.php
Created June 24, 2023 17:57
WooCommerce Filter Hook to Make checkout addresses fields not required in WooCommerce. All code goes in functions.php file of your active child theme.
// Billing and shipping addresses fields
add_filter( 'woocommerce_default_address_fields' , 'filter_default_address_fields', 20, 1 );
function filter_default_address_fields( $address_fields )
{
// Only on checkout page
if( ! is_checkout() ) return $address_fields;
// All field keys in this array
@stavrossk
stavrossk / woocommerce-shipping-contact.php
Created June 7, 2023 11:34 — forked from helgatheviking/woocommerce-shipping-contact.php
Add a shipping email/phone field to checkout and notify of new orders
<?php
/*
Plugin Name: WooCommerce Shipping Contact
Plugin URI: https://github.com/helgatheviking/wc-shipping-contact
Description: Add a shipping email field to checkout and notify of new orders
Version: 1.1.0
Author: Kathy Darling
Author URI: http://kathyisawesome.com
Requires at least: 4.0
Tested up to: 4.8
@stavrossk
stavrossk / PHP Ordinal number suffix adder.php
Created August 14, 2013 19:22
PHP Snippet: Add (th, st, nd, rd, th) to the end of a number: This PHP code snippet will add the appropriate suffix th, st, nd and rd to a given number.
<?php
function ordinal($num)
{
$last=substr($num,-1);
if( $last>3 or
@stavrossk
stavrossk / PHP Validate e-mail address.php
Created August 17, 2013 13:21
PHP Snippet: Validate email Address: E-mail validation is perhaps the most used validation in web forms, this code will validate email address and also optionally check the MX records of the domain provided in email address to make email validation more robust.
<?php
function is_valid_email($email, $test_mx = false)
{
if( eregi("^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) )
{
@stavrossk
stavrossk / Import CSV file using PDO.php
Created May 11, 2014 13:00
Import a CSV file into a MySQL database using PHP PDO.
<?php
$databasehost = "localhost";
$databasename = "test";
$databasetable = "sample";
$databaseusername="test";
$databasepassword = "";
@stavrossk
stavrossk / SDL: Drawing text sample function.c
Last active July 12, 2021 22:13
SDL Tutorial: Drawing Text with SDL.
// TTF_Init() must be called before using this function.
// Remember to call TTF_Quit() when done.
void drawText
(SDL_Surface* screen, char* string,
int size, int x, int y,
int fR, int fG, int fB,
int bR, int bG, int bB)
{
@stavrossk
stavrossk / PHP Real client IP address retriever.php
Last active June 7, 2021 06:05
PHP Snippet: Get Real IP Address of Client: This function will fetch the real IP address of the user even if he is behind a proxy server.
<?php
function getRealIpAddr()
{
if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) )
{
@stavrossk
stavrossk / PHP - sending e-mail attachments.php
Created May 16, 2013 15:20
Sending e-mail with attachments using PHP
<html>
<head>
<title>
Sending attachment using PHP
</title>
@echo off
IF NOT EXIST %WINDIR%\System32\GroupPolicy goto next
echo Deleting GroupPolicy folder...
RD /S /Q "%WINDIR%\System32\GroupPolicy" || goto error
echo.
:next
IF NOT EXIST %WINDIR%\System32\GroupPolicyUsers goto next2