Skip to content

Instantly share code, notes, and snippets.

View fedmich's full-sized avatar
🏠
Working from home. open for job opportunity

Federico fedmich

🏠
Working from home. open for job opportunity
View GitHub Profile
@fedmich
fedmich / check running on port 80.bat
Created August 6, 2012 07:27
MS-DOS Command Prompt
netstat -o -n -a | findstr 0.0:80
<?php
/*
* @author Fedmich
* @version v1.1
* File caching version
*/
function GetHTML($url, $secs = 900) {
$md5 = md5($url);
$file = dirname(__FILE__) . "/cache/page_$md5.tmp";
@fedmich
fedmich / memcache php.ini
Created May 16, 2012 03:40
memcached, PHP ini configurations
extension=php_memcache.dll
[Memcache]
memcache.allow_failover = 1
memcache.max_failover_attempts=20
memcache.chunk_size =8192
memcache.default_port = 11211
Ctl+Shift+Del on Chrome opens up the "Clear Browsing Data" window
@fedmich
fedmich / image types.php
Created May 11, 2012 08:34
Regular Expressions (RegEx)
<?php
if(preg_match( '@.*\.(png|jpeg|jpg|gif|bmp)@i', $url) ){
$img_type = 'image';
}
?>
Public
@fedmich
fedmich / executeScript.js
Created April 27, 2012 07:57
Chrome Extensions
chrome.tabs.executeScript(null,
{code:"document.body.bgColor='red'"});
@fedmich
fedmich / cakephp_hide_debug_sql.js
Created April 23, 2012 08:37
CakePHP - Debug tools
$(function() {
$('table.cake-sql-log').css({border:'red 1px dashed'});
$('table.cake-sql-log tbody').hide();
$('table.cake-sql-log thead')
.prepend($('<tr><td colspan="4"><a href="#" onclick="return sql_toggle();" style="font-weight:bold; color:red;" >Hide/Show SQLDump</a></td></tr>'));
});
function sql_toggle (){
$('table.cake-sql-log tbody').toggle();
return false;
@fedmich
fedmich / h2_span1stw.htm
Created April 21, 2012 23:41
Stack overflow answers
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
var obj_h2 = $('h2');
var h2_title = obj_h2.html();
var words = h2_title.split(' ');
words[0] = '<span>' + words[0] + '</span>'
@fedmich
fedmich / hide_other_elements.js
Created April 21, 2012 02:50
Javascript - Hide elements like iframe, embedded objects on the page
/*
Hides iframe from youtube, embedded objects
*/
function hide_other_elements(){
var iframes = document.getElementsByTagName('iframe');
jQuery(iframes).each(function(){
if( (this.src + '').match('http://www.youtube.com/embed/') ){
jQuery( this ).parent().addClass('hidden_elements');
}
});