Skip to content

Instantly share code, notes, and snippets.

@gergob
gergob / Animals.js
Created November 24, 2012 19:14
Animals
/// <reference path="//Microsoft.WinJS.1.0/js/base.js" />
/// <reference path="//Microsoft.WinJS.1.0/js/ui.js" />
(function () {
"use strict";
WinJS.Namespace.define("Zoo", {
Animal: WinJS.Class.define(
@gergob
gergob / zoo.json
Created November 24, 2012 22:02
Data of transferred animals
[{
"name" : "King",
"age" : 5,
"hoursSinceLastFeed" : 3
},
{
"name" : "Geeko",
"age" : 2,
"hoursSinceLastFeed" : 12
},
@gergob
gergob / buildAnimal.js
Created November 24, 2012 22:41
buildAnimal function
buildAnimal: function (model) {
var newAnimal = new Zoo.Animal();
if (model.hasOwnProperty("name")) {
newAnimal.setName(model.name);
}
if (model.hasOwnProperty("age")) {
newAnimal.setAge(model.age);
@gergob
gergob / loadZoo.js
Created November 24, 2012 22:46
loadZoo function
loadZoo: function (uri) {
//IMPORTANT TO RETURN THE PROMISE
return Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri)
.then(function (file) {
return Windows.Storage.FileIO.readTextAsync(file)
.then(function (textFromFile) {
var myParsedJsonData = JSON.parse(textFromFile);
//this will store all the new animals transferred to zoo
var zoo = new Array();
@gergob
gergob / processAndDisplayZooJSON.js
Created November 24, 2012 23:16
Process and display zoo.json
args.setPromise(WinJS.UI.processAll().then(function() {
//build up the URL for the file added to the project
var url = new Windows.Foundation.Uri("ms-appx:///zoo.json");
//this will store the imported data
var myNewAnimals = new Array();
//invoke the static method which loads the file
//and creates Animal objects from json data
@gergob
gergob / yes.js
Created July 18, 2013 21:28
Contains the implementation of linux's yes command.
#!/usr/bin/env node
/*
This small node.js app should do exactly what the yes linux command does.
Quote from man yes:
Repeatedly output a line with all specified STRING(s), or `y'.
*/
@gergob
gergob / wc.js
Created July 26, 2013 21:03
Contains the implementation of the wc linux command using node.js
#!/usr/bin/env node
/*
This small node.js app should do exactly what the wc linux command does.
Quote from man wc:
Print newline, word, and byte counts for each FILE, and a total line if more than one FILE is specified. With no FILE, or when FILE is -, read standard
input. A word is a non-zero-length sequence of characters delimited by white space. The options below may be used to select which counts are printed,
always in the following order: newline, word, character, byte, maximum line length.
@gergob
gergob / fstat.js
Created July 26, 2013 21:17
contains the node.js fstat methods
//
// Method names taken from: http://nodejs.org/api/fs.html#fs_class_fs_stats
//
//stats is the return value if fs.statsync(PATH_TO_FILE) method
stats.isFile();
stats.isDirectory();
stats.isBlockDevice();
stats.isCharacterDevice();
stats.isSymbolicLink(); //(only valid with fs.lstat())
@gergob
gergob / hello_vilag.js
Created October 23, 2013 16:17
FLOSSzine - Programozás Kezdőkenk - Bevezető - Hello Világ!
//minden szöveg, amelyet // előz meg,
//illetve /* ... */ jelek közzé teszünk
//a JavaScript kommentként kezeli és figyelmen kívül hagyja
alert("Hello Világ!");
@gergob
gergob / hello.html
Created October 23, 2013 16:28
FLOSSzine - Programozás Kezdőkenk - Bevezető - Hello Világ!
<!-- HTML fájlokba ezen jelek közzé lehet kommentárokat tenni -->
<!DOCTYPE html>
<html>
<!-- HTML dokumentum fej része -->
<head>
<!-- Erre azért van szükség, hogy a böngésző meg tudja jeleníteni az ékezetes magyar betüket -->
<meta charset="utf-8">
<!-- Hivatkozunk az előzőekben megírt JavaScript kódfájlunkra -->
<script src="hello_vilag.js" type="text/javascript"></script>