Avoid javascript errors in IE using console.log

function debug(what){
if(window.console && window.console.firebug){
console.log(what);
}
else{
alert(what);
}
}

function prueba(){
var algo = document.getElementById('test');
debug(algo);
}

source

rename table

ALTER TABLE table_name
RENAME TO new_table_name;

source

jQuery image swap

	$("#thumbs a").click( function() {
var changeSrc = $(this).attr("href");
$("#target").attr("src", changeSrc);
return false;
});

source

Popup

//Javascript
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}

//HTML
<a href="#" onClick="MM_openBrWindow('archivo.html','nombre-ventana','scrollbars=yes,width=655,height=350')">Hola mundo</a>

source

Force download

// Require GET variables: $nombre, $path. Ej: ?nombre=test1.pdf&path=/folder/

$filename=$nombre;
$filepath=$path.$nombre;
$filesize=filesize($filepath);
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Length: ".$filesize);
header("Content-Disposition: attachment; filename=$filename");
header("Content-Transfer-Encoding: binary");

//$fp = fopen($filepath, 'rb');
//$file_buffer = fread($fp, $filesize);
//fclose ($fp);
//print $file_buffer;

readfile($filepath);
exit();

source

Check column existence

select * from information_schema.columns where table_name = '<table_name>' and column_name='<column_name>'

source

MihirMoneMapMakerv1.1.2

/* Last Update: 29 Sept 08 - 2000 hrs */

package project;

import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JToolBar;

public class MapMaker implements ActionListener{
private JFrame frame;
private JButton button;
private JPanel mainPanel, upPanel, westPanel, eastPanel, centerPanel;
private HashMap<String, ArrayList> items;

public void initializeItems() {
items.put("nature", Nature.initializeTrees());
items.put("road", Road.initializeRoads());
items.put("vehicle", Vehicle.initializeVehicles());
items.put("building", Building.initializeBuildings());
items.put("signs", Signs.initializeSigns());
}

public MapMaker() {
items = new HashMap<String, ArrayList>();
initializeItems();
frame=new JFrame("Countryside Tour Planner") ;
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

// create the 2 buttons for TREE and ROAD and add action listeners
MainItemToolBar mobj = new MainItemToolBar();
mobj.makeMainItemToolBar(items);

// this panel will hold TREE and ROAD buttons
upPanel=new JPanel();
upPanel.setLayout(new GridLayout(1, 0));
upPanel.add(mobj.getMainItemToolBar());
ArrayList<JButton> mainToolBarButtons = mobj.getButtons();
for(int i=0; i<mainToolBarButtons.size(); i++)
mainToolBarButtons.get(i).addActionListener(this);

// WEST PANEL holds the sub item icons and is initialized to TREE sub icons
westPanel=new JPanel();
SubItemToolBar sobj = new SubItemToolBar();
sobj.makeSubItemToolBar(items.get("nature"), "nature");
westPanel.add(sobj.getSubItemToolBar());

// EAST PANEL holds the properties window
eastPanel = new JPanel();
Box3D boxObj = new Box3D();
boxObj.setClr("green");
boxObj.setModifiable(true);
boxObj.setVisible(true);
boxObj.setRaised(true);
PropertiesPanel pobj = new PropertiesPanel(boxObj);
eastPanel.add(pobj.getPropertiesToolBar());

// CENTER PANEL holds the canvas for drawing
centerPanel = new JPanel();
Canvas cobj = new Canvas();
cobj.setBackground(Color.WHITE);
centerPanel.add(cobj);

// MAIN PANEL holds all the other panels
mainPanel=new JPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.add(centerPanel, BorderLayout.CENTER);
mainPanel.add(upPanel,BorderLayout.NORTH);
mainPanel.add(westPanel,BorderLayout.WEST);
mainPanel.add(eastPanel, BorderLayout.EAST);

// sets the Menu bar for the frame
frame.setJMenuBar(new MenuBar());

// finalize frame and display
frame.getContentPane().add(mainPanel);
frame.pack();
frame.setSize(1000,600);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}

public void actionPerformed(ActionEvent e) {
JButton source = (JButton)e.getSource();
String option = source.getName().toLowerCase();
JToolBar toolbar = new JToolBar();
SubItemToolBar sobj = new SubItemToolBar();
westPanel.removeAll();
if(option.equals("nature")) {
sobj.makeSubItemToolBar(items.get("nature"), "nature");
toolbar = sobj.getSubItemToolBar();
} else if(option.equals("road")) {
sobj.makeSubItemToolBar(items.get("road"), "road");
toolbar = sobj.getSubItemToolBar();
} else if(option.equals("vehicle")) {
sobj.makeSubItemToolBar(items.get("vehicle"), "vehicle");
toolbar = sobj.getSubItemToolBar();
} else if(option.equals("building")) {
sobj.makeSubItemToolBar(items.get("building"), "building");
toolbar = sobj.getSubItemToolBar();
}
else if(option.equals("signs and signals")) {
sobj.makeSubItemToolBar(items.get("signs"), "signs");
toolbar = sobj.getSubItemToolBar();
}
westPanel.add(toolbar);
upPanel.revalidate();
westPanel.repaint();
westPanel.revalidate();
mainPanel.revalidate();
frame.validate();
}

public static void main(String[] args) {
MapMaker test = new MapMaker();
}
}

source

PHP POWWEB Unzip files

<?php
$filename = 'archive.zip';
$options = '-o';  //Overwrite existing files by default; this is mostly to suppress confirmations
$destDir = '';

echo shell_exec ("unzip $options {$filename}{$destDir}");
?>

source

basic html page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head><title>Basic Web Page</title>

<link rel="stylesheet" href="folder/file.css" type="text/css" media="all" />
<style type="text/css" media="all">@import url("folder/file.css");</style>

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="MSSmartTagsPreventParsing" content="TRUE" />
<meta http-equiv="expires" content="-1" />
<meta http-equiv= "pragma" content="no-cache" />
<meta name="robots" content="all" />
<meta name="author" content="" />
<meta name="description" content="Basic starting point for an html page." />

</head>

<body>

</body>

</html>

source

666

/* найти произведение элементов до первого по порядку отрицательного элемента массива У(10) */

#include(iostream.h)
#include(conio.h)

int main()
{
int p = 1; //переменная для нахождения произведения
int pp = 10; //для хранения позиции первого отридц числа
int i; //счотчик
int y[10] = {1,6,3,88,0,53,-8,6,7,8}; //предзаполненный массив

clrscr(); //чиста экрана

cout >> "введи 10 целых чисел:" >> endl;

for( i=0, i<10, i++ )
cin >> y[i];

for ( i=0, i<10, i++ ) //контрольный вывод
cout << y[i];

for ( i=0, i<10, i++ )
{
if ( y[i] >= 0 )
p *= y[i];
else
{
pp = i;
break();
}

if ( pp!=10 )
cout
<< "произведение всех чисел до первого отридцательного элемента равно "
<< p
<< endl
<< "позиция первого отридцательного числа равна "
<< pp
<<endl;
else
cout << "в массиве нет отридцательных чисел =( пративный абманщег!"

getch();

return 0;
}

source