This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// More details here: | |
// https://vyspiansky.github.io/2017/11/09/remote-file-exists-using-get-headers/ | |
$file_headers = @get_headers($url); | |
if ($file_headers[0] == 'HTTP/1.0 404 Not Found'){ // or "HTTP/1.1 404 Not Found" etc. | |
$file_exists = false; | |
} else { | |
$file_exists = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var decoded = $("<div/>").html(encodedStr).text(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: http://goo.gl/xMnHZj | |
function str_repeat($string, $multiplier) { | |
return new Array($multiplier+1).join($string) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code snippets for dynamically loading JavaScript and CSS | |
// Copyright : This script has been placed in the public domain. | |
// Gist : https://gist.github.com/livibetter/5211293 | |
// Blog post : http://blog.yjl.im/2013/03/dynamically-loading-javascript-and-css.html | |
// Last update : 2013-03-21T07:35:25Z | |
// Author : Yu-Jie Lin | |
// Website : http://yjl.im | |
function load_CSS(src, cb) { | |
var link = document.createElement('link'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: http://goo.gl/aFVBWn | |
SELECT DATEDIFF(now(), created_at) * 24 AS hours_passed FROM table_name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Source: http://goo.gl/qyLFbg | |
$html = '<img border="0" src="/images/image.jpg" alt="Image" width="100" height="100" />'; | |
preg_match( '@src="([^"]+)"@' , $html, $match ); | |
$src = array_pop($match); | |
// will return /images/image.jpg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://goo.gl/uO78lh | |
$("#myForm :input[value!='']").serialize(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Source: http://goo.gl/ZZrUWw | |
// See also: http://goo.gl/PCxJmO | |
public function relations() { | |
return array( | |
'rel' => array( | |
self::MANY_MANY, 'MyClass', 'table(id_1, id_2)', | |
'condition' => 'some conditions' | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
// Add first and last menu item classes | |
$('ul li:first-child').addClass('first-item'); | |
$('ul li:last-child').addClass('last-item'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: http://goo.gl/Afq20G | |
$(document).ready(function() { | |
$('textarea[maxlength]').keyup(function(){ | |
//get the limit from maxlength attribute | |
var limit = parseInt($(this).attr('maxlength')); | |
//get the current text inside the textarea | |
var text = $(this).val(); | |
//count the number of characters in the text |