Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Macagare

  • Germany
View GitHub Profile
@Macagare
Macagare / html5_template.html
Created Oct 29, 2012 — forked from nathansmith/html5_template.html
HTML: Simple HTML5 Template
View html5_template.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge, chrome=1" />
<title>untitled</title>
<link rel="stylesheet" href="" />
</head>
<body>
@Macagare
Macagare / PHP: PHP read csv
Created Oct 29, 2012
PHP: Open and read a csv file via PHP
View PHP: PHP read csv
<?php
$fh = fopen("myfile.csv", "r");
while ($line = fgets($fh)) { // Read one line at-a-time until end of file
$words = explode (';', $line ); // break the line down to words, by separating on a ';'
echo "This line consisted of the following words:\n";
foreach ($words as $word) { //display all words
echo "Word: ". $word. "\n";
}
// update the database here.
@Macagare
Macagare / PHP: count file lines
Created Oct 29, 2012
PHP: Count the lines of a file
View PHP: count file lines
public function countLines($filePath, $emptyLines = true) {
$lineCounts = 0;
if (is_file($filePath) == true) {
$fileHandle = fopen($filePath, 'r');
if ($fileHandle == true) {
while(feof($fileHandle) == false) {
$currentLine = fgets($fileHandle);
if ($emptyLines == false) {
if (trim($currentLine) != null) {
$lineCounts = $lineCounts + 1;
@Macagare
Macagare / HTML Upload form
Created Oct 29, 2012
HTML: form für uploading files
View HTML Upload form
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
@Macagare
Macagare / MYSQL: copy table
Created Oct 29, 2012
MYSQL: create a copy of another table
View MYSQL: copy table
CREATE TABLE recipes_new LIKE production.recipes; INSERT recipes_new SELECT * FROM production.recipes;
@Macagare
Macagare / MYSQL: Distanzberechnung
Created Oct 29, 2012
MYSQL: Mit der nachfolgende Funktion kann die Entfernung zwischen 2 Punkten auf der Erdkugel berechnet werden. Somit kann man ganz einfach in einer MySQL-Datenbank die Elemente ermitteln die zm Beispiel im Umkreis zu einem bestimmten Punkt liegen. Ich den
View MYSQL: Distanzberechnung
CREATE FUNCTION `GoogleDistance_KM`(
geo_breitengrad_p1 double,
geo_laengengrad_p1 double,
geo_breitengrad_p2 double,
geo_laengengrad_p2 double ) RETURNS double
RETURN (6371 * acos( cos( radians(geo_breitengrad_p2) ) * cos( radians( geo_breitengrad_p1 ) )
* cos( radians( geo_laengengrad_p1 ) - radians(geo_laengengrad_p2) )
+ sin( radians(geo_breitengrad_p2) ) * sin( radians( geo_breitengrad_p1 ) ) )
);
@Macagare
Macagare / JavaScript: JQuery document ready
Created Oct 31, 2012
JavaScript: JQuery document ready
View JavaScript: JQuery document ready
$(document).ready(function() {
// Handler for .ready() called.
});
@Macagare
Macagare / Javascript: interval.js
Created Oct 31, 2012 — forked from manast/interval.js
Javascript: Accurate Javascript setInterval replacement
View Javascript: interval.js
function interval(duration, fn){
this.baseline = undefined
this.run = function(){
if(this.baseline === undefined){
this.baseline = new Date().getTime()
}
fn()
var end = new Date().getTime()
this.baseline += duration
@Macagare
Macagare / gist:3992769
Created Nov 1, 2012
XML: TOMAS Import example
View gist:3992769
<Images xmlns="">
<Image ObjectID="TDS00020010051505595">
<DescribingName>
<Value LanguageCode="fr">salle de bain 2</Value>
<Value LanguageCode="de">salle de bain 2</Value>
<Value LanguageCode="en">salle de bain 2</Value>
<Value LanguageCode="es">salle de bain 2</Value>
<Value LanguageCode="it">salle de bain 2</Value>
</DescribingName>
<MultimediaGroup LookupID="WBX00020010000126810">
You can’t perform that action at this time.