Skip to content

Instantly share code, notes, and snippets.

@oghenez
oghenez / object-to-form-data.js
Created May 21, 2024 20:48 — forked from ghinda/object-to-form-data.js
JavaScript Object to FormData, with support for nested objects, arrays and File objects. Includes Angular.js usage.
// takes a {} object and returns a FormData object
var objectToFormData = function(obj, form, namespace) {
var fd = form || new FormData();
var formKey;
for(var property in obj) {
if(obj.hasOwnProperty(property)) {
if(namespace) {
<!DOCTYPE html>
<html lang="en">
<head>
<style>
body {
margin: 0;
padding: 0;
font-family: 'PT Sans', sans-serif;
}
@oghenez
oghenez / MY_Form_validation.php
Created April 19, 2024 21:59 — forked from Aramics/MY_Form_validation.php
Codeigniter is_unique for multiple fields
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Form_validation extends CI_Form_validation {
protected $CI;
public function __construct($rules = array())
{
parent::__construct($rules);
$this->CI =& get_instance();
/// <summary>
/// A listing of ASCII control characters for readability.
/// </summary>
public static class AsciiControlChars
{
/// <summary>
/// Usually indicates the end of a string.
/// </summary>
public const char Nul = (char)0x00;
@oghenez
oghenez / HostNameRouter.php
Created November 28, 2017 09:46 — forked from chill117/HostNameRouter.php
Manage multiple hostnames (domains, sub-domains) within a single instance of CodeIgniter.
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/*
Manage multiple hostnames (domains, sub-domains) within a single instance of CodeIgniter.
Example:
If you had the following domain/sub-domain style for your site:
your-domain.com
@oghenez
oghenez / ajax-form.js
Created September 20, 2013 21:41 — forked from havvg/ajax-form.js
jQuery(function($) {
$('form[data-async]').live('submit', function(event) {
var $form = $(this);
var $target = $($form.attr('data-target'));
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),