Skip to content

Instantly share code, notes, and snippets.

View shimondoodkin's full-sized avatar

Shimon Doodkin shimondoodkin

View GitHub Profile
@shimondoodkin
shimondoodkin / InnerHTMLie6.js
Created January 7, 2013 15:47
InnerHTML & setAttribute for ie6-ie8 that do not suffer from restriction
//innerHTML of these elements in internet explorer are read only:
//COL, COLGROUP, FRAMESET, HEAD, HTML, STYLE, TABLE, TBODY, TFOOT, THEAD, TITLE, TR, SELECT.
//example:
// function createtable(deal)
// {
// var table = document.createElement('table');
// table.className='infotable';
// //table.innerHTML='<tbody><tr><td>123</td></tr></tbody>' // will not work in internet explorer
// setInnerHTML(table,'<tbody><tr><td>123</td></tr></tbody>')
@shimondoodkin
shimondoodkin / wp-includes\canonical.php
Last active December 11, 2015 10:58
helps debug canonical url wordpress - replace all wp_redirect function calls with calls to exit_redirect function
...
function exit_redirect($url,$status){ //wp_redirect
//return wp_redirect($url,$status); // uncomment to temporarly disable
while(ob_get_level())ob_end_flush();
if ( !$requested_url ) {
// build the URL in the address bar
/*
These next two functions work together to lock down bbPress forums based on PMPro membership level.
Check that the current user has access to this forum. Be sure to update the $restricted_forums array based on your needs.
*/
function pmpro_check_forum()
{
global $current_user;
/*
@shimondoodkin
shimondoodkin / merge_arrays.js
Created February 1, 2013 15:53
this awesome piece of JavaScript is written by me, by rewriting merge-strings function to use array elements instead of chars. licence: 2 close bsd/public domain
///////////////////////////merge arrays////// wrote by Shimon Doodkin/////////
/*
test mergin two arrays with common merging points
merge
[1,10:55] ,
[2,10:55] ,
[3,10:55]
@shimondoodkin
shimondoodkin / tinyxhr.js
Last active September 19, 2023 18:10
tiny xhr snippet to do XMLHttpRequest
// tinyxhr by Shimon Doodkin - licanse: public doamin - https://gist.github.com/4706967
//
// tinyxhr("http://site.com/ajaxaction",function (err,data,xhr){ if (err) console.log("goterr ",err,'status='+xhr.status); console.log(data) });
// tinyxhr("http://site.com/ajaxaction",function (err,data,xhr){ if (err) console.log("goterr ",err,'status='+xhr.status); console.log(data) },'POST','value1=1&value2=2');
// tinyxhr("http://site.com/ajaxaction.json",function (err,data,xhr){ if (err) console.log("goterr ",err,'status='+xhr.status); console.log(data); console.log(JSON.parse(data)) },'POST',JSON.stringify({value:1}),'application/javascript');
// cb - a callback function like: function (err,data,XMLHttpRequestObject){ if (err) throw err; }
//
function tinyxhr(url,cb,method,post,contenttype)
{
@shimondoodkin
shimondoodkin / gist:5142644
Created March 12, 2013 12:53
node.js reverse proxy at end of express. to make post commands work must remove bodyparser and mothod override. use body parser as middleware of app.get command.
// this is not a main file the main file is opchart.js
var express = require('express')
// , routes = require('./routes')
// , user = require('./routes/user')
, path = require('path');
sessionStore=false //defined on first time it could be catched from a request
app = express();//global
@shimondoodkin
shimondoodkin / todo list in facebook.tamper.js
Last active December 17, 2015 09:58
in chrome, add Tampermonkey plugin. add new script. copy paste to new script
// ==UserScript==
// @name todo list in facebook
// @namespace http://kodtov.com
// @version 0.1
// @description adds a todo list in top of facebook
// @include *facebook.com*
// @copyright 2013, Shimon Doodkin
// ==/UserScript==
// tinyxhr by Shimon Doodkin - licanse: public doamin - https://gist.github.com/4706967
the basics of programming with callbacks:
structure:
function simple1(cb) // the last argument is callback function
{
if(cb)return cb();// the return is required to prevent continuation of the function.
// the if(cb) is optional and it is to enable to omit the callback in rare cases.
// it is usually useful in api functions.
}
@shimondoodkin
shimondoodkin / Taskbar.js
Last active January 21, 2017 16:21
qooxdoo desktop taskbar class. modify qx.Class.define("charts.Taskbar", ... to your choice of class prefix
//TASKBAR CLASS
/**
* This class provides some well known operating system like taskbar
* behaviours. To every added window a toggle button is attached, that
* can switch the window between maximized and minimized state.
*
* *Example*
*
* Here is a little example of how to use the widget.
@shimondoodkin
shimondoodkin / datefunctions.js
Last active December 18, 2015 21:38
date functions i use
Date.prototype.isValid = function() {
if ( Object.prototype.toString.call(this) !== "[object Date]" )
return false;
return !isNaN(this.getTime());
}
////////////