Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Macagare

  • Germany
View GitHub Profile
@Macagare
Macagare / gist:768ac1e177e4b1ca3879
Created Jun 24, 2015
SVN remove unversioned files like "git clean -f"
View gist:768ac1e177e4b1ca3879
svn st | grep '^?' | awk '{print $2}' | xargs rm -rf
@Macagare
Macagare / urls.sh
Last active Aug 29, 2015
Shell URL request runner
View urls.sh
for i in `cat testurls.txt`
do
curl -v -o /dev/null $i\&lorem=$RANDOM
done
# testurls.txt simply lists one URL per line
@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 / 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 / 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 / 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 / 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.
});
You can’t perform that action at this time.