Chrome dev tools Auto save
Posted: Sunday, December 18, 2011 by Unknown in Labels: Coding practises/ProgrammingAuto-saving CSS And JavaScript Changes Locally From The Chrome Developer Tools.
Pretty cool stuff, saves lot of development time.
things which are blown up in the quest for knowledge
Auto-saving CSS And JavaScript Changes Locally From The Chrome Developer Tools.
Pretty cool stuff, saves lot of development time.
No matter who you are
No matter which profession is yours
You have to go social and feel the power of social way of living, social way of collaborating, social way of connecting...etc
Very simple things but yields greater performance.
We have been seeing the trend of moving to social from each and every individual. The testimony of this is that facebook has around 800 Million users and recently they announced that around 500 million users are online at a time.
Every individual is spending most of the time in social networks by sharing posts, stay connected to friends status updates blah blah....
That facebook crazy question "What's on your mind?" tempting every one to share things irrespective of the topic.
I think, The era of enterprises moving to social started now. Sounds crazy!!! Yes, this is what exactly "Social Enterprise". It exactly means that "Get in touch about your company branding from your customers, who are social :)"
IMO, facebook did great job in moving individuals to social & hopefully salesforce.com will do great job in moving enterprises to social.
Very nice video on how "Burberry" can become social enterprise.
Go social.. Go Social
Cheers!!!!
We are moving towards a world where desktop and web based applications merge. Where the term personal computer doesn't just mean desktops but also includes mobile devices. Where applications and data belong to the cloud and can move from one device to another.
IMO, the credit for merging desktop and web based applications goes to Google and the credit for creating the 'personal devices' market and providing a common way to access data and applications across these devices goes to Apple.
Here is the Chrome latest release where we can run c/c++ apps inside browser.
Very cool stuff!!!
I have spent enough time in finding memory leak detection tool and explored few tools such as sIEve, Drip, Software Verification Javascript memory observer, IEMemoryleakDetector....etc.
Unfortunately i could not find them helpful to me. After further investigation i realized that browser system process private bytes consumption is the best way to identify if the app is leaking memory or not.
I used processexplorer.exe to monitor private bytes of a process but here there is no option to record and play the memory consumption.
One of my earlier posts will be useful in recording private bytes of any windows system process.
I don't find any tool which can be used for recording windows system process memory and used for later review.
There are some tools like process explorer but these are live it won't allow us to record the memory graph. So i decided to write java client which will poll periodically using DOS command WMIC and get the private bytes of a system process.
Usage :-
Paste the below code and put in MemoryMonitor.java
javac MemoryMonitor.java
java MemoryMonitor process_name poll_interval test_duration file
java MemoryMonitor firefox.exe 5 60 d:\\test.csv
So ideally, test.csv contains private bytes data of all intervals later you can use this file for drawing graphs.
Cheers!!!!!!!!!!
Here is the program code:-
import java.awt.Toolkit;
import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
//java MemoryMonitor firefox.exe 5 60 d:\\test.csv
public class MemoryMonitor {
public String PROCESS_NAME = "eclipse.exe";
public int TIME_INTERVAL = 5; // in seconds
public int TOTAL_TEST_TIME = 60; // in seconds
public String DESTINATION_FLE = "d:\\memory_usage.csv";
Toolkit toolkit;
Timer timer;
Timer timer1;
List memoryList;
public MemoryMonitor(String args[]){
PROCESS_NAME = args[0] ; TIME_INTERVAL = Integer.parseInt(args[1]) ; TOTAL_TEST_TIME = Integer.parseInt(args[2]) ; DESTINATION_FLE = args[3];
memoryList = new ArrayList();
toolkit = Toolkit.getDefaultToolkit();
timer = new Timer();
timer1 = new Timer();
timer1.schedule(new ExitTimerTask(), TOTAL_TEST_TIME * 1000);
scheduleTimer();
}
public void scheduleTimer(){
getMemoryDetails();
timer.schedule(new MemoryDetailsTask(), TIME_INTERVAL * 1000);
}
public void getMemoryDetails(){
try {
Process proc = Runtime.getRuntime().exec("WMIC PROCESS where Caption=\""+PROCESS_NAME+"\" get PageFileUsage");
InputStream procOutput = proc.getInputStream();
String value = readInputStreamAsString(procOutput);
String array[] = value.split("\n");
double privateBytesValue = 0;
for(int i = 1 ; i < array.length ; i++){
if(array[i].trim().length()>0){
String privateBytes = array[i].substring(0, array[i].indexOf(" "));
privateBytesValue+= Double.parseDouble(privateBytes) / 1024;
}
}
System.out.println(privateBytesValue);
memoryList.add(privateBytesValue);
} catch (Exception e) {
System.out.println("Error occured");
e.printStackTrace();
System.exit(0);
}
}
public String join(List list, String conjunction)
{
StringBuilder sb = new StringBuilder();
boolean first = true;
for (Object item : list)
{
if (first)
first = false;
else
sb.append(conjunction);
sb.append(item);
}
return sb.toString();
}
public String readInputStreamAsString(InputStream in) throws IOException {
BufferedInputStream bis = new BufferedInputStream(in);
ByteArrayOutputStream buf = new ByteArrayOutputStream();
int result = bis.read();
while (result != -1) {
byte b = (byte)result;
buf.write(b);
result = bis.read();
}
return buf.toString();
}
class MemoryDetailsTask extends TimerTask {
public void run() {
getMemoryDetails();
scheduleTimer();
}
}
class ExitTimerTask extends TimerTask {
public void run() {
try {
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(DESTINATION_FLE),"UTF8"));
out.write(join(memoryList,","));
out.close();
System.out.println("Please find this file for the report "+DESTINATION_FLE);
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println("Not able to write to the file "+DESTINATION_FLE);
e.printStackTrace();
};
System.exit(0);
}
}
public static void main(String args[]) {
new MemoryMonitor(args);
}
}
In javascript, We can write programs in very optimized manner as we can send functions as arguments or as return values. Here is a small snippet of code where we can avoid repeat work.
function addHandler(elem, event, handler){
if(elem.addEventListener){ // DOM2
addHandler = function(elem, event, handler){
elem.addEventListener(event, handler, false);
}
}else{ // IE
addHandler = function(elem, event, handler){
elem.attachEvent("on" + event, handler);
}
}
addHandler(elem, event, handler);
During addHandler fist call the function definition varied.
I hope you will really enjoy following video and will get to know new way of javascript coding from Jquery source.
Paul Irish : 10 Things I Learned from the jQuery Source from yayQuery on Vimeo.
Generally we might need to modify the structure and behaviour of a program at runtime
(or )
we have to call a method of a class but we will get class name and method at runtime only. I mean during compile time we dont know what to use.
In these type of scnerios we can opt for reflection style of programming. I will show you sample program how to use in different languages.
Java:-
// No Reflection
new Foo().hello();
// After Reflection
Class cls = Class.forName("Foo");
cls.getMethod("hello", null).invoke(cls.newInstance(), null);
Javascript:-
// No Reflection
new Foo().hello()
// After Reflection
new (eval('Foo'))()['hello']()
Python:-
# No Reflection
Foo().hello()
# After Reflection
getattr(globals()['Foo'](), 'hello')()
I wanted to share few things how i thrive into a startup company.
1) Self motivation
2) Be Transparent
3) Very passionate
4) Be hungry every minute
5) Let my manager knows my strengths, weakness and expectations
6) If I feel disgruntled then analyzed myself immediately
7) Expect less from others
8) Start with doable things once we see any working prototype we can scale it to any extent.
9) Shout immediately if i stuck any where
10) Built Good reliability by attitude.
At least,
I did these things for the first 1.5 years. Later anyhow i get habituated with these things :)
Javascript memory leaks especially in IE during removal of any DOM element (or) setting innnerHTML property. During those actions we should explicitly set "null" to their event handler's property. Have a look at "purge" function in the following link.
Source:- http://javascript.crockford.com/memory/leak.html
In my last post i wrote about HTML5 websocket. As i dig into it i found jwebsocket.
Here is my observation:-
Pros:-
1) jWebSocket is a pure Java/JavaScript high speed bidirectional communication solution for the Web - secure, reliable and fast.
2) Make use of websockets if the browser does not support this then it will fallback to flashbridge.
3) Standalone jwebsocket server is provided. You can even add jwebsocket capabilities to existing web servers like jetty,tomcat..etc.
4) Client side plug-in is available so that you can think about only on application logic.
5) Can be used in different ways like Chat, Steaming, RPC, Shared object, Shared canvas. Lot of demos are there in the site.
Cons:-
1) What if flash crashed because of some other application in the browser.
2) Could have provided long polling too as another fallback option.
3) Need to support SSL for all browsers.
4) Could have provided some tool to perform load/stress tests. Since it is not http communication we can not perform load tests using Jmeter..etc.
Finally it is pretty awesome and very good. I am exploring it. If anyone of you using it please let me know about its performance.
Lets have a look at facebook's Javascript style. It is awesome!!!
Most of the REST web services JSON response will be like
while(1);{"feedItem": "sdf","status": "sdfsdf","updateTime": "sdfsdf"}
for(;;);{"t":"continue"}
for(;;);["a","b","c"]
Just go through the HTTP calls made inside in Facebook, Google calender, Chatter ..etc then you can find such responses.
while(1); , for(;;); all these are infinite loops, this is ensure that some other websites cant hack other sites data. By using this we can prevent Cross domain AJAX requests made using script tags.
I was so impressed while reading these issues which are to be addressed as part of Business plan from Subroto Bagchi book "The High performance Entrepreneur"
1) What is the mission and vision of the organization?
2) What is my product or service? How will it evolve as a family of products or services?
3) What is the competitive landscape? How are other leading player serving the market? What trends do market research and analyst reports indicate?
4) In what way will I be different? Why should someone buy my products or services?
5) How will I get my first, paying customer? How will I price my goods or services?
6) What will be my marketing strategy?
7) What organization structure will I need? What critical skills do the founders possess and which ones need to be supplemented?
8) What capital expenditure will be needed and why? How have I determined and adequacy and the cost?
9) What revenue expenditure will be needed for the same period?
10) How is my cost structure different from that of the competition?
11) What is my three-year cash flow?
12) When will the organization reach break even?
13) What is the funding plan? How much of it will come from personal capital, how much from venture funding and what portion from loans?
14) What is the plan for recruitment, training and retention of people?
15) What are the R&D plans? How will the activity be sustained over time?
16) What are the manufacturing and distribution plans?
17) What are the various risks involved in building the organization?
18) In what way will the team de-risk those?