Skip to content

Instantly share code, notes, and snippets.

View danferth's full-sized avatar
🎸
Jammin till the break of dawn

Dan Klotz danferth

🎸
Jammin till the break of dawn
View GitHub Profile
@danferth
danferth / JS URL grab.md
Last active May 22, 2019 22:52
Get URL values with jQuery

Grab the $_GET[] from a url with JS

Cheat sheet for ustilizing the $_GET[] from a URL in JS

Real simple little function will grab the $_GET[] values and put them into an array for use with jQuery. I didn't write it and sorry but do not remember where it came from but man has it been usefull at times.

thanks to the original author!

@danferth
danferth / jQuery Plugin syntax.md
Last active May 22, 2019 22:51
Jquery Plugin Syntax for referance

jQuery plugin syntax

Cheat sheet for creating jQuery Plugins

So you whant to flood the market with another scrolling slideshow, popup, video enabled jQuery plugin. Here is the syntax plain and simple.

  • creat your function that can be used with other libraries by wraping in anonymus function (function($){
  • name the function $.fn.myfunction(settings){
@danferth
danferth / PDO and MySQL.md
Last active April 10, 2023 13:44
Cheat sheet for using PDO (PHP Data Objects) in connecting and querying MySQL database.

PDO (PHP Data Objects)

Cheat sheet for using PDO to interact with MySQL db's

Used to use MySQL then found out it was being depreciated, this is of course right after I got the hang of it and was almost finished with the project i was using to learn myself. So desided to make the switch to PDO way much easier especially if you have security in mind.

For instance instead of $var = mysql_real_escape_string($_POST['data'];, you just $var = $db->quote($_POST['data'];. Or even better use prepared staements and the underlying driver will not only escape but quote the string for you!

@danferth
danferth / PHP sessions.md
Last active May 4, 2023 14:39
PHP session cheat sheet

PHP Sessions

Cheat sheet for using PHP sessions

  • start session with session_start(); at the begginging of document before any HTML or PHP.
  • set session variable with $_SESSION['varName'] = "value";, it will be available on anypage that has sessions active.
  • unset session variables with unset($_SESSION['varName']); or unset all with session_unset(); session will still be active though.

SQL Statements

Cheat sheet SQL staements

This is for SQL staements to be used in PHP

create table

@danferth
danferth / helper.php
Created January 24, 2014 17:44
PHP helper functions
<php?
//fun helper function for debugging from http://net.tutsplus.com/tutorials/tools-and-tips/xdebug-professional-php-debugging/
function dump($value) {
echo ‘<pre>';
var_dump($value);
echo ‘</pre>';
}
?>
@danferth
danferth / PDO classes.md
Last active May 15, 2023 01:17
PHP classes for PDO

PDO Classes for db connect and manipulation

Below is a description on how to use the classes in the below script

Include script and set up db variables

include 'zdb.php';
@danferth
danferth / open-write-close-with-PHP.md
Last active August 29, 2015 14:27
open and write to file with PHP

Open a file and write to it with PHP

snippet to open a file, write to it (with timestamp), then close file with PHP

More can be found at fopen docs

@danferth
danferth / update-ubuntu.md
Last active August 29, 2015 14:27
Ubuntu update from terminal

To update Ubuntu from Terminal

Remember to use sudo of you are not logged in as root

apt-get update
apt-get upgrade
apt-get dist-upgrade
reboot
@danferth
danferth / .htaccess
Created September 29, 2018 00:07
My standard htaccess file
# ######################################################################
# This below is extracted from the HTML5 boilerplate htaccess file. #
# ######################################################################
#
# Apache Server Configs v3.0.0 | MIT License
# https://github.com/h5bp/server-configs-apache
# (!) Using `.htaccess` files slows down Apache, therefore, if you have
# access to the main server configuration file (which is usually called
# `httpd.conf`), you should add this logic there.