Skip to content

Instantly share code, notes, and snippets.

View matiasfha's full-sized avatar

Matías Hernández Arellano matiasfha

View GitHub Profile
@matiasfha
matiasfha / gist:6784244
Created October 1, 2013 20:02
ejemplo java escritura archivo texto
try{
FileWriter fw = new FileWriter("salida.txt");
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter salida = new PrintWriter(bw);
salida.println("Primera linea");
salida.close();
//Modo append
bw = new BufferedWriter(new FileWriter("salida.txt",true));
salida.print("Segunda Linea");
double b = 123.45;
@matiasfha
matiasfha / gist:6784297
Created October 1, 2013 20:05
Ejemplo TextViewer Java AWT
import java.awt.Button;
import java.awt.FileDialog;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.TextArea;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
@matiasfha
matiasfha / gist:6877813
Created October 8, 2013 01:05
Java Swing example
package com.zetcode;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
public class SimpleExample extends JFrame {
public SimpleExample() {
setTitle("Simple example");
@matiasfha
matiasfha / gist:6877914
Created October 8, 2013 01:18
Java Swing Quit Button example
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
public class QuitButtonExample extends JFrame {
@matiasfha
matiasfha / gist:6878072
Created October 8, 2013 01:40
Java Swing MenuBar
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.SwingUtilities;
@matiasfha
matiasfha / gist:6969968
Created October 14, 2013 02:53
Java y MySQL
package javamysql;
import java.sql.*;
public class Main {
//variables
private static Connection conexion;
private static String bd="javamysql";
private static String user="test";
#The mocked method to test
def save_obj(self, original_obj):
obj = super(CampaignProcessor, self).save_obj(original_obj)
for r in original_obj.featured_reviews.all():
review = (
r and
review_processor.get_or_create_obj(r)[0]
or None)
if review:
obj.featured_reviews.add(review)
Statement stmt = null;
String query =
"select attr1, attr2 from TU_TABLA";
try {
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
String attr1 = rs.getString("attr1");
int attr2 = rs.getInt("attr2");
function tripOverviewController ($scope, pricingService) {
this.includeMeetAndGreet = function () {
if(this.checkoutData){
return this.checkoutData.trip.includeMeetAndGreet === 1;
}
return false;
};
this.showCouponField = function () {
if(this.checkoutData){
@matiasfha
matiasfha / angular.js
Created November 4, 2015 18:54
Angular start method
(function(window, document, undefined) {
<!--
here goes entire AngularJS code
including functions, services, providers etc related code goes here
-->
if (window.angular.bootstrap) {
//AngularJS is already loaded, so we can return here...
console.log('WARNING: Tried to load angular more than once.');
return;
}