Skip to content

Instantly share code, notes, and snippets.

View fideloper's full-sized avatar
🏠
Working from home

Chris Fidao fideloper

🏠
Working from home
View GitHub Profile
@fideloper
fideloper / twitter.linkify.js
Created October 20, 2011 23:17
Linkify Twitter feed (@usernames, #hashtags and links)
String.prototype.linkify_tweet = function() {
var tweet = this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/g, function(url) {
var wrap = document.createElement('div');
var anch = document.createElement('a');
anch.href = url;
anch.target = "_blank";
anch.innerHTML = url;
wrap.appendChild(anch);
return wrap.innerHTML;
});
@fideloper
fideloper / curl_results.sh
Created December 1, 2011 15:23
Shell - append curl JSON request results in a nice format to an output file, with basic auth - mjson tool
#With Basic Auth
curl --user someuser:somepassword -d 'some_post=variables&go=here' http://api.somecoolapi.com/json.somedata | python -mjson.tool >> /path/of/file/to/export/to.txt
#Without Basic Auth
curl -d 'some_post=variables&go=here' http://api.somecoolapi.com/json.somedata | python -mjson.tool >> /path/of/file/to/export/to.txt
#More Goodies: http://www.davidslog.com/1187630823/format-xml-json-from-command-line
@fideloper
fideloper / EEembed.html
Created December 7, 2011 14:56
Example SEO module use
<!-- Some embed code in any template -->
{embed='site/_header' title='Some Title' keywords='some,keywords' description='a description'}
<!-- site.group/_header.html -->
<!doctype html>
<html>
<head>
<title>{embed:title}</title>
<meta name="keywords" content="{embed:keywords}" />
<meta name="description" content="{embed:description}" />
@fideloper
fideloper / h5bp.sh
Created December 27, 2011 20:18
Download and setup basic h5bp from github.com
#!/usr/bin/bash
git clone https://github.com/paulirish/html5-boilerplate.git
cd html5-boilerplate
git checkout v2.0stripped
@fideloper
fideloper / application.ini
Created January 20, 2012 15:53
Zend Translate
resources.locale.default = "en_US"
resources.translate.content = APPLICATION_PATH "/../data/locales"
resources.translate.scan = "directory"
resources.translate.adapter = "csv"
resources.translate.delimiter = ","
resources.translate.default = "en"
;File localization structure example:
;
; project_root/data/locales/en/lang_en.csv
<?php
class IndexController extends Zend_Controller_Action
{
private $lang;
public function init() {
$this->lang = Zend_Registry::get('Zend_Translate');
@fideloper
fideloper / index.phtml
Created January 20, 2012 16:04
Sample view
<!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="no-js ie6" lang="en" mlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if IE 7 ]> <html class="no-js ie7" lang="en" mlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if IE 8 ]> <html class="no-js ie8" lang="en" mlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<script type="text/javascript">var _sf_startpt=(new Date()).getTime()</script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
@fideloper
fideloper / postdeploy.php
Created February 4, 2012 18:06
Beanstalk Post deploy hooks
<?php
$deploy_json = @file_get_contents('php://input');
if (!empty($deploy_json))
{
$deploy_data = json_decode($deploy_json);
//Log output to file (overwrites on each deploy). Make sure file is 0777
file_put_contents('results.txt', print_r($deploy_data, true));
@fideloper
fideloper / enclosures.js
Created April 13, 2012 13:53
More fun Javascript enclosures
Instead of the "traditional":
(function() {
})();
You can do:
!function(){
@fideloper
fideloper / perm.sh
Created April 24, 2012 18:57
Script for file permssion (Expressionengine)
#!/bin/bash
# Find location of this script.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#Standard permissions
find "$DIR"/ -type d -print0 | xargs -0 chmod 775
find "$DIR"/ -type f -print0 | xargs -0 chmod 664
#Alternatively 0777 these