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 / 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);
}
@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 / 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 / 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 / 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 / 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;
function scan(obj, search, from)
{
var k;
if (obj instanceof Object) {
for (k in obj){
//console.log('object ', obj, k);
if (obj.hasOwnProperty(k)){
if(k.toString().indexOf(search)!=-1){
console.log('found string as prop ', k, obj);
}else{
@adrianvlupu
adrianvlupu / mvc.html
Created December 11, 2013 17:39
JS MVC
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="jquery-2.0.3.min.js"></script>
<script src="underscore.js"></script>
<script src="backbone.js"></script>
<script>
//#region eventHandler
var eventHandler = function (sender) {
@adrianvlupu
adrianvlupu / WebApiConfig.cs
Last active January 3, 2016 10:49
Common webapi config
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using Newtonsoft.Json;
using System.Web.Routing;
using System.Net.Http;
namespace WebRoleV2
{
@adrianvlupu
adrianvlupu / Repository.cs
Last active March 22, 2022 11:08
Generic repository for EF
using OrangeMSE.Business;
using OrangeMSE.Business.Data;
using OrangeMSE.Business.Helpers;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Linq.Expressions;