Skip to content

Instantly share code, notes, and snippets.

View svlasov's full-sized avatar

Sergey Vlasov svlasov

  • Israel
View GitHub Profile
@svlasov
svlasov / EmptyWidget.php
Created February 16, 2012 07:48 — forked from jonathonbyrdziak/CustomWidgetFile.php
Plugin code to create a single widget in wordpress.
<?php
/**
*
*
*
* Plugin Name: Empty Widget
* Description: Single Widget Class handles all of the widget responsibility, all that you need to do is create the html. Just use Find/Replace on the Empty_Widget keyword to rebrand this class for your needs.
* Author: RedRokk Interactive Media
* Version: 1.0.0
* Author URI: http://www.redrokk.com
@svlasov
svlasov / wp_func_404
Created February 28, 2012 15:21
Function for displaying 404 page from arbitrary point of a WordPress plugin or theme
function _return_404() {
status_header(404);
nocache_headers();
include( get_404_template() );
exit;
}
@svlasov
svlasov / gist:2138390
Created March 20, 2012 17:28 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@svlasov
svlasov / gist:2215819
Created March 27, 2012 13:22
Humanize file size
<?php
function humanizeFileSize($pathToFile)
{
if (is_readable($pathToFile)) {
$size = filesize($pathToFile);
if ($size < 1024) {
return $size .'B';
} elseif ($size < 1048576) {
return round($size / 1024, 2) .'Kb';
} elseif ($size < 1073741824) {
@svlasov
svlasov / testlisttable.php
Created April 25, 2012 08:14 — forked from Latz/testlisttable.php
Sample plugin for usage of WP_List_Table class (basic version)
<?php
/*
Plugin Name: Test List Table Example
*/
if( ! class_exists( 'WP_List_Table' ) ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
class My_Example_List_Table extends WP_List_Table {
@svlasov
svlasov / a view.php
Created April 25, 2012 11:09 — forked from TCotton/a view.php
Wordpress Options API access class
<?php
namespace OptionView;
use OptionController;
/**
* Form_View
*
* @package Wordpess Options API access class
* @author Andy Walpole
@svlasov
svlasov / basename.js
Created May 10, 2012 10:42
get basename part of a filename
function basename(path) {
return path.replace(/\\/g,'/').replace( /.*\//, '' );
}
@svlasov
svlasov / qqq
Created July 30, 2012 19:39
qqq
qqq
@svlasov
svlasov / application_controller.rb
Created August 12, 2012 12:43 — forked from joewest/application_controller.rb
Cross-origin resource sharing in rails
class ApplicationController < ActionController::Base
protect_from_forgery
after_filter :set_access_control_headers
def set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Request-Method'] = '*'
end
end
assets_path = File.expand_path("~/projects/rails/scout/public")
log_path = File.expand_path "~/assets.txt"
temp_requested_files_path = File.expand_path "~/processed_assets.txt"
ignore_pattern = /sparkline|datejs/
known_used =[
"javascripts/jquery-1.7.1.min.js",
"javascripts/jquery.extensions.js",
"javascripts/application.js",
"stylesheets/default.css",