Skip to content

Instantly share code, notes, and snippets.

View Ciantic's full-sized avatar

Jari Pennanen Ciantic

View GitHub Profile
@Ciantic
Ciantic / load.php
Created June 10, 2011 16:03
Non quoted api for WP: load.php (patch)
<?PHP
$WP_NONQUOTED_POST = array();
/**
* Add magic quotes to $_GET, $_POST, $_COOKIE, and $_SERVER.
*
* Also forces $_REQUEST to be $_GET + $_POST. If $_SERVER, $_COOKIE,
* or $_ENV are needed, use those superglobals directly.
*
@Ciantic
Ciantic / hygcsv_to_sqlite.py
Created September 14, 2011 16:18
Convert hygxyz.csv to hyg.sqlite
# Public domain
# Created by Jari Pennanen
# September 2011
#
# For viewing SQLite, try one of these
# - http://sqliteadmin.orbmu2k.de/ (only win32, better than sqlitebrowser)
# - http://sqlitebrowser.sourceforge.net/
import sqlite3
import os
@Ciantic
Ciantic / parseuri_absuri.js
Created September 30, 2011 15:08 — forked from Yaffle/URLUtils.js
Parse URI and Convert Relative URI to Absolute
var parseURIMatcher = /^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/;
/**
* Parses the URI
*
* @param url
* @returns object
*/
function parseURI(url) {
var m = parseURIMatcher.exec(url);
@Ciantic
Ciantic / default_sorting.php
Created December 5, 2011 18:21
default sorting order of all list views in admin
<?PHP
function post_order_type_default_sorting(&$query) {
if (!isset($query->query['orderby'])) {
$query->set('orderby', 'menu_order');
}
}
function post_order_type_list_view() {
add_action('pre_get_posts', 'post_order_type_default_sorting', 1, 1);
@Ciantic
Ciantic / filter.php
Created December 9, 2011 12:29
Filter in admin list
<?PHP
abstract class My_AdminList {
public static $taxonomies = array("menu_category");
public static $post_types = array("owns_restaurant_item");
/**
* Admin init hook
*/
@Ciantic
Ciantic / listboks.html
Created September 24, 2012 07:09
Testi
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Select test</title>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8">
function Hae(kohde_id, porras_id, kerros_id, fill_name) {
$.getJSON("hae_data2.php",{kohde_id: kohde_id, porras_id: porras_id, kerros_id: kerros_id}, function(j){
console.log(j);
@Ciantic
Ciantic / custom.css
Created October 10, 2012 19:17
Web.Tweetdeck.com hack: smaller and inline avatars
/*
Edit User StyleSheet of Chrome:
Windows:
C:\Users\YOURUSERNAME\AppData\Local\Google\Chrome\User Data\Default\User StyleSheets\Custom.css
Create the file if it does not exist. Similar file is in Firefox too.
*/
@Ciantic
Ciantic / jquery.query.js
Created November 26, 2012 12:46 — forked from bdimcheff/jquery.query.js
jquery-query
/**
* http://plugins.jquery.com/project/query-object
* jQuery.query - Query String Modification and Creation for jQuery
* Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
* Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
* Date: 2009/8/13
*
* @author Blair Mitchelmore
* @version 2.1.8 (fork)
*
@Ciantic
Ciantic / date_i18n.js
Created November 19, 2013 15:04
WordPress' date_i18n as javascript function (derived from phpjs date)
function date_i18n(format, timestamp) {
// http://kevin.vanzonneveld.net
// + original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com)
// + parts by: Peter-Paul Koch (http://www.quirksmode.org/js/beat.html)
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: MeEtc (http://yass.meetcweb.com)
// + improved by: Brad Touesnard
// + improved by: Tim Wiel
// + improved by: Bryan Elliott
// + improved by: David Randall
@Ciantic
Ciantic / getUID.php
Created December 5, 2013 16:49
Unique ID (alpha numeric)
<?php
/**
* Unique ID alpha numeric (0-9a-z)
*
* @return 20 character alphanumeric unique id
**/
function getUID($id=null) {
$s = uniqid('', true);
$hex = substr($s, 0, 13);
$dec = $s[13] . substr($s, 15); // skip the dot