Skip to content

Instantly share code, notes, and snippets.

@akanshmurthy
akanshmurthy / java.txt
Last active November 27, 2017 21:15
Java
Java highlights from Head First Java
- public static main; at least one per app
- source code -> compile -> byte code -> run on platform independent JVMs
- bool and int are not compatible -> no int x = 1; if (x)
- class = blueprint for object; object oriented = inheritance with superclass -> DRY
- main only really used to test or start the Java app
- every time an object is created in Java, it is stored in memory called the heap (a garbage-collectible heap)
-> JVM does a lot of the magic to manage the heap
- jar = when you have lots of classes
@akanshmurthy
akanshmurthy / angular.txt
Last active November 27, 2017 04:06
Angular
Angular highlights from ng-book
- live data-binding
- $digest() for dirty checking if value has changed
- bind by attribute rather than raw object (clock.now vs clock)
- scope = glue between controller and view
- $scope.$apply for callbacks outside Angular context
- only ng-controller and ng-repeat directives create own scope
- DOM manipulation not in controller
- nesting controllers gives you access to parent scope
@akanshmurthy
akanshmurthy / web_rtc.md
Last active January 20, 2017 07:56
3 reasons why WebRTC will rock your socks!

Wait, what is WebRTC?

Let me ask you a question. Does it pain you to have to download a third-party application or plugin to do simple things like have a video or audio chat? (I'm looking at you, Skype and Google Hangouts). Worse, imagine building an application that utilizes video or audio chat and having to write codecs for native apps. Web Real Time Communication, known among friends as WebRTC, to the rescue!

The 3 reasons:

  1. It is free.
  2. It is well supported.
  3. It is simple.

Free

WebRTC is an open source project with many spin-offs in various languages. The only part of WebRTC that is not built-in is its signaling mechanism or protocol, which is required to coordinate communication between the browsers involved in the connection. Messing with the signaling (mainly, STUN and TURN servers) manually can get hairy quickly so the easiest option is to use already-hosted public servers or to use a service that takes care of that for you, such as PubNub, Twilio, XirSys, a

@akanshmurthy
akanshmurthy / modals.js.jsx
Last active October 24, 2015 21:04
Using Bootstrap modals as show pages for elements in Rails with React.js and Flux
//app/components/
postClicked: function(post, e){
e.preventDefault();
if (post.body) {
ModalActions.showModal(post.body);
} else {
ModalActions.showModal(post.field_name, post.field_value);
}
},