Skip to content

Instantly share code, notes, and snippets.

@carlossalas
carlossalas / VideoAspectRatio.js
Last active October 15, 2020 22:13
Video Aspect Ratio
.video-aspect-ratio {
position: relative;
width: 100%;
height: 0;
padding-bottom: 55%;
iframe {
position: absolute;
width: 100%;
height: 100%;
@carlossalas
carlossalas / YouTubeGetID.js
Created November 22, 2019 17:02
YouTubeGetID
/**
* Get YouTube ID from various YouTube URL
* @author: takien
* @url: http://takien.com
* For PHP YouTube parser, go here http://takien.com/864
*/
function YouTubeGetID(url){
var ID = '';
url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
@carlossalas
carlossalas / index.php
Created October 26, 2018 23:46
CI: Form Validate
public function validate()
{
$this->load->library('form_validation');
$validation_rules = [
[
'field' => 'email',
'rules' => 'trim|required|valid_email'
],
[
@carlossalas
carlossalas / index.php
Created October 26, 2018 19:52
CI: CORS API Rest
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
$method = $_SERVER['REQUEST_METHOD'];
if ($method == "OPTIONS") {
die();
}
@carlossalas
carlossalas / index.css
Created November 22, 2017 18:01
CSS: Toggle Navigation Animation
// HTML
<div id="toggleNav">
<span></span>
<span></span>
<span></span>
<span></span>
</div>
// CSS
@carlossalas
carlossalas / index.js
Created October 11, 2017 17:40
JS: Example Parsley Add Custom error
$('form input').each(function(i, input){
specific_field = $(input).parsley();
window.ParsleyUI.removeError(specific_field, 'serverError');
});
$.post('api/registro/guardar', serializeFormData, function(res){
if ( res.success )
{
callback();
}
@carlossalas
carlossalas / youtube_id_regex.php
Created September 2, 2017 19:13 — forked from ghalusa/youtube_id_regex.php
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
@carlossalas
carlossalas / index.js
Last active October 15, 2020 22:16
Prevent parent scroll when in child div
$('.wrap').on('mousewheel', function(e){
var event = e.originalEvent,
d = event.wheelDelta || -event.detail;
this.scrollTop += ( d < 0 ? 1 : -1 ) * 50;
e.preventDefault();
});
@carlossalas
carlossalas / config.rb
Created January 6, 2017 21:11
Compass: Config
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "scss"
images_dir = "img"
javascripts_dir = "js"
# You can select your preferred output style here (can be overridden via the command line):
@carlossalas
carlossalas / ubigeo_peru.sql
Last active October 15, 2020 22:16
Ubigeo Perú SQL
-- phpMyAdmin SQL Dump
-- version 3.5.8
-- http://www.phpmyadmin.net
--
-- Servidor: localhost
-- Tiempo de generación: 13-03-2014 a las 20:07:46
-- Versión del servidor: 5.5.33-31.1
-- Versión de PHP: 5.3.17
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";