The document discusses various topics related to JavaScript including:
- Inconsistencies in type checking and comparisons
- Issues with treating null and undefined the same
- Problems that can occur with reference types like objects and arrays
- Use of the 'this' keyword in functions and methods
- Implementing inheritance between objects
The overall message is that JavaScript has some quirks but it is important to learn its paradigms and criticize the language constructively.
Alpine.js ti offre la natura reattiva e dichiarativa di grandi framework come Vue o React a un costo molto inferiore. La sua forza sta nella facilità di manipolazione del DOM (document object model).
Alpine.js non prevede alcun build step e fornisce tutti gli strumenti necessari per creare un'interfaccia utente di base.
Alpine.js ti offre la natura reattiva e dichiarativa di grandi framework come Vue o React a un costo molto inferiore. La sua forza sta nella facilità di manipolazione del DOM (document object model).
Alpine.js non prevede alcun build step e fornisce tutti gli strumenti necessari per creare un'interfaccia utente di base.
XQDT - XQuery Getting Momentum in Eclipseguesteb3ec2
These slides were presented during the EclipseCon 2010 in Santa Clara, California.
They present the new XQuery Tools that are now incubating in the XML project in Eclipse.
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress WordCamp Kyiv
Если ваш блог читает не только мама и одноклассники, то вы наверняка сталкивались с проблемой нагрузки на ваш трехдолларовый хостинг. Мы расскажем как решить эту проблему, используя встроенные функции кеширования WordPress.
You've seen Kris' open source libraries, but how does he tackle coding out an application? Walk through green fields with a Symfony expert as he takes his latest “next big thing” idea from the first line of code to a functional prototype. Learn design patterns and principles to guide your way in organizing your own code and take home some practical examples to kickstart your next project.
XQDT - XQuery Getting Momentum in Eclipseguesteb3ec2
These slides were presented during the EclipseCon 2010 in Santa Clara, California.
They present the new XQuery Tools that are now incubating in the XML project in Eclipse.
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress WordCamp Kyiv
Если ваш блог читает не только мама и одноклассники, то вы наверняка сталкивались с проблемой нагрузки на ваш трехдолларовый хостинг. Мы расскажем как решить эту проблему, используя встроенные функции кеширования WordPress.
You've seen Kris' open source libraries, but how does he tackle coding out an application? Walk through green fields with a Symfony expert as he takes his latest “next big thing” idea from the first line of code to a functional prototype. Learn design patterns and principles to guide your way in organizing your own code and take home some practical examples to kickstart your next project.
Implement threads and a GUI interface using advanced Java Swing clas.pdfamrishinda
Implement threads and a GUI interface using advanced Java Swing classes.
Required data structure - the advanced data structure uses implementation of a multi-tree with
the following levels: Cave - level 0 Party - Level 1 Creature - Level 2 Artifacts - Level 3
Treasures - Level 3 Jobs
Use the Swing class JTree effectively to display the contents of the data file. Implement a JTable
to also show the contents of the data file.
Threads: Implement a thread for each job representing a task that creature will perform. Use the
synchronize directive to avoid race conditions and insure that a creature is performing only one
job at a time. The thread for each job should be started as the job is read in from the data file.
Only one job should be progressing for each creature at any moment. Use delays to show the
creature doing the task.
Use a JProgressBar for each creature to show the creature performing the task. Use JButton\'s on
the Job panel to allow the task to be suspended and cancelled. The GUI elements should be
distinct from the other classes in the program.
Solution
Please find the code below for the above problem :
import java.util.ArrayList;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Random;
import java.io.File;
import java.io.FileNotFoundException;
import javax.swing.JProgressBar;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import java.awt.GridLayout;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Cave2 {
ArrayList parties = new ArrayList (); // the parties
ArrayList loners = new ArrayList (); // creatures not in parties
ArrayList drops = new ArrayList (); // Treasures not carried
ArrayList magics = new ArrayList (); // Artifacts not carried
ArrayList jobs = new ArrayList (); // Jobs to be performed
JFrame jf = new JFrame ();
JPanel jrun = new JPanel ();
JTextArea jta = new JTextArea (10, 10);
// hashmap of everything by index
HashMap hmElements = new HashMap ();
public Cave2 () {
Scanner sf = null;
String fileName = \"dataC.txt\";
try {
// sf = new Scanner (new File (fileName));
// getResourceAsStream is the way to access a data file in a jar package file
// this works in general, so leave it here as is.
sf = new Scanner (getClass().getResourceAsStream (fileName));
}
catch (Exception e) {
System.out.println (e + \"\ File bummer: \" + fileName);
} // end open file try/catch block
if (sf == null)
return;
readFile (sf);
jta.setText (toString ());
jf.setTitle (\"Cave2\");
jf.add (jrun, BorderLayout.PAGE_END);
jrun.setLayout (new GridLayout (0, 5, 2, 5));
jf.add (new JScrollPane (jta), BorderLayout.CENTER);
jta.setFont (new Font (\"Monospaced\", 0, 12));
jf.pack ();
jf.setVisible (true);
jf.setLocationRelativeTo (null);
} // end no-parameter constru.
Simple Photo Processing and Web Display with PerlKent Cowgill
I have a small photo gallery on my website and in this presentation, I share
some steps I used in creating a nearly automatic workflow of getting
pictures from my camera to his gallery using Perl.
Presentation from OSDC 2008 in Sydney, on using Sphinx with Rails. The sldes don't work that well without the talk though, but it may be useful as a reference, I guess.
I Have the following Java program in which converts Date to Words an.pdfallystraders
I Have the following Java program in which converts Date to Words and the only thing I have to
do now is add a boolean for a leap year. ( I am using Apache NetBeans) please explain where the
boolean goes.
Like this:
I need the code working with the boolean added, Thank you!!!
package a1_demo;
import java.util.Scanner;
public class MainApp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Welcome to the Date to Words Converter!\n\n");
while ( true ) {
// get user input
String str_MM_DD_YYYY = Validator.getString(
Validator.sc,
"Enter date in MM/DD/YYYY format: "
);
// convert text to ints:
// "11/22/3333" - > int, int int
String[] dateComponents = str_MM_DD_YYYY.split( "/" );
if ( dateComponents.length != 3 ) {
System.out.println("\t\t Bad input, please retry...");
continue;
}
int month = 0;
int day = 0;
int year = 0;
try {
month = Integer.parseInt(dateComponents[ 0 ]);
day = Integer.parseInt(dateComponents[ 1 ]);
year = Integer.parseInt(dateComponents[ 2 ]);
} catch ( java.lang.NumberFormatException ex ) {
System.out.println("\t\t numeric values are expected, please retry...");
continue;
}
Date2TextConverter converter = new Date2TextConverter( month, day, year );
System.out.print( converter.month2text() );
System.out.print( " " );
System.out.print( converter.day2text() );
System.out.print( " " );
System.out.print( converter.year2text() );
System.out.println();
}// endless while loop
}//main
}//class MainApp
package a1_demo;
public class Date2TextConverter {
//---------------------------------------
// data
//---------------------------------------
int month = 0;
int day = 0;
int year = 0;
//---------------------------------------
// constructors
//---------------------------------------
public Date2TextConverter(int month, int day, int year )
{
this.month = month;
this.day = day;
this.year = year;
}//Date2TextConverter
//---------------------------------------
// operations
//---------------------------------------
public String month2text()
{
switch( month )
{
case 1: return "Jan";
case 2: return "Feb";
case 3: return "Mar";
case 4: return"April";
case 5: return"May";
case 6: return"June";
case 7: return"July";
case 8: return"Aug";
case 9: return"Sep";
case 10: return"Oct";
case 11: return"Nov";
case 12: return"Dec";
//...
default:
return "Invalid Month";
}
}//month2text
public String day2text()
{
//return Integer.toString( day );
return number2words (day);
}//day2text
public String year2text()
{
int century = year / 100;
int yearInCentury = year % 100;
String centuryText = number2words( century );
String yearText = number2words( yearInCentury );
if ( yearInCentury < 10 ) {
return centuryText + " zero " + yearText;
} else {
return centuryText + " " + yearText;
}
}//year2text
private String number2words( int number ) {
// convert to text a number 0 through 99
if ( number < 20 ) {
// 0, 1, 2, 3, ..., 19
return zero2nineteen[ number ];
} else if ( number % 10 == 0 ) {
// 20, 30, 40, ... 90
return .
JSARToolKit / LiveChromaKey / LivePointers - Next gen of ARYusuke Kawasaki
I gave a talk about the next generation of AR. Pure ActionScript 3.0 libraries of LiveChromaKey and LivePointers made it at the SparkStudy/09 (Spark project勉強会#09)
Try this at: http://www.kawa.net/text/spark/09/spark.html
JavaScript - Like a Box of Chocolates - jsDayRobert Nyman
This presentation aims to give you information about the JavaScript language itself; pros, cons and pitfalls. It will cover the basics and then go into objects, scope, closure and some performance bits.
Similar to Não alimente os trolls: JavaScript é bonito - FrontInSM 2015 (20)
As novas APIs da web tem possibilitado grandes feitos para o Javascript. Essa palestra aborda tratamento de sinais que vão desde a criação de filtros de imagem, passando por distorções de áudio (e pedais de guitarra!), até compressão de streams! Vamos falar sobre as barreiras que a linguagem quebra diariamente!
Nowadays we have native options to deal with media signals on javascript! How can we use the available APIs to process it? This talk is about amazing uses to Web Audio API and the Video tag like sampling, quantization, filtering, etc. Can we synthesize guitar effects?
Nessa palestra abordei algumas APIs que considero promissoras no HTML5 como acessá-las com o Javascript tornando a experiência do usuário interessante.
Como ondas eletromagnéticas interagem na camada física em diferentes meios, como se transporta informação e os motivos pelos quais não podemos ter mais velocidade aumentando a frequência deliberadamente.
16. “Se JavaScript não fosse tão
feia, um livro chamado
‘JavaScript: The Good Parts’
não seria o best-seller da
linguagem na Amazon”
http://simpleprogrammer.com/2013/05/06/why-javascript-is-doomed/
26. var url1 = 'http://localhost/rs/santa-maria'
var url2 = 'http://localhost/'
var getState = function (url) {
var stateMatch = url.match(//[a-z]{2}//gi);
var state = null;
if (stateMatch !== null && stateMatch.length > 0) {
state = stateMatch[0].replace(///g, '');
}
return state;
}
getState(url1); // ‘rs’
getState(url2); // null
27. “Se você trata null e
undefined igualmente, é
recompensado com
comparações mais simples”
https://speakerdeck.com/getify/new-rules-for-javascript
28. if (stateMatch !== null && stateMatch.length > 0) {
state = stateMatch[0].replace(///g, '');
}
if (stateMatch && stateMatch.length) {
state = stateMatch[0].replace(///g, '');
}
29. var data = {name: 'Luke', surname: 'Skywalker'}
var User = function (name, surname) {
this.name = name;
this.surname = surname;
this.getCompleteName = function () {
return this.name + ' ' + this.surname;
}
}
var user = new User(data.name, data.surname)
user.getCompleteName(); // 'Luke Skywalker'
30. var data = {name: 'Luke'}
var user = new User(data.name, data.surname)
user.getCompleteName(); // 'Luke undefined'
31. var data = {name: 'Luke'}
var User = function (name, surname) {
this.name = name;
this.surname = surname || '';
this.getCompleteName = function () {
return this.name + ' ' + this.surname;
}
}
var user = new User(data.name, data.surname)
user.getCompleteName(); // 'Luke '
33. var UserView = function () {
function setName (name) {
this.name = name;
}
function setEvents () {
var that = this;
$('.hit').on('click', function () {
console.log(this); // <button class="hit">Hit me!</button>
$(this).toggleClass('odd');
that.setName($('.name').val());
});
}
return {
setEvents: setEvents,
setName: setName
}
}
34. function setEvents () {
var that = this;
$('.hit').on('click', function () {
console.log(this);
$(this).toggleClass('odd');
that.setName($('.name').val());
});
}
35. function setEvents () {
var button = $('.hit');
function handler () {
console.log(this);
button.toggleClass('odd');
this.setName($('.name').val());
}
button.on('click', handler.bind(this));
}
https://github.com/rssilva/presentations/blob/master/front-in-sm-2015/thisWorld/ex1.html
36.
37. var Human = {
setName: function (name) {
console.log(this);
this.name = name;
},
sayHi: function () {
return 'Hi! My name is ' + this.name + '!';
}
}
38. var Ninja = {
setName: Human.setName,
setStealhLevel: function (level) {
console.log(this)
this.stealthLevel = level;
}
}
39. var Turtle = {
setHullLevel: function (level) {
console.log(this);
this.hullLevel = level;
}
}
var NinjaTurtle = {
setName: Ninja.setName,
setStealhLevel: Ninja.setStealhLevel,
setHullLevel: Turtle.setHullLevel
}