@namespace url(http://www.w3.org/1999/xhtml);
/*
Flickr - Prefer Helvetica
by Alex Bischoff
2008-04-18
*/
@-moz-document domain("flickr.com") {
body, input, textarea, select
{
/* This is normally set to "Arial, Helvetica, sans-serif" */
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
}
}
Flickr – Prefer Helvetica
Beginner’s instructions for compiling from source on OS X
# cd into the source directory and run the following command. That should do it. sudo ./configure; sudo make; sudo make install
Preserve & update/rebuild query string
<?php
/**
* Name: Preserve and update/rebuild query string<br>
* @param Example:
* Example URL: <a href="http://www.site.com/?category=foo&order=desc&page=2" >http://www.site.com/?category=foo&order=desc&page=2</a>
*
* <a href="<?php echo queryString('order','asc'); ?>">Order ASC</a>
*
* Output HTML: <a href="?category=foo&order=asc&page=2">Order ASC</a>
* Output URL: <a href="http://www.site.com/?category=foo&order=asc&page=2" >http://www.site.com/?category=foo&order=asc&page=2</a>
*
* Not <a href="http://www.site.com/?category=foo&order=desc&page=2&order=asc" >http://www.site.com/?category=foo&order=desc&page=2&order=asc</a>
*/
function queryString($str,$val)
{
$queryString = array();
$queryString = $_GET;
$queryString[$str] = $val;
$queryString = "?".htmlspecialchars(http_build_query($queryString),ENT_QUOTES);
return $queryString;
}
?>
jQuery radio button donate submit
//Clear the value in the text form when you click other
$("#other").click(function(){
$("#inputAmount").attr("value", "").focus().select();
});
$("#donateBox form").submit(function(){
//Check to see if the radio button is checked
if($("#other").is(":checked")){
//Take value from the text box
var ourValue = $("#inputAmount").attr("value");
//Check to see if we have a value
if(ourValue ==="" || ourValue ==="0"){
ourValue = "5";
}
//Add it to the radio button
$("#other").attr("value", ourValue);
} else {
return;
}
});
Lire les fichiers textes
Lire les fichiers contenant du texte grâce au PHP est déjà facile. Il vous suffit d'utiliser le trio de fonctions fopen(), fgetc() et fclose().
Dans cet exemple, vous parcourez un fichier nommé "sample.txt" situé dans le même répertoire que le script. Et vous affichez chaque ligne à l'écran.
<?
$fichier = fopen("sample.txt","r") ;
while(!feof($fichier)) {
// On récupère une ligne
$Ligne = fgets($fichier,255);
// On affiche la ligne
echo $Ligne;
}
// On ferme le fichier
fclose($fichier);
?>
Tout ce code peut se résumer en une ligne :
<?
readfile("sample.txt") ;
?>
Maintenant, si vous voulez affecter tout le contenu du fichier à une variable, ne commencez pas fopen()... file_get_contents() suffit largement!
<?
// Affectation du contenu de sample à la variable $texte
$texte = file_get_contents("sample.txt") ;
?>
Vous désirez affecter chaque ligne dans une liste? Vous n'avez pas besoin d'incrémenter un compteur, et de compter les lignes ; file() le fait déjà .
<?
// Affectation du contenu de sample à la variable $texte
$texte = file("sample.txt") ;
?>
Javascript Tag Cloud
/**----------------------------------------------------------------
*
* TAG CLOUD IMPLEMENTATION
*
*///--------------------------------------------------------------
var TagCloud = function(){
var DEFAULT_UNIT = '%';
var DEFAULT_TEXT_PROPERTY = 'text';
var DEFAULT_VALUE_PROPERTY = 'value';
var gatherStatistics = function(data, config){
var currentMax = data[0][config.valueProperty];
var currentMin = data[0][config.valueProperty];
for(var i = 0; i < data.length; i++){
var value = data[i][config.valueProperty];
currentMax = (currentMax < value)?value:currentMax;
currentMin = (currentMin > value)?value:currentMin
}
return {
max : currentMax,
min : currentMin,
mid : (currentMax+currentMin)/2,
unit : (currentMax-currentMin)/100
};
}
var defaultScaler = function(value, rangeData){
return ((value/rangeData.max)*100)+100;
}
return {
process : function(data, config){
config = config || {};
config.unit = config.unit || DEFAULT_UNIT;
config.textProperty = config.textProperty || DEFAULT_TEXT_PROPERTY;
config.valueProperty = config.valueProperty || DEFAULT_VALUE_PROPERTY;
var dataRange = gatherStatistics(data, config);
var scaler = config.scaler || defaultScaler;
for(var i = 0; i < data.length; i++){
var scale = scaler(data[i][config.valueProperty], dataRange);
config.renderer(data[i][config.textProperty], scale, config.unit);
}
}
}
}();
/**----------------------------------------------------------------
*
* BASIC USAGE EXAMPLE
*
*///--------------------------------------------------------------
var cloudData = [
{text:"One", value:41},
{text:"Two", value:122},
{text:"Three", value:53},
{text:"Four", value:45},
{text:"Five", value:52},
{text:"Six", value:68}
];
TagCloud.process(cloudData,{
renderer : function(text, size, unit){
document.write("<span style="font-size:" + size + unit + ";">" + text + "</span>");
}
,scaler : function(value, rangeData){
var MAXFONTSIZE = 30;
var MINFONTSIZE = 12;
var spread = rangeData.max - rangeData.min;
if(spread == 0){
spread = 1;
}
return MINFONTSIZE + (value - rangeData.min) *
(MAXFONTSIZE - MINFONTSIZE) / spread;
}
,unit : 'px'
});
jQuery open external link in new window
//Grab the href, open it in a window and cancel the click action
$("a[href^='http']").click(function(){window.open(this.href); return false;});
//Add target = blant to the external link
$("a[href^='http']").attr('target','_blank');
//Similar to the first, only using your domain name
$("a:not([href*='yourdomainnamehere.com'])").click(function(){
window.open(this.href);
return false;
}).attr("title", "Opens in a new window");
NickMeinholdTheCanvas v0.1
// modified 01/10/08
package project;
import java.awt.*;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.event.*;
import java.io.File;
import java.util.ArrayList;
public class TheCanvas extends JPanel implements MouseListener, MouseMotionListener {
private int X, Y;
private Image image;
private ArrayList<Item> canvas_items = new ArrayList<Item>();
Item current_item = new Vehicle("Tram", "black", "images/vehicle/tram_black.gif", "Tram", true);
public TheCanvas() {
addMouseMotionListener(this);
addMouseListener(this);
setVisible(true);
try{
image = ImageIO.read(new File ("images/save.png"));
}
catch(Exception e) {
System.out.println("The image file could not be found"+e);
}
}
public void mouseMoved(MouseEvent event) {
X = (int) event.getPoint().getX();
Y = (int) event.getPoint().getY();
repaint();
}
public void mouseDragged(MouseEvent event) {
mouseMoved(event);
}
public void mousePressed(MouseEvent event) {
}
public void mouseReleased(MouseEvent event) {
}
public void mouseEntered(MouseEvent event) {
}
public void mouseExited(MouseEvent event) {
}
public void mouseClicked(MouseEvent event) {
System.out.println(X+","+Y);
}
public void update(Graphics graphics) {
paint(graphics);
}
public void paint(Graphics g) {
// Dynamically calculate size information
Dimension size = getSize();
// diameter
//int d = Math.min(size.width, size.height);
//int x = (size.width - d)/2;
//int y = (size.height - d)/2;
g.setColor(Color.white);
g.fillRect(0, 0, size.width, size.height);
g.drawImage(image, X, Y, null);
}
}
Dump Database
mysqldump -uuser -ppass --opt database > file directory
Access SQLite Database from SAS
/************************************************
* ACCESS SQLITE DATABASE FROM SAS *
* REQUIREMENT: *
* HAVE SQLITE ODBC DRIVER INSTALLED *
************************************************/
libname sqlite odbc complete = "dsn=SQLite;
Driver={SQLite3 ODBC Driver};
Database=C:foldermydatabase.db";