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 / clip_thumb.php
Created March 12, 2012 05:26
Fed - CakePHP
<img src="<?= $this->Thumb->clip_thumb('ImageFilename','300x300'); ?>" alt="" />
@fedmich
fedmich / Expire headers.htaccess
Created March 19, 2012 06:28
HTaccess apache
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType image/x-icon "access plus 2692000 seconds"
ExpiresByType image/jpeg "access plus 2692000 seconds"
ExpiresByType image/png "access plus 2692000 seconds"
ExpiresByType image/gif "access plus 2692000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2692000 seconds"
ExpiresByType text/css "access plus 2692000 seconds"
ExpiresByType text/javascript "access plus 2692000 seconds"
@fedmich
fedmich / chmod.cmd
Created March 28, 2012 04:41
Linux Commands (ubuntu)
sudo chmod 777 -R PATH
@fedmich
fedmich / doc_append.js
Created April 9, 2012 09:01
Javascript Codes
function doc_append ( obj ){
if( document.getElementsByTagName("head").length > 0 ){
document.getElementsByTagName("head")[0].appendChild( obj );
}
else{
document.getElementsByTagName("body")[0].appendChild( obj );
}
}
var url_css = 'http://example.com/css/file.css';
@fedmich
fedmich / append_external.js
Created April 11, 2012 07:09
Javascript Codes (Bookmarklets)
javascript:(function(){document.body.appendChild(document.createElement('script')).src='http://example.com/js/bookmarklet.min.js?r='+(Math.random()*99999999);})();
@fedmich
fedmich / ai_autoselect.js
Created April 12, 2012 02:53
Javascript A.I.
/*
AI, Auto Select an item from select dropdown, based on url
* @author fedmich
* @version 1.0
*/
function ai_autoselect ( css_select , url ){
if( ! url ){ return; }
var obj_sel = $( css_select )
if(obj_sel.val()){
return true; //user already picked something, just skip
@fedmich
fedmich / hyperlink google search query
Created April 18, 2012 07:25
Google Docs, Spreadsheet
@fedmich
fedmich / post_query.py
Created April 20, 2012 07:50
Python codes
import httplib, urllib
params = urllib.urlencode({
'param': 'value',
'param2': 'value2'
})
headers = {
"Content-type": "application/x-www-form-urlencoded",
"Accept": "text/plain"
@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');
}
});
@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>'