23
Nov
2013

recover SA password mssql 2008

Hi,
i recently forgot my sa user’s password and i had to create a new db on my sql server .. bummer!
so, i looked in many blogs and stackoverflow answers and couldn’t find a quick way to do it.

i had admin access to the server, no sql management studio installed on it so i had to use command line..
i could install ‘management studio’ and login with my windows account but i choose an easier solution:

go to command prompt by typing Start – Run – cmd

at the command window (without needing to change directories or anything) type (enter for each line)

OSQL -S instancename -E (where instancename could be something like : localhost\sql or localhost\sqlexpress or localhost\sqlexpress,1433)
1> EXEC sp_password NULL, ‘yourpassword’, ‘sa’
2> GO

you can use this method to replace the password of any user not only SA and it should work on other versions of mssql.

enjoy :)

Comments
Posted in General

28
Dec
2011

Jquery UI slider hides when slides – Event name collision with mootools

Hi,

after few hours of investigating this bug …
if you are trying to put a jquery ui slider on a page with mootools it won’t work as you would excpect because mootools slide event fires before jquery does.

the fix for this problem is easy, just do .prop(‘slide’,null) before initializing the jquery slider. this will remove Mootools’s Fx.Slide from the element.

scroller.prop('slide',null).slider({...});

Hope i helped someone with this ... 

G'day
Ady

03
Dec
2011

Video Suggestion tool for your wordpress blog

Hi all,
recently i finished working on a great tool to help editors add videos to their blog.
this tool grabs data from AOL Video library which is the largest curated library in the web.

the plugin wrap it self in it’s own namespace so it won’t conflict with other components on the page,
it features semantic matching for content, which is a great thing. you can write your post , hit the suggest videos button and in a second you get planty of semantically related videos that can match your content.

Download link: Video Suggestion for wordpress

We bloggers know that adding a video to your post reduces the bounce rate and helps improving your search engine score!
That plugin has some other versions that works with Movable Type CMS & Blogsmith. if you fency another version feel free to contact me , and i’ll try to help out with it.

Fetching suggest data was a nice challenge. i needed to post data to a remote server and grab the returned data in a JSON format , cross domain json is an easy task, you can use jsonp which works great, but it lacks one small thing..
you can’t post data. bummer ! if you want to grab a lot of text / data and push it to a remote server for analysis , it gets harder.
luckily we now have a new HTML5 method to do such things, “postmessage”. post message is a way to communicate between the opener page and an iframe who sits on another domain.
i’ll write a post regarding that way soon, with some examples.

* will be glad to have comments from you readers about that tool & generally about the blog.

Ady


27
Nov
2011

HttpWebRequest Authentication error 400

If you ever encounter such problems with authentication with querystring make sure you read Idan’s blog post @

HttpWebRequest Authentication error 400

Have a good day,

Ady


23
Sep
2011

.net handler working sequentially and not parallel.

Hi,
Last week I was working on a .net handler that have many functionalities, that are being triggered from a JavaScript app we have in the company – I realized that the calls to this handler are made sequentially and not parallel as I wold expect.

My first guess was something to do with the application pool’s settings, or some other configuration issue with my iis server, but that direction led nowhere. So I started to look at the code, looking for a lock of some kind, couldn’t find any .. Bad luck.

Than it it me, the handler, in some of it’s methods fetches the logged in users object from the session (only fetches – doesn’t alter in any way) … Hmm what will happen if i’ll drop that IRequireSessionState from the handler ? … And there we go, the handler has returned behaving as I expected – parallel !

Ok, now that I know what is the cause for this problem I made some digging in the web, and found out that I can use IReadOnlySessionState, which will do exactly what I wanted, read things from the session without locking it!

Best,
Ady

Comments
Posted in ASP.NET

07
Sep
2011

js onbeforeunload event – alert before leaving the page

if you wan’t to prevent a user from leaving your page,
something you might wanna do if you build a cms , or some admin page with user changing fields.

create a javascript variable named isDirty and make sure that field will be set to true on all input changes on the page (and some non trivial changes you might have in your ui)
than bind an event to the window.onbeforeunload (works on all browsers without the use of an extrenal js lib such as jQuery, dojo, mootools)

?View Code JAVASCRIPT
 window.onbeforeunload = function (ev) {
            var leavePageMsg = 'Your changes haven\'t been saved.\nAre you sure you want to leave this page?';
            ev = ev || window.event;
            if (isDirty) {
                if (ev) {
                    ev.returnValue = leavePageMsg;
                }
                return leavePageMsg;
            }
            // no return value - meaning it's ok to leave the page.
        };

Thats it, it will do the magic :)
Have a good one.

Comments
Posted in HTML, javascript

09
Jul
2011

Html5 Multiple File Uploading

i got a bit of messing around lately with html and found this great new features to XMLHttpRequest object.
now you can use it to send files and get their progress using javascript ! for all of us this is a great improvment , cause we don’t to use flash / silverlight / java anymore to get a neat progress bar for file upload.
of course there are great solutions (swfupload / uploadify etc) that hides the flash and mimics the whole process , but it not native to the browser …

so the uploader is wrapped as a class named .. you can guess Html5Uploader,
for ease of writing i used jquery – mainly for the selectors and event handling , but it can easily removed by anyone with a bit of javascript knowledge.

so in order to get it up & running create a new html5uploader object using such line :

var uploader = new Html5Uploader({ mimeTypes: “image/jpeg,image/gif,image/png,image/x-png,image/bmp”, queueSizeLimit: 10, fileInputId: ‘filesToUpload’ });
events thrown from the class :

onErrorAddingFile with an error object
onCancel – once a file is removed from queue
onAddedToQueue – once a file being added to queue (here you can write your own html)
onUploadStarted – for each file
onAllComplete – self explained i guess
onProgress – for file upload
onComplete – for each file
onError – on error while uploading.

you can download the demo from this link : html5 multiple file upload source

in the zip file you will find a .net solution with all the files (css/js/ashx) – the upload handler is a .net handler, you can modify one of my previous php upload handlers for this cause if you want to use php as your backend

and view an online demo @ html5 multiple file upload demo

right now chrome and firefox >4 supports html5 uploading, ie – not yet.

if you find this usefull , have any comments – please share with me, it’s nice to listen to my audience :)

Have a good one,

Ady


08
Apr
2011

Multiple inheritance in c sharp

Hi there!

all of us .net programmers know that there isn’t a built in way to create multiple inheritance in c#,
well – i needed such. i know some will argue and say this pattern is a no no, and i should have used other methods to create what i wanted,
but for me – it make perfect sense to do so.
am sharing with you the simple way i did so, if it is useful for one of you, i’m glad !

?View Code CSHARP
public class Multiple  where TType1 : new()
where TType2 : new()
{
static TType1 base1;
static TType2 base2;
 
public Multiple()
{
base1 = new TType1();
base2 = new TType2();
}
 
public static implicit operator TType1(Multiple c)
{return base1;}
public static implicit operator TType2(Multiple c)
{return base2;}
}
 
class Foo{}
class Bar{}
class FooBar : Multiple
{}
 
//then use as
 
FooBar foobar=new FooBar();
((Foo)foobar).FooFunciton();
((Bar)foobar).BarFunction();
foobar.FooBarFunction();

attached is a visual studio 2010 sample code: MinheritCSharp.zip

Cheers,

Ady

Comments
Posted in ASP.NET, c#, ,

28
Mar
2011

linq distinct – create a distinct collection using linq (c#)

Hi there,

well its been a long while since i wrote anything on this blog, alot have changed in this long period.

wanted to share a neat way to use linq in c# to get a distinct list of elements by some key.
lets say you have a collection of categories, where the unique identifier called uid, and you want to make that list distinct,

var practiceAreas = from teamMember in AllTeamMembers
from teamMemberRelation in teamMember.TeamToTeamPracticeAreaRecords
select teamMemberRelation.TeamPracticeArea;
// DISTINCT ….
temp = practiceAreas.GroupBy(p => p.EntityId).Select(g => g.First()).ToList();
var categoryCollection = from item in AllItems
select item.Categories;
now make it distinct
var distinctCategoryCollection = categoryCollection .GroupBy(p => p.uid).Select(g => g.First())
neat ha ?
Comments
Posted in ASP.NET, c#, linq

15
Jan
2010

flash of unstyled content

have you ever seen a html page that loads unstyled and a second (sometimes more) after it “loads” its gets reorgenized ?
well this problem refered as “flash of unstyled content”.

it happens when the page content starts to load before the css files are completely loaded. you won’t see much of this problem using ie or any other browser other then firefox, thats because the way firefox renders the page is different then the other browsers. it rerender the page every time a new css rule is loaded, ie for example waits for all the page content(includes images) to be loaded and then it plots the rendered result (skipping the FOUC)

ok – so what can be done to avoid this annoing problem ?

i did some research on this issue – trying to find the best solution , and there is no 1 ultimate solution, you will have to optimize your page – reducing the loading size of the page, but more important is moving the css files to the top of your html, acutally to the top of your head section, css files must be loaded first, then the js files and other content.
normally we wont use javascript functions untill the domready event is thrown – so that won’t be a problem.

now, after doing so, we should try to compress the files,
search the web for a css compressor in your preferred language,
examples :
PHP : http://davidwalsh.name/css-compression-php
ASP.NET : http://madskristensen.net/post/Combine-multiple-stylesheets-at-runtime.aspx

the last one is a great example for combining and compressing the css files,
resulting in 1 css file that holds few files in it.

the same can be done with js files (compressing and mergin)
online js compressing can be done using Yahoo’s YUI Compressor (http://developer.yahoo.com/yui/compressor/)

or you can search for a php / .net server side js compressor.

Now, after doing these steps your page would weight alot less then it did before – maybe this step already solved your problem.

i would go on and load the images in photoshop and use the save for web method without the max resultion checked.

Hope this article helped you,

Ady.