Archive: 2012

Reading Binary Tile Map Data on Windows Phone

Scott Walker · Sep 28, 2012
The problem I ran into when trying to create a Tile Mapping engine was reading data on Windows Phone. Windows Phone will not allow the below namespace so I had to go another route.

using System.Runtime.Serialization.Formatters.Binary;

Windows Phone has a class called TileContainer which allows access to the Phone's Content area.


             try
            {
                Stream path = TitleContainer.OpenStream("Content/Maps/" + map);
                using (BinaryReader br = new BinaryReader(path))
                {
                    for (int x = 0; x < MapWidth; x++)
                    {
                        for (int y = 0; y < MapHeight; y++)
                        {
                            mapCells[x, y] = new MapSquare(
                                br.ReadInt32(), // Background Layer
                                br.ReadInt32(), // Interactive Layer
                                br.ReadInt32(), // Foreground Layer
                                br.ReadString(), // CodeValue
                                br.ReadBoolean()); // Passable
                        }
                    }
                }


đŸ’Ŧ 0 C# Windows Phone

Using jQuery Templates to Search Blog Posts

Scott Walker · Sep 13, 2012

Using JQuery Templates to search Blogs.

Place the Jquery Templates script on the layout page or on the page using the template:

jQuery.tmpl.min.js

The JavaScript file contains the code below:

đŸ’Ŧ 0 Jquery Templates

Loading and Parsing Tweets from a Twitter Feed (Legacy XML API)

Scott Walker · Mar 22, 2012

The LoadTweets() function pulls in a certain amount of tweets from a Twitter account. This function parses the tweet and updates links so that they are clickable.

The URL below will send an XML result. Change the publictimeline to a valid Twitter account and indicate the amount of tweets you need to receive.

http://twitter.com/statuses/user_timeline/publictimeline.xml?count=
đŸ’Ŧ 0 Twitter JavaScript XML

Performing LIKE '%query%' Searches in LINQ

Scott Walker · Mar 16, 2012
When searching and the need arises for LIKE '%query%' using Linq to SQL, use below:

        [Route("search")]
        [HttpPost]
        public IActionResult Search(string search)
        {
            var posts = _db.Posts
                .Where(x => x.Body.Contains(search))
                .Where(x => x.Title.Contains(search)).ToArray();

            ViewBag.SearchCriteria = search;
            ViewBag.TagView = new TagView(_db);

            return View(posts);
        }


Older/Redacted code


using System.Data.Linq.SqlClient;
result = (from b in db.Blogs
   where SqlMethods.Like(b.Title, "%" + keyword + "%") ||  
   SqlMethods.Like(b.Body, "%" + keyword + "%")  
   orderby b.AddedDate descending
   select b);

đŸ’Ŧ 0 Linq SQL