Skip to content

Instantly share code, notes, and snippets.

View optikalefx's full-sized avatar

Sean Clark optikalefx

View GitHub Profile
@optikalefx
optikalefx / Super Simple Ajax File Upload (XHR2).js
Last active April 4, 2021 15:12
Ajax File upload with jQuery and XHR2Sean Clark http://square-bracket.com
// Ajax File upload with jQuery and XHR2
// Sean Clark http://square-bracket.com
// xhr2 file upload
$.fn.upload = function(remote, data, successFn, progressFn) {
// if we dont have post data, move it along
if (typeof data != "object") {
progressFn = successFn;
successFn = data;
}
@optikalefx
optikalefx / MultipleEmailAttachments.php
Last active July 10, 2023 13:02
Multiple Email Attachments PHP from scratch
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
if(isset($_FILES) && (bool) $_FILES) {
$allowedExtensions = array("pdf","doc","docx","gif","jpeg","jpg","png","rtf","txt");
$files = array();
<?php
class Nodesystem extends App {
function save() {
// get the post data
$post = $this->_safeMysql();
$this->_log('ID', $post['id']);
//get a user id
function ParallaxItem(containerNode) {
var container, bgElements, offset, bgHeight, containerHeight, maxScrolls, height;
container = Y.one(containerNode);
bgElements = container.all('.parallax-background');
function refreshCoords() {
offset = container.getY();
containerHeight = container.get('offsetHeight');
bgHeights = [];
maxScrolls = [];
bgElements.each(function(item) {
@optikalefx
optikalefx / chat.html
Created June 4, 2013 16:36
RealTime + Root.js
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="realtime.js"></script>
<style type="text/css">
#chat {
width:300px;
height:300px;
border:1px solid black;
$.fn.upload = function(remote,data,successFn,progressFn) {
// if we dont have post data, move it along
if(typeof data != "object") {
progressFn = successFn;
successFn = data;
}
return this.each(function() {
if($(this)[0].files[0]) {
var formData = new FormData();
formData.append($(this).attr("name"), $(this)[0].files[0]);
// Ajax File upload with jQuery and XHR2
// Sean Clark http://square-bracket.com
// xhr2 file upload
// data is optional
$.fn.upload = function(remote,data,successFn,progressFn) {
// if we dont have post data, move it along
if(typeof data != "object") {
progressFn = successFn;
successFn = data;
}
<nav>
<div class="row">
<div class="col-xs-6"></div>
<div class="col-xs-6"></div>
</div>
<div class="row">
<div class="col-xs-6"></div>
<div class="col-xs-6"></div>
</div>
<div class="row" style="height:0%">
module.exports = {
add(req, res) {
var data = req.body;
app.models.file.upload(req.files).then(function(result) {
res.json(result);
});
},
// ==========
// = Animated Scroll =
// ==========
(function($) {
$.modal = bootbox;
$('#top-section').parallax("50%", 0.1);
$('#work').parallax("50%", 0.3);
$('#about').parallax("50%", 0.1);