Skip to content

Instantly share code, notes, and snippets.

View adrianvlupu's full-sized avatar
💾
the world

Victor Lupu adrianvlupu

💾
the world
  • Fullscreen Digital
  • Bucharest Romania
View GitHub Profile
@adrianvlupu
adrianvlupu / GetSet.js
Last active December 27, 2015 13:39
Getters/Setters in javascript
//method 1
var A = function(name){
var _name = name;
Object.defineProperty(this, 'name', {get: function(){console.log('get name'); return _name;},
set:function(e){console.log('set name='+e); _name=e;},
enumerable: true
});
return this;
@adrianvlupu
adrianvlupu / slidezor.jquery.js
Created September 16, 2013 09:41
My vision of the simplest slider ever
(function ($) {
$.fn.slider = function (method, options) {
var methods = {
init: function (options) {
if ($(this).children().length > 0) {
var slide = $($(this).children().get(options.startIndex));
slide.addClass('selected');
options.onInit(options.startIndex);
}
},
@adrianvlupu
adrianvlupu / handler.cs
Created July 25, 2013 09:47
Ashx responding to a json POST body
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OAuth;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
@adrianvlupu
adrianvlupu / debug.js
Last active December 20, 2015 03:08
Minimal debug console
var debug={
enabled: true,
init: function () {
if (this.enabled)
$('body').append('<div id="debug" style="position:absolute;bottom:0;right:0;background:#FFF;border:solid 1px #000;font-size:10px;padding:5px;"></div>');
},
write: function () {
if (this.enabled) {
for(var i in arguments)
$('#debug').append('<div>' + ((typeof arguments[i]==='object')?JSON.stringify(arguments[i]):arguments[i]) + '</div>');
@adrianvlupu
adrianvlupu / HttpUtils.cs
Last active December 19, 2015 08:29
HTTP Get/POST
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Web;
@adrianvlupu
adrianvlupu / JSONP.js
Created June 28, 2013 08:43
JSONP js wrapper
var JSONP = {
_jsonpcallbacks: {},
request: function (url, data, callback) {
var callbackName = Math.random();
Ripple._jsonpcallbacks[callbackName] = callback;
var script = document.createElement('script');
script.src = url + '?callback=' + callbackName + '&data=' + encodeURIComponent(JSON.stringify(data));
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);
}