Skip to content

Instantly share code, notes, and snippets.

View timpulver's full-sized avatar

Tim Pulver timpulver

View GitHub Profile
@timpulver
timpulver / upload.sh
Created June 4, 2014 07:39
[Shell, Arduino, Ino] Upload Arduino Code using Ino without creating a "src"-folder
#!/bin/sh
# Arduino-IDE-and-Ino-Side-by-sidy Helper Script
# Version: 0.1
# Author: Tim Pulver
# Ino URL: http://inotool.org
#
# Compile and upload Arduino sketches using Ino
# without moving them to a "scr"-folder, so you can still edit
# the sketch in Arduino IDE.
@timpulver
timpulver / SoftwareResetWithWatchdog.ino
Created June 10, 2014 11:42
[Arduino, Watchdog] Soft-Reset Arduino using Watchdog
/*
* Watchdog example
*
* Send 'r' through serial to reboot the Arduino, when it's back up, "Boot..." should appear.
*/
// include watchdog, part of avr-gcc compiler
#include <avr/wdt.h>
void setup(){
@timpulver
timpulver / Watch_Data_Directory_For_Changes.pde
Created July 8, 2014 11:29
[Processing] Watch Data Folder for Changed / Newly Created Files
import static java.nio.file.LinkOption.NOFOLLOW_LINKS;
import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE;
import static java.nio.file.StandardWatchEventKinds.OVERFLOW;
import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.Path;
@timpulver
timpulver / randomImage.php
Created March 19, 2012 19:16
Displays a random image
/*
Am Anfang müssen die Dateinamen im script gespeichert werden. Dazu nehme ich der Einfachheitshalber ein Array namens $bild. Die Funktion mt_rand() liefert eine Zufallszahl im Bereich unteres Array (also unterer Anzahl der eingetragenen Bilder). Mit der letzten Zeile wird der Wert aus dem Array $bild per PHP-Befehl "echo" in den HTML-Code geschrieben.
Um das Ganze nun nutzen zu können, musst du auf deinem Server diesen Quellcode in eine Datei mit der Endung .php speichern (sonst interpretiert der Server den Quelltext nicht als PHP). Wichtig dabei natürlich, dass dein Server überhaupt PHP installiert hat. Sollte aber mittlerweile überall Standard sein.
*/
<?PHP
// Hier kommen die dateinamen untereinander
$bild[] = "header1.jpg";
@timpulver
timpulver / stringToCharPtr.cpp
Created March 19, 2012 19:24
String in char* konvertieren (CPP)
// String definieren
string s1("Ein Text");
// Zeichen aus String in char-Feld umkopieren
char charArray[40];
// string.c_str() liefert char*
strcpy(charArray,s1.c_str());
@timpulver
timpulver / randomInt.cpp
Created March 19, 2012 19:26
Create a random number between grA and grB (CPP)
srand ( time(NULL) );
int grA, grB;
grA = 0; grB = i;
int a;
a = grA + (rand() % (grB - grA + 1));
@timpulver
timpulver / deleteFile.cpp
Created March 19, 2012 19:27
Delete a file (CPP)
#include <stdio.h>
int remove(const char *filename);
@timpulver
timpulver / stringCompare.cpp
Created March 19, 2012 19:31
Compare two Strings
// returns 0 if equal
stricmp(str1, str2);
@timpulver
timpulver / directoryExists.cpp
Created March 19, 2012 19:28
Check if a directory exists (CPP)
bool DirectoryExists( const char* pzPath ){
DIR *pDir;
bool bExists = false;
pDir = opendir (pzPath);
if (pDir != NULL){
return true;
}
return false;
}
@timpulver
timpulver / readFile.cpp
Created March 19, 2012 19:32
Read a textfile line after line
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
ifstream f; // Datei-Handle
string s;
f.open(argv[1], ios::in); // Öffne Datei aus Parameter