Skip to content

Instantly share code, notes, and snippets.

View kselax's full-sized avatar

Kselax kselax

View GitHub Profile
<?php
echo "hello world!";
?>
@kselax
kselax / test.php
Last active November 1, 2018 06:56
test gist
<?php
echo "hello world
This is editable version";
?>
@kselax
kselax / TextInserter.js
Last active March 17, 2018 20:03
TextInserter. (javascript)
class TextInserter{
constructor(selector, text){
this.selector=selector
this.text=text;
this.field=$(selector).get(0);
this.value=$(selector).val();
this.start=this.field.selectionStart;
this.finish=this.field.selectionEnd;
this.putText();
@kselax
kselax / JqTexInserter.js
Last active March 17, 2018 20:04
JqTexInserter
jQuery.fn.JqTexInserter = function(text) {
this.each(function() {
var start=$(this).get(0).selectionStart;
var finish=$(this).get(0).selectionEnd;
var str=$(this).val();
str=str.substr(0,start)+text+str.substr(finish);
$(this).val(str);
},text);
}
@kselax
kselax / textareaInserter.js
Last active March 17, 2018 19:50
javascript textarea inserter both with jquery and steer javascript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<div><textarea id="mytextarea"></textarea></div>
<div><button>click</button></div>
@kselax
kselax / WpThumbnail.php
Created March 28, 2018 16:42
WpThumbnail is a class for put thumbnail image to WP media library
<?php
namespace ddd;
if(!class_exists('WpThumbnail')){
class WpThumbnail{
private $tempImgFile; //path to temfile
private $tempImgPngFile; //path to png temp file
@kselax
kselax / A.php
Created March 29, 2018 01:03
PHP, Class Autoloader - class that automatically load classes from folder.
<?php
if(!class_exists('A')){
class A{
function __construct(){
echo __CLASS__."<br>";
}
}
}
?>
@kselax
kselax / Plugin.php
Last active March 29, 2018 01:11
PHP Current class loader
<?php
namespace ddd;
if(!class_exists('Plugin')){
class Plugin{
function __construct(){
$this->loadCore();
}
@kselax
kselax / AutoLoader.php
Created March 29, 2018 10:23
php autoloader
<?php
namespace test1;
if(!class_exists('AutoLoader')){
class AutoLoader{
private $dirs;
public function __construct(){
@kselax
kselax / SplAutoLoader.php
Created March 29, 2018 11:43
php Spl Auto Loader File for load PHP classes using function spl_autoload_register
<?php
namespace test1;
if(!class_exists('SplAutoLoader')){
class SplAutoLoader{
private $nameSpace;
private $dirs;
public function __construct($nameSpace){