Skip to content

Instantly share code, notes, and snippets.

View fotan's full-sized avatar

Matt Danskine fotan

View GitHub Profile
@fotan
fotan / form.html
Created January 13, 2017 22:13
AJAX - Form Validation with PHP
<form action="process.php" method="post">
<label>First Name</label>
<input name="first_name" type="text" />
<label>Email</label>
<input name="email" type="text" />
<input type="submit" value="Submit" />
</form>
<script>
@fotan
fotan / hidden.html
Created January 6, 2017 01:46
FORM - Hidden Field Captcha
Hides a form field. Check for it on the form processor page. If there's data, it was filled in by a bot because a normal browser can't see it.
<input type="text" name="surprise" value="" style="display: none; visibility: hidden;"/>
@fotan
fotan / mackup.txt
Created January 4, 2017 16:34
MACKUP
https://github.com/lra/mackup
From Homebrew, on "master system" do:
# Install Mackup
brew install mackup
# Launch it and back up your files
mackup backup
@fotan
fotan / backup_dbs.php
Created December 21, 2016 19:22
PHP - Backup DB Server
<?php
######################################################################
## MySQL Backup Script v2.1 - May 3, 2007
######################################################################
## For more documentation and new versions, please visit:
## http://www.dagondesign.com/articles/automatic-mysql-backup-script/
## -------------------------------------------------------------------
## Created by Dagon Design (www.dagondesign.com).
## Much credit goes to Oliver Mueller (oliver@teqneers.de)
@fotan
fotan / load_test.txt
Created December 13, 2016 01:44
LINUX - Load Test Server
ab -n 10000 -c 10 http://fotan.us (Or any single page)
10000 is the number of hits
10 is the number of concurrent connections
If you just want to throw load at a single URL at a time on a web server then download Apache AB. It comes with Apache HTTP server.
Simple command (from Terminal on my Mac works)
@fotan
fotan / du.txt
Created December 13, 2016 01:29
LINUX - Output Directory Sizes
du -h --max-depth=1 /home/ | sort -h -r
du - Disk Usage command
print the total size of each folder under the /home/directory in human readable values (K, M, G) and sort -h -r
will sort them taking human readable values into account and will display the results in reverse order from largest fodler to smallest.
If u want largest folders last use only sort -h without -r
@fotan
fotan / orderby.sql
Created December 7, 2016 20:39
MYSQL - ORDER BY values in a field in your own order
ORDER BY FIELD(fieldname, 7, 4, 34);
or
ORDER BY FIELD(fieldname, 'seven', 'four', 'asshole');
@fotan
fotan / center.css
Created November 28, 2016 16:31
BS3 - Center Modal on Page
.modal {
text-align: center;
}
@media screen and (min-width: 768px) {
.modal:before {
display: inline-block;
vertical-align: middle;
content: " ";
height: 100%;
@fotan
fotan / alerts.php
Last active October 7, 2016 15:42
BS3 - Dynamic Alerts
// Set $alert_type and $message somewhere else
<?php if(isset($message)) { ?>
<br />
<div class="row">
<?php
// Add ability to display different types of alerts.
// For backwards compatibility, if $alert-type isn't set, set it to alert-info.
@fotan
fotan / checkURL.php
Created July 12, 2016 17:02
PHP - Check server code on a URL (See if website is up)
$url = “http://fotan.us”;
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
/* Get the HTML or whatever is linked in $url. */
$response = curl_exec($handle);
/* Check the return code. */
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);