Skip to content

Instantly share code, notes, and snippets.

@ajduke
ajduke / JSFUN.md
Last active August 29, 2015 13:56 — forked from azat-co/JSFUN.md

JS FUNdamentals

If it's not fun, it's not JavaScript.

Expressiveness

Programming languages like BASIC, Python, C has boring machine-like nature which requires developers to write extra code that's not directly related to the solution itself. Think about line numbers in BASIC or interfaces, classes and patterns in Java.

On the other hand JavaScript inherits the best traits of pure mathematics, LISP, C# which lead to a great deal of expressiveness (and fun!).

@ajduke
ajduke / task.java
Last active August 29, 2015 13:57
desc
public class Task1 {
public static void main(String[] args) {
// run in a second
final long timeInterval = 1000;
Runnable runnable = new Runnable() {
public void run() {
while (true) {
// ------- code for task to run
import java.util.Timer;
import java.util.TimerTask;
public class Task2 {
public static void main(String[] args) {
TimerTask task = new TimerTask() {
@Override
public void run() {
// task to run goes here
@ajduke
ajduke / s3.json
Created March 18, 2015 18:10
amazon-s3-part-1
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"AddPerm",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::ExampleBucket/*"]
}
@ajduke
ajduke / ErrorHandlerWrapper.js
Created April 10, 2015 05:54
Javascript Error handler
var fs = require('fs')
fs.readFile('app.js', errorHandler(function (content) {
console.log('File contents are ' + content)
})
)
function errorHandler(callback) {
return function (err, result) {
@ajduke
ajduke / output.json
Created April 11, 2015 11:11
JSON Gist
[
{
"raw": "This is some text to demonstrate how a recursive parser works it has ",
"data": "This is some text to demonstrate how a recursive parser works it has ",
"type": "text"
},
{
"raw": "b",
"data": "b",
"type": "tag",
@ajduke
ajduke / FinalVariable.java
Created April 1, 2012 03:31
Initializing Final variables
package ajd.examples.basics;
public class FinalVariable {
final int finalInstanceField
// =5
;
static final int finalStaticField = 5;
{
// finalField = 5;
@ajduke
ajduke / FinalVariable.java
Created May 13, 2012 08:31
Final variable initialization
public class FinalVariable {
final int finalInstanceField ;
public FinalVariable() {
// constructor
finalInstanceField = 7;
}
}
@ajduke
ajduke / FinalVariable.java
Created May 13, 2012 08:07
Final Instance variable
public class FinalVariable {
// in the instance initializer expression, or while declaration itself
// final <type> <variable_name> = <initializer expression>;
final int finalInstanceField = 5;
}
@ajduke
ajduke / FinalVariable.java
Created May 13, 2012 08:27
Initializing final variable
public class FinalVariable {
final int finalInstanceField;
{
// Initialization in instance initializer block
finalInstanceField = 5;
}
}