Skip to content

Instantly share code, notes, and snippets.

View devyfriend's full-sized avatar

devyfriend

View GitHub Profile
/*
example require.js setup file
*/
var G5 = window.G5 || {
photo_editor: false
};
require.config({
baseUrl: base_url,
var casper = require('casper').create({
clientScripts: ["c:/phantomjs/casperjs/includes/jquery.js"]
});
var cnt = 0, tots = 666;
var param = {
'duration[from]':115,
'duration[to]':375,
'numberOfFlights':300,
/*
requirejs optimization setup config file
howto: node r.js -o build.js
*/
({
//appDir : '../',
baseUrl : '../js',
dir : '../release',
name: 'main',
@devyfriend
devyfriend / notes
Last active December 10, 2015 12:19
/* search twitter hash */
url: http://search.twitter.com/search.json?page=6&max_id=286412943002836992&q=%23GALAXYCamHoliday&rpp=99&include_entities=1&result_type=mixed
docs: https://dev.twitter.com/docs/api/1/get/search
/* twitter user */
https://api.twitter.com/1/users/lookup.json?screen_name=devyfriend&include_entities=true
/* fb share */
function posttofb(){
@devyfriend
devyfriend / MY_Router.php
Created January 11, 2013 13:55
Codeigniter DB Router for Modular
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');
/* load the MX_Router class */
require APPPATH."third_party/MX/Router.php";
class MY_Router extends MX_Router {
function _set_routing()
{
// Are query strings enabled in the config file? Normally CI doesn't utilize query strings
@devyfriend
devyfriend / MY_Exceptions.php
Created January 24, 2013 16:37
custom 404 overides for codeigniter so we can just call "show_404('say something')" anywhere from the code, put this file in application/core, still need to edit $route['404_override'] = 'welcome/error_404'; in config/routes.php and create valid controller or nasty error will appear when browse to false url
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Exceptions extends CI_Exceptions {
public function __construct()
{
parent::__construct();
}
function show_404($message = "The page you requested was not found.")
@devyfriend
devyfriend / ckeditor_ckfinder.html
Last active December 11, 2015 15:59
javascript to load ckeditor with ckfinder
<script>
/*
note:
- dont forget to set ckfinder/config.php $baseUrl for userfiles folder
- in ckfinder/config.php, set the function CheckAuthentication(){ return true; } to enable file browsing
*/
var div = $('textarea[name=blog_body]').get(0);
var editor = CKEDITOR.replace( div,
{
filebrowserBrowseUrl : base_url + 'assets/ckfinder/ckfinder.html?id=demo3',
@devyfriend
devyfriend / config.php
Last active December 11, 2015 16:08
modified codeigniter config file, useful to detect the server in http or https, especialy when the app is inside an iframe
$referer = isset($_SERVER['HTTP_REFERER']) ? parse_url($_SERVER['HTTP_REFERER']) : false;
$scheme = isset($referer['scheme']) ? $referer['scheme'] : 'http';
$config['base_url'] = $scheme.'://'.$_SERVER['HTTP_HOST'].'/';
$config['scheme_url'] = $scheme;
$config['asset_url'] = $config['base_url'].'assets/';
$config['index_page'] = ''; // empty it
@devyfriend
devyfriend / .htaccess
Last active August 30, 2021 04:23
common htaccess for codeigniter to remove /index.php/controllers, "Options -Indexes" is to disable directory browsing without index file
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|img|css|js|robots\.txt)
@devyfriend
devyfriend / apache_php
Last active December 11, 2015 16:18
my common setting with wampserver
/* httpd.conf */
Listen 91
<Virtualhost *:91>
ServerName localhost
ServerAdmin me@me.com
DirectoryIndex index.html index.php
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" comonvhost
CustomLog logs/access_log_99.txt comonvhost
DocumentRoot "d:/wamp/www/whatever/"