Skip to content

Instantly share code, notes, and snippets.

View teocci's full-sized avatar
👨‍💻
Coding

Teocci teocci

👨‍💻
Coding
View GitHub Profile
@teocci
teocci / PersistingDataWithTempData.md
Last active June 2, 2016 17:50
TempData is used to pass data from current request to subsequent request.

Persisting Data with TempData

TempData is used to pass data from current request to subsequent request, this means redirecting from one page to another. It’s life is very short and lies only till the target view is fully loaded. But you can persist data in TempData by calling Keep() method.

TempData with Keep method

If you want to keep value in TempData object after request completion, you need to call Keep method with in the current action. There are two overloaded Keep methods to retains value after current request completion.

void Keep()

Calling this method with in the current action ensures that all the items in TempData are not removed at the end of the current request.

@model MyProject.Models.EmpModel;
@{ 

Session Variables as Objects

Or you could think of this as session objects. Either way the end result is the same. Everyone uses session variables at some point in their career. What I am doing is offering what I feel is a better way to deal with session variables.

When I have used session variables in the past I had two main issues; having to remember names and converting them when they were other than string. Not to mention using Session["SomeName"] was just too much typing without intellisense. Some people have wrapped their session variables with getters and setters. That is a nice idea, but still a bit too much work for what I want to do. After all I want my code to work for me, not just work. What if we save a class as a session object, and have the class save itself seamlessly as a session variable. This works great because you access the class thus giving you intellisense, strongly typed variables and you don't need to worry about checking the session since it is all in the class.

To dem

Accessing Session from Javascript using JQuery, AJAX in ASP.Net

Well, well well, this is one of those problems which crops out many a time while developing web application “How do i access session variables in my Javascript?” Usually the answer is you cannot, simply because sessions are stored on the server (backside) and your application is running on some remote client (Firefox de m...). Theoretically that is truth, but not the whole truth. Let us dispel the misconception.

Accessing session variables in ASP.Net

Well as we said before, it is not completely true when someone tells you, that session values cannot be used in JavaScript. It can be done, but with limitations. You can only have read-only access:).

This sample will show how we do it

//Consider you have set the following session variable in code-behind

NDK support in Android Studio

NDK support requires the use of Android NDK (r10e or above) and the android gradle-experimental plugin (0.7.0-alpha1). NDK support for the gradle(-stable) plugin, check this article on the NDK and Android Studio. This user guides provides general details on how to use it and highlights the difference between the experimental plugin and the original plugin. (This guide is based on the gradle-experimental 0.7.0 and Android Studio 2.1)

Setting up the gradle-experimental plugin

A typical Android Studio project may have a directory structure as follows. Files that we need to change are marked with a "*":

.

How To Install Node.js on an Ubuntu 14.04 server

Node.js is a Javascript platform for server-side programming that allows users to build network applications quickly. By leveraging Javascript on both the front-end and the back-end, development can be more consistent and be designed within the same system.

In this guide, we'll show you how to get started with Node.js on an Ubuntu 14.04 server.

If you are looking to set up a production Node.js environment, check out this link: How To Set Up a Node.js Application for Production.

How To Install the Distro-Stable Version

Ubuntu 14.04 contains a version of Node.js in its default repositories that can be used to easily provide a consistent experience across multiple servers. The version in the repositories is 0.10.25. This will not be the latest version, but it should be quite stable.

ZoneMiner Installation: Build Package From Source

(These instructions assume installation from source on a ubuntu 14.x+ system)

First we make sure you have the needed tools

sudo apt-get update
sudo apt-get install cmake git

Next up we make sure you have all the dependencies

NetBeans IDE Keyboard Shortcuts I use the most

Initially for exploration of the features working with mouse may feel fancy but as you continue using the tool for project development and want to concentrate more on task in hand you start finding ways to do things faster. NetBeans IDE 6.1 provides many keyboard shortcuts if used judiciously they can save a lot of developers time.

I use certain shortcut keys more often than other keys. This is a list of the keyboard shortcuts for NetBeans IDE which I use in my day to day development tasks.

CTRL+F12 Navigate to Member

When my class becomes big and there are many methods in the class navigating to a specific method becomes easy with this dialog box.

Simple Chat Using PHP Socket + HTML5 WebSocket

HTML5's Websocket provides an important feature for establishing a socket connections between web browsers and servers. Once the connection has been established with the server, all the messages are sent directly over a socket rather than usual HTTP response and requests, giving us much faster and persistent communication between a web browser and a server. In this tutorial, let’s create a simple chat system using this technology.

Chat Server using PHP Socket: The Implementation

First, we need to create a Socket server that runs permanently, performs the handshaking, send/receive data from the chat page, and finally handles multiple clients. To this end, we will create a daemon script in PHP. I know what you might be thinking, PHP is mostly used to create dynamic webpages, BUT we can also create background daemons using nothing but PHP. How we do that? Well just follow this steps:

1. Install WebSocket Server

After finished with the Installation of a