Skip to content

Instantly share code, notes, and snippets.

@sxidsvit
sxidsvit / gallery_pgwp_blocks.php
Last active September 23, 2016 22:04
Код галереи, созданный в модуле Pinegrow Blocks WP (lesson 10).
@sxidsvit
sxidsvit / pinegrow_examples.php
Last active September 23, 2016 22:04
Фрагменты кода Pinegrow: полезные снипеты кода на PHP для WP
// Фрагменты кода Pinegrow + полезные фрагменты из других источников
/* functions.php - Pinegrow generated Enqueue Scripts and Styles */
if ( ! function_exists( 'prokopskiy_2_enqueue_scripts' ) ) :
function prokopskiy_2_enqueue_scripts() {
/* Pinegrow generated Enqueue Scripts Begin */
wp_deregister_script( 'jquery' );
<?php
class Db
{
private $_connection;
private static $_instance; //The single instance
private $_host = DB_HOST;
private $_username = DB_USER;
private $_password = DB_PASSWORD;
private $_database = DB_DB;
@iGusev
iGusev / chat.php
Created September 25, 2014 20:10
php-chat
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<meta http-equiv="refresh" content="2">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
.chat-body {
margin-bottom: 10px;
@ashutoshlr
ashutoshlr / Create_table.sql
Last active February 21, 2016 16:52
PHP - Chat Application
CREATE TABLE `s_chat_messages` (
`id` INT(11) NOT NULL AUTO_INCREMENT ,
`user` VARCHAR(255) NOT NULL ,
`message` VARCHAR(255) NOT NULL ,
`when` INT(11) NOT NULL ,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
@jonashansen229
jonashansen229 / class.database.php
Last active June 20, 2023 08:41
PHP OOP Database class using MySQLI and Singleton pattern. Only one instance of the class will be made, this requires less memory.
<?php
/*
* Mysql database class - only one connection alowed
*/
class Database {
private $_connection;
private static $_instance; //The single instance
private $_host = "HOSTt";
private $_username = "USERNAME";
private $_password = "PASSWORd";
@rhrn
rhrn / rpn
Created September 12, 2012 08:09
Reverse Polish notation on PHP
<?php
function rpn($params) {
$params = explode(' ', $params);
$count = sizeof($params);
$result = null;
@ebidel
ebidel / handle_file_upload.php
Created April 18, 2012 03:23
Uploading files using xhr.send(FormData) to PHP server
<?php
$fileName = $_FILES['afile']['name'];
$fileType = $_FILES['afile']['type'];
$fileContent = file_get_contents($_FILES['afile']['tmp_name']);
$dataUrl = 'data:' . $fileType . ';base64,' . base64_encode($fileContent);
$json = json_encode(array(
'name' => $fileName,
'type' => $fileType,
'dataUrl' => $dataUrl,
@slackorama
slackorama / rpn.py
Created April 2, 2012 05:59
Python implementation of an RPN calculator
#!/usr/bin/env python
# an rpn calculator in python
# > 19 2.14 + 4.5 2 4.3 / - *
# [85.297441860465113]
# only supports two operands and then an operator
import operator
ops = { '+': operator.add,
@reinink
reinink / gist:1467201
Created December 12, 2011 13:41
Example of how to parse HTML document with phpQuery
<?php
// Include the phpQuery library
// Download at http://code.google.com/p/phpquery/
include 'phpQuery.php';
// Load Mike Fisher's player page on thescore.com
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.thescore.com/nhl/player_profiles/859-mike-fisher');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);