Sunday, November 15, 2015

Consuming a RESTful Web Service Video and Notes

mkdir src/main/java/hello

@JsonIgnoreProperties - any properties not bound in this type should be ignored.

gradle bootRun
or
gradle build
java -jar build/libs/gs-consuming-rest-0.1.0.jar

OR

gradle wrapper
./gradlew bootRun
or
./gradlew build
java -jar build/libs/gs-consuming-rest-0.1.0.jar

OR

mvn spring-boot:run
or
mvn clean package
java -jar target/gs-consuming-rest-0.1.0.jar

output:
2015-11-14 03:20:26.415  INFO 23613 --- [main] hello.Application  : Quote{type='success', value=Value{id=12, quote='@springboot with @springframework is pure productivity! Who said in #java one has to write double the code than in other langs? #newFavLib'}}

Thursday, November 12, 2015

Building Java Projects with Maven Video and Notes

mvn compile
mvn package
mvn install

Greeter.java
package hello;

public class Greeter{
public String sayHello(){
return "Hello world!";
}
}

HelloWorld.java
package hello;

import org.joda.time.LocalTime;

public class HelloWorld{
public static void main(String[] args){
LocalTime currentTime = new LocalTime();
System.out.println("The curent local time is " + currentTime);
Greeter greeter = new Greeter();
System.out.println(greeter.sayHello());
}
}

pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.springframework</groupId>
    <artifactId>gs-maven</artifactId>
    <packaging>jar</packaging>
    <version>0.1.0</version>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.2</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer                                  implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>hello.HelloWorld</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Wednesday, November 4, 2015

Building Java Projects with Gradle Video and Notes

gradle tasks
gradle wrapper
gradlew build
gradlew run
jar tvf build/libs/gs-gradle-0.1.0.jar

HelloWorld.java
package hello;

import org.joda.time.LocalTime;

public class HelloWorld{
public static void main(String[] args){
LocalTime currentTime = new LocalTime();
System.out.println("The current local time is: " + currentTime);

Greeter greeter = new Greeter();
System.out.println(greeter.sayHello());
}
}

Greeter.java
package hello;

public class Greeter{
public String sayHello(){
return "Hello world!";
}
}

//build.gradle file starts
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'

mainClassName = 'hello.HelloWorld'

repositories{
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile "joda-time:joda-time:2.2"
}

jar{
baseName = 'gs-gradle'
version = '0.1.0'
}

task wrapper(type: Wrapper){
gradleVersion = '2.3'
}
//build.gradle file ends

Tutorial Fly YouTube Channel


Tuesday, October 13, 2015

Wednesday, October 7, 2015

Monday, October 5, 2015

Tuesday, August 4, 2015

Enable Execution of Powershell Scripts inside Visual Studio

























PS P:\>Set-ExecutionPolicy unrestricted
PS P:\>Set-ExecutionPolicy remotesigned

Note: clear all *.licx files

Tuesday, July 21, 2015

Compressed AJAX Data

String Extension Method Zip:
public static byte[] Zip(this string str)
{
var bytes = Encoding.ASCII.GetBytes(str);
using (var memorystreaminput = new MemoryStream(bytes))
using (var memorystreamoutput = new MemoryStream())
{
using (var gs = new GZipStream(memorystreamoutput, CompressionMode.Compress))
{
memorystreaminput.CopyTo(gs);
}
return memorystreamoutput.ToArray();
}
}

Repository Save:
var showsIQueryable = GetShowsIQueryable();
var serializer = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue };
var data = serializer.Serialize(showsIQueryable);

var compressedDataBlob = data.Zip();

//stores compressedDataBlob

Controller ActionResult Get:
var showsJsonText = _showService.CommandRepo.GetShowsCache();
Response.Headers.Remove("Content-Encoding");
Response.AppendHeader("Content-Encoding", "gzip");

return new FileContentResult(showsJsonText, "application/javascript");

JavaScript:
$.ajax({
type: "POST",
url: serverUrl,
dataType: 'json',
cache: false,
async: true,
data: JSON.stringify(model),
contentType: "application/json; charset=utf-8"
}).done(function (data) {
....
});

HTML:
<script type="text/javascript">
var shows = @Html.Raw(new JavaScriptSerializer().Serialize(Model.Shows)
</script>

Thursday, July 16, 2015

Friday, July 10, 2015

Watching: Website Performance

























Website Performance
Introduction
Make Performance a Priority
Why web performance?
Performance and user experience
How we get web performance
Focus on the critical path
The total cost of ownership
The Middle-End: YSlow
YSlow rules
Beyond the big 14
The Middle-End: Resources
Images
Minification
The Middle-End: Architecture & Communication
Understanding the middle-end
Introduction to architecture
Data validation
JSON, ajax, & Web sockets
The Front-End: Resource Loading
Preloading images
Lazy loading
Parallel loading
The Front-End: Abstractions & Animation
OO is slower
JavaScript animations
CSS transition vs. css animation
The Front-End: UI Thread, Garbage Collection & jsPerf
The single threaded browser
Threaded JavaScript
Dynamic memory allocation
Introduction jsPerf
JavaScript performance mythbusters

Wednesday, May 13, 2015

Friday, April 17, 2015

3 Ways to Load Html with HtmlAgilityPack

Method 1:
var web = new HtmlWeb();
var doc = web.Load(sourceUrl);

Method 2:
var uri = new Uri(sourceUrl);
var request = (HttpWebRequest)WebRequest.Create(uri);
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
var response = (HttpWebResponse)request.GetResponse();

var doc = new HtmlDocument();
var stream = response.GetResponseStream();
doc.Load(stream, Encoding.UTF8);

Method 3:
using (var wc = new WebClient()){
html = wc.DownloadString(sourceUrl);
}
var doc = new HtmlDocument();
doc.LoadHtml(html);

Monday, February 16, 2015

Case-insensitive and Accent-insensitive String Comparison in Linq to SQL

ALTER TABLE Stories ALTER COLUMN Name [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AI

Friday, January 30, 2015

Wednesday, January 28, 2015

AngularJS Directives

ng-app
ng-controller
ng-model
ng-click
ng-submit
ng-repeat
ng-view
ng-show
ng-hide

Tuesday, January 27, 2015

Watching: AngularJS: Get Started























Link: http://www.pluralsight.com/courses/angularjs-get-started

Watching: Building Mobile Apps With the Ionic Framework and AngularJS























Link: http://www.pluralsight.com/courses/building-mobile-apps-ionic-framework-angularjs

Wednesday, January 21, 2015