Najem jadrnic na Hrvaškem – Gremo jadrat

Sončni žarki nas že vabijo na morje. Že veste kam greste letos jadrat? Najem jadrnic vzame veliko prostega časa. Veliko hitreje in brez stresa bo šlo, če se o izbiri posvetujte z izkušenimi strokovnjaki agencije Gremo jadrat. Vredni so zaupanja, saj že četrto leto številnim družinam in drugim skupinam pomagajo pri najemu jadrnic. Ker si želijo, da bi se imeli res nepozabno, vam razkrijejo tudi čudovite zalivčke, kjer se lahko zasidrate ali privežete na boje ter uživate v izbranih konobah. Cene jadrnic iz njihove ponudbe so res ugodne. Vse, kar morate narediti je, da izberete termin, marino in jadrnico.

2231_1

Po jadranju s prijatelji ali družino se boste z dopusta vrnili z nabito polnimi baterijami in pripravljeni na nove zmage. Obiščite nas na spletnem mestu www.gremojadrat.si.

Additions to this Web site have been blocked – SharePoint 2010

Just got a very interesting error in my SharePoint 2010. Not exactly sure how it came to be … but anyways. I was making some PowerShell updates to the site … also restored the site using PowerShell … maybe this left the site locked down eventually.

First I could not edit or add anything to my SharePoint 2010 site. I tried to log-out and sign-in again. Than I restarted the server – this also didn’t help. Than I tried to change the site collection administrators and I got “Additions to this Web site have been blocked” error. Than I was closer to the solution … had to go actually to Central Administration > Application Management > Site Collections > Configure quotas and locks and change the “Lock status” for the site to Not locked.

additions-web-site-blocked-sharepoint-2010

MTP Mode is enabled

Last night I just updated my HTC One to version 4.3 Jelly Bean. When I connected it to my computer I saw “MTP Mode is enabled”. So it seems this is already there since the version 3.0 Honeycomb but I didn’t notice it back than. At least it was not so obvious.
And what does it stand for? MTP simply stands for Media Transfer Protocol.

mtp-mode-is-enabled

If you want to read some more details go to the androidcentral link.

How To Clear DNS Cache In Mac OS and Windows

Ever wanted to clear DNS cache on your mac os? I use it all the time … and over and over again I am searching for the same command line. To keep the records also for me here it is:

1
$ dscacheutil -flushcache

Here is the line for CMD on your Windows machine:

1
C:\>ipconfig /flushdns

Install PEAR and add path to $PATH on Mac

Recently I was just installing PEAR and I needed to add it to $PATH. I stumbled upon site of muttsnutts notes and here is the path I’ve been following to do it:

Here is how to install PEAR:

1
2
3
$ cd /Users/robertkuzma
$ wget http://pear.php.net/go-pear.phar
$ php -d detect_unicode=0 go-pear.phar

The syntax for adding $PATH:

1
sudo sh -c 'echo "/Users/robertkuzma/pear/bin" >> /etc/paths.d/pear_path'

Eventually for PEAR to work in PHP you will also need to add the include line to php.ini file.

1
include_path=".:/Users/robertkuzma/pear/share/pear"

And how to check if pear is actually working in your PHP? You have to include System.php class because it comes embeded with PEAR.

1
2
3
4
5
6
7
8
9
10
<?php

require_once 'System.php';
if(class_exists('System')===true) {
    echo 'PEAR is installed!';
} else {
    echo 'PEAR is not installed :(';
}

?>

or a bit more simple:

1
2
3
4
5
6
<?php

require_once 'System.php';
var_dump(class_exists('System', false));

?>

PowerShell count number of characters in a string

I was just trying to count the number of characters in a string using PowerShell. It seems there is a very simple way to do it. It is a bit different if you are (me include) coming from a C language background like javascript, php or some other similar ones …

So the syntax is as follows:

1
2
3
4
$string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
$measureObject = $string | Measure-Object -Character;
$count = $measureObject.Character;
Write-Host $count;

I have written the code above on the examples from Scripting Guy! Blog.

Get SharePoint list items and export them to XML using PowerShell

Last time I was explaining how to get sharepoint 2010 list items using powershell script. Now, lets make a step forward and export those items into an XML file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
cls
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

$outputXmlFilePath="C:\Exports\yourfile.xml";
$webURL = "http://sharepointsite";
$listName = "listUwant2export";

$spWeb = Get-SPWeb $webURL;
$spList = $spWeb.Lists[$listName];
$spItems = $spList.GetItems();

[System.Xml.XmlTextWriter]$xml = New-Object 'System.Xml.XmlTextWriter' $outputXmlFilePath, ([Text.Encoding]::UTF8);
$xml.Formatting = "indented";
$xml.Indentation = 4;

$xml.WriteStartDocument();
$xml.WriteStartElement('root');

$spItems | ForEach-Object {

$xml.WriteStartElement('item');

$xml.WriteAttributeString("ID",$_['ID']);
$xml.WriteAttributeString("Title",$_['Title']);

$xml.WriteEndElement();
Write-Host $_['Title'];
}

$xml.WriteEndElement();

$xml.Flush();
$xml.Close();
$spWeb.Dispose();

The result will be an XML output with values as attributes.

Get items from SharePoint List using PowerShell script

For long time I wanted to dive a bit deeper into PowerShell. Hopefully I will be able to post few of the sharepoint powershell tricks here.
First one is about getting list items from a sharepoint list:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
cls
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
    Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

$sourceWebURL = "http://sharepointsite"
$sourceListName = "mylist"

$spSourceWeb = Get-SPWeb $sourceWebURL
$spSourceList = $spSourceWeb.Lists[$sourceListName]
#$spSourceItems = $spSourceList.GetItems()
#$spSourceItems = $spSourceList.GetItemById("1")
$spSourceItems = $spSourceList.Items | where {$_['ID'] -eq 1}

$spSourceItems | ForEach-Object {
    Write-Host $_['ID']
    Write-Host $_['Title']
}

You can either get all the items with GetItems() method currently commented out or you can filter items by some parameters. Filter applied in the script above is also equal to the GetItemById(“1”) method.

SharePoint Webservice SOAP Call for “recently changed items”

I just read a tweet question: @robertkuzma do you know syntax for web service call to get “recently changed items” from share point?

The important thing here is to properly create the XML you are posting. The article Writing CAML Queries For Retrieving List Items from a SharePoint List might be usefull to construct the SOAP call needed.

Check out the code below – will get you the items modified in last 3 days:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
            <listName>yourListNameHere</listName>
            <query>
                <Query>
                    <Where>
                        <Geq>
                            <FieldRef Name="Modified" />
                            <Value Type="DateTime"><Today OffsetDays="-3" /></Value>
                        </Geq>
                    </Where>
                </Query>
            </query>
        </GetListItems>
    </soap:Body>
</soap:Envelope>

Don’t forget to add SOAPAction = “http://schemas.microsoft.com/sharepoint/soap/GetListItems” to the header of your POST SOAP call.

Making a POST in Objective-C (Xcode) to SharePoint Webservice requiring Windows NTLM Authenticaton for iPhone or Ipad

Xcode logoIn my previous posts I was talking about how to use SOAP to SharePoint Webservices using different programing languages (PHP, Android – Java). I found it very convenient to be able to publish also a sample how to do the same in Xcode (Objective-C).

I also had to browse the web quite a bit. Finilly I stumbeled upon article from Ravi Dixit about the tipical webservice changing celsius to fahrenheit. Becase I was missing some steps in the code Erhan Demirci steped in. Because I also needed to authenticate this article came handy. I connected the dots, changed the SOAP request and displayed the responce in the screen (also in the log).

When creating new project in Xcode just choose View-based Application, name it “SoapSharePoint” and copy-paste the code below.

The SoapSharePointController.h code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#import <UIKit/UIKit.h>

@interface SoapSharePointViewController : UIViewController <NSXMLParserDelegate> {

    IBOutlet UILabel *output;
    NSMutableData *webData;
    NSXMLParser *xmlParser;
    NSString *finaldata;
    NSString *convertToStringData;
    NSMutableString *nodeContent;

}
@property (nonatomic,retain) UILabel *output;
-(IBAction)invokeService;

@end

And the SoapSharePointController.m file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#import "SoapSharePointViewController.h"

@implementation SoapSharePointViewController
@synthesize output;

-(IBAction)invokeService
{
   
        nodeContent = [[NSMutableString alloc]init];

        NSString *soapFormat = [NSString stringWithFormat:@"<?xml version="1.0" encoding="utf-8"?>\n"
                                "<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">\n"
                                "<soap:Body>\n"
                                "<GetListCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/" />\n"
                                "</soap:Body>\n"
                                "</soap:Envelope>\n"];

       
       
        NSLog(@"The request format is %@",soapFormat);
       
        NSURL *locationOfWebService = [NSURL URLWithString:@"http://localhost/_vti_bin/lists.asmx"];
       
        NSLog(@"web url = %@",locationOfWebService);
       
        NSMutableURLRequest *theRequest = [[NSMutableURLRequest alloc]initWithURL:locationOfWebService];
       
        NSString *msgLength = [NSString stringWithFormat:@"%d",[soapFormat length]];
       
       
        [theRequest addValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
        [theRequest addValue:@"http://schemas.microsoft.com/sharepoint/soap/GetListCollection" forHTTPHeaderField:@"SOAPAction"];
        [theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"];
        [theRequest setHTTPMethod:@"POST"];
        //the below encoding is used to send data over the net
        [theRequest setHTTPBody:[soapFormat dataUsingEncoding:NSUTF8StringEncoding]];
       
       
        NSURLConnection *connect = [[NSURLConnection alloc]initWithRequest:theRequest delegate:self];
       
        if (connect) {
            webData = [[NSMutableData alloc]init];
        }
        else {
            NSLog(@"No Connection established");
        }
   
}


//NSURLConnection delegate method

-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    [webData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    [webData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    NSLog(@"ERROR with theConenction");
    [connection release];
    [webData release];
}

-(BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
{
    return YES;
}

-(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
    NSURLCredential *credential = [NSURLCredential credentialWithUser:@"username" password:@"password" persistence:NSURLCredentialPersistenceForSession];
    [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
}


-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    NSLog(@"DONE. Received Bytes: %d", [webData length]);
    NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
    NSLog(@"%@",theXML);
   
    convertToStringData = [[NSString alloc] initWithData:webData encoding:NSUTF8StringEncoding];
   
    output.numberOfLines = 0;
    output.text = convertToStringData;
    [output sizeToFit];
   
    [connection release];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)viewDidUnload {
    [super viewDidUnload];
}


- (void)dealloc {
    [output release];
    [convertToStringData release];
    [super dealloc];
}

@end

Also don’t forget to create a label and a button in the XIB (nib) file. Connect the the File’s Owner in outlets output to label and in the received action invokeService to button.

Or you can simply download it.