Skip to content

Instantly share code, notes, and snippets.

View vbilopav's full-sized avatar
🏠
Working from home

Vedran Bilopavlović vbilopav

🏠
Working from home
View GitHub Profile
$.ajax({
url: "http://localhost:53920/MyServiceSample.svc/jsonp/DoSomeWork?request=" +
JSON.stringify({ Param1: 1, Param2: "bla"}) +
"&callback=?",
contentType: "application/json",
dataType: "json",
type: "GET",
success: function(data) {
if (data.success) {
// do some stuff...
protected void Application_BeginRequest(object sender, EventArgs e)
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "http://localhost:53738");
if (HttpContext.Current.Request.HttpMethod != "OPTIONS") return;
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "POST, PUT, DELETE");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept");
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
HttpContext.Current.Response.End();
}
/*
jQuery pub/sub plugin by Peter Higgins ([email protected])
Loosely based on Dojo publish/subscribe API, limited in scope. Rewritten blindly.
Original is (c) Dojo Foundation 2004-2010. Released under either AFL or new BSD, see:
http://dojofoundation.org/license for more information.
*/
define('text',["module"],function(e){"use strict";var l,o,a,s,u,r=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],t=/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,i=/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,c="undefined"!=typeof location&&location.href,f=c&&location.protocol&&location.protocol.replace(/\:/,""),p=c&&location.hostname,d=c&&(location.port||void 0),m={},v=e.config&&e.config()||{};return l={version:"2.0.12",strip:function(e){if(e){var n=(e=e.replace(t,"")).match(i);n&&(e=n[1])}else e="";return e},jsEscape:function(e){return e.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r").replace(/[\u2028]/g,"\\u2028").replace(/[\u2029]/g,"\\u2029")},createXhr:v.createXhr||function(){var e,n,t;if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;if("undefined"!=typeof ActiveXObject)for(n=0;n<3;n+=1){t=r[n];try{e=new ActiveXObject(t)}catch(e){}if(e){r=[t];break}}return e},parseName:function
select
t.table_name,
c.column_name,
c.data_type ||
case when c.character_maximum_length is not null
then '(' || cast(c.character_maximum_length as varchar) || ')'
else case when c.numeric_precision is not null
then '(' || cast(c.numeric_precision as varchar) || ',' || cast(c.numeric_precision_radix as varchar) || ')'
|| case when coalesce(c.numeric_scale, 0) = 0 then '' else ',' || cast(c.numeric_scale as varchar) || ')' end
@vbilopav
vbilopav / pubsub.js
Last active February 19, 2019 14:26
/*
*** Publish/Subscribe global events functions - implementation of pubsub pattern for loose coupled components ***
Usage:
* Publish global application event:
publish("unique event name / category / subcategory", arg1, arg2, arg3);
or
define(["sys/html"], html => {
const
test = (object, extensions) => {
extensions.forEach(e => {
if (object.prototype[e] !== undefined) {
throw new Error(`Error: Name collision - object ${object} already have defined "${e}" !`);
}
});
};
do $$
begin
drop function if exists select_company_and_sectors(int);
drop function if exists update_company(int, json);
drop function if exists update_sectors(json);
drop table if exists employees;
drop table if exists sectors;
drop table if exists companies;
select "value" from "values" where id = @id;
select
keys.key, data->>keys.key as value
from (
select distinct jsonb_object_keys(data) as key from table
) keys cross join table
where data->>keys.key is not null
group by keys.key, data->>keys.key