Skip to content

Instantly share code, notes, and snippets.

View ionurboz's full-sized avatar

Onur ionurboz

View GitHub Profile
@ionurboz
ionurboz / jQuery.UTF-8.js
Created May 3, 2018 22:51 — forked from lucasmezencio/jQuery.UTF-8.js
A way to manipulate UTF-8 strings in jQuery.
;(function($, undefined) {
$.extend({
toUTF8 : function(text) {
text = text.replace(/\r\n/g,"\n");
var output = [];
for (var n = 0 ; n < text.length ; n++) {
var c = text.charCodeAt(n);
@ionurboz
ionurboz / jQuery.limit.js
Created May 3, 2018 22:52 — forked from lucasmezencio/jQuery.limit.js
jQuery 'limit' plugin for textarea
;(function ($) {
$.fn.limit = function (options) {
var defaults = {
limit : 200,
result : false,
alertClass : false
}, options = $.extend(defaults, options);
return this.each(function () {
var characters = options.limit;
@ionurboz
ionurboz / turkish-capitalize-words.js
Created May 4, 2018 16:20 — forked from anova/turkish-capitalize-words.js
Capitalize, lowercase, uppercase for Turkish alphabet.
//http://stackoverflow.com/a/1026087/181295
String.prototype.turkishUpperCase = function () {
return this.replace(/ğ/g, 'Ğ')
.replace(/ü/g, 'Ü')
.replace(/ş/g, 'Ş')
.replace(/ı/g, 'I')
.replace(/i/g, 'İ')
.replace(/ö/g, 'Ö')
.replace(/ç/g, 'Ç')
.toUpperCase();
@ionurboz
ionurboz / bbcode.php
Created May 9, 2018 22:19 — forked from neo22s/bbcode.php
BBcode parser example
<?php
/**
* BBcode helper class
*
* @package BBcode
* @category Helper
* @author Chema <chema@garridodiaz.com>
* @copyright (c) 2012
* @license GPL v3
*/
@ionurboz
ionurboz / tmplmeta.md
Created March 29, 2019 00:21 — forked from scottjehl/tmplmeta.md
Template meta tag pattern for template-based decisions

I've been finding this little meta[name='tmpl'] pattern useful lately when making template-based decisions in JS, such as when loading a particular file or set of files that are needed only on a particular page of a site.

First, in the HTML of a particular template, like say, a search result page:

<head>
  ...
  <meta name="tmpl" content="searchresult">
</head>
@ionurboz
ionurboz / rAF.js
Created April 19, 2019 22:29 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@ionurboz
ionurboz / router.html
Created April 29, 2019 21:37 — forked from joakimbeng/router.html
A really simple Javascript router
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Building a router</title>
<script>
// Put John's template engine code here...
(function () {
// A hash to store our routes:
@ionurboz
ionurboz / chrome_39.js
Created May 5, 2019 12:15 — forked from ksol/chrome_39.js
Language detection in javascript
window.navigator.language // -> "fr"
window.navigator.languages // -> ["fr-FR", "fr", "en-US", "en", "es", "de"]
window.navigator.userLanguage // -> undefined
window.navigator.browserLanguage // -> undefined
window.navigator.systemLanguage // -> undefined
@ionurboz
ionurboz / upload-a-file-with-wp-api-rest.MD
Last active June 20, 2019 20:18 — forked from ahmadawais/upload-a-file.MD
Upload a file using the WordPress REST API

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle:

<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 year"
# Data interchange
ExpiresByType application/atom+xml "access plus 1 hour"