Skip to content

Instantly share code, notes, and snippets.

View ncou's full-sized avatar
🪲
Catching bugs !

ncou

🪲
Catching bugs !
View GitHub Profile
// See https://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit, jQuery version with arrays and objects support
function post(path, parameters) {
var form = $('<form></form>');
form.attr("method", "post");
form.attr("action", path);
$.each(parameters, function(key, value) {
if ( typeof value == 'object' || typeof value == 'array' ){
$.each(value, function(subkey, subvalue) {
@ncou
ncou / multiple-file-upload.php
Created November 17, 2016 22:28 — forked from tutweb/multiple-file-upload.php
Script upload multiple file dengan PHP
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Multiple File Upload dengan PHP | Jurnalweb.com</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" id="file" name="files[]" multiple="multiple" accept="image/*" />
<input type="submit" value="Upload!">
@ncou
ncou / Javascript - Simple email validation
Created November 28, 2016 21:50 — forked from dreamstarter/Javascript - Simple email validation
Javascript - Use a regex to check the email address input.
function checkEmail(email) {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if (!reg.test(email)) return false;
return true;
}
@ncou
ncou / example-user.js
Created November 28, 2016 21:51 — forked from nijikokun/example-user.js
Beautiful Validation... Why have I never thought of this before?!
var user = {
validateCredentials: function (username, password) {
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9_-]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);
@ncou
ncou / JavaScript Form Validation
Created November 28, 2016 21:51
Simple JavaScript Form Validation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>JavaScript HOMEWORK</title>
<style>
strong{
font-style:italic;
font-size:20px;
}
https://github.com/saxman6989/materializeModal/blob/master/materializeModal.js
https://github.com/jenstornell/img-defer.js/blob/master/img-defer.js
https://github.com/theuves/subir.js/blob/master/subir.js
https://github.com/nishanths/zoom.js/blob/master/js/zoom.js
https://github.com/VodkaBears/Remodal/blob/master/src/remodal.js
https://github.com/quru/image-defer/blob/master/src/image-defer.js
https://github.com/ncou/image-defer-loader/blob/master/img-defer.js
https://github.com/benceg/vanilla-modal/blob/master/dist/index.js
https://github.com/julienzmiro/zoomzoomzang/blob/master/zzz.js
https://github.com/moqmar/tinyfade.js
@ncou
ncou / detect-touch.js
Created January 5, 2017 01:22 — forked from c3ry5/detect-touch.js
To detect if i device supports touch events with a jquery scroll function
var isTouch = function () {
return 'ontouchend' in document;
}
@ncou
ncou / .htaccess
Created January 8, 2017 16:24 — forked from GaryJones/.htaccess
Security Headers
<IfModule mod_headers.c>
# HSTS - force redirect to HTTPS at the browser level.
# Submit for Chrome preload list at https://hstspreload.appspot.com/
# Header always set Strict-Transport-Security: "max-age=31536000; includeSubDomains; preload" env=HTTPS
# X-Xss-Protection
Header always set X-XSS-Protection "1; mode=block"
# Stop clickjacking by only allowing us to frame our own site
Header always set X-Frame-Options "SAMEORIGIN"
@ncou
ncou / delete array
Created March 12, 2017 00:01 — forked from chad3814/gist:2924672
deleting array items in javascript with forEach() and splice()
// This is from my comment here: http://wolfram.kriesing.de/blog/index.php/2008/javascript-remove-element-from-array/comment-page-2#comment-466561
/*
* How to delete items from an Array in JavaScript, an exhaustive guide
*/
// DON'T use the delete operator, it leaves a hole in the array:
var arr = [4, 5, 6];
delete arr[1]; // arr now: [4, undefined, 6]
@ncou
ncou / README.md
Created April 16, 2017 16:23 — forked from paulirish/README.md
imagesLoaded() jquery plugin