Skip to content

Instantly share code, notes, and snippets.

View ssovit's full-sized avatar
🔥
print "hello"

Sovit Tamrakar ssovit

🔥
print "hello"
View GitHub Profile
@ssovit
ssovit / fontaweomse-stars.php
Last active December 19, 2018 10:40
Create FontAwesome static rating bar based on rating data
<?php
function createFontAwesomeStarRating($rating=0,$min=0,$max=10,$maxStars=5,$return=false){
$score=(($rating - $min) * ($maxStars)) / ($max - $min) ;
$full=floor($score);
$half=ceil($score)-$full;
$empty=$maxStars-$full-$half;
$result='<div class="rating-stars" title="'.$score.'">';
$result.=str_repeat('<i class="fa fa-star"></i>',$full);
$result.=str_repeat('<i class="fa fa-star-half-o"></i>',$half);
$result.=str_repeat('<i class="fa fa-star-o"></i>',$empty);
@ssovit
ssovit / clear-cache.php
Created September 28, 2017 06:43
Auto clean autoptimize cache once a month
<?php
namespace wppress;
class GarbageCollection
{
public function __construct()
{
add_filter('cron_schedules', function ($schedules) {
$schedules['weekly'] = array(
'interval' => 604800,
var svgPHPArray = function (dest) {
var File = gutil.File;
var files = [];
var prepareFiles = function (f, enc, cb) {
if (f.isNull()) {
cb();
return;
}
if (f.isStream()) {
cb();
@ssovit
ssovit / gulpfile.js
Created September 8, 2016 06:29
Gulp - Nicely Commented Less Import from a folder
var gulp = require('gulp');
var less = require('gulp-less');
var lessImport=require('less-imports.js');
gulp.task('less_parts', function() {
gulp.src("src/less/parts/*.less")
.pipe(lessImport('style.css'))
.pipe(less())
.pipe(gulp.dest("./"));
@ssovit
ssovit / popular-post-class.php
Last active August 29, 2015 14:06
Post Views
<?php
class WPPress_Post_Views
{
function __construct() {
add_action('wp_ajax_post_heartbeat', array(&$this,
'increase'
));
add_action('wp_ajax_nopriv_post_heartbeat', array(&$this,
'increase'