Skip to content

Instantly share code, notes, and snippets.

View jpalala's full-sized avatar
🎯
Focusing

Jose Palala jpalala

🎯
Focusing
View GitHub Profile
@jpalala
jpalala / slug-url-gen.php
Last active September 26, 2022 05:32 — forked from anonymous/gist:2912227
Slug URL generator for seo (removes spaces hyphens, and other characters)
<?php
function slugify($str) {
$search = array('Ș', 'Ț', 'ş', 'ţ', 'Ş', 'Ţ', 'ș', 'ț', 'î', 'â', 'ă', 'Î', 'Â', 'Ă', 'ë', 'Ë');
$replace = array('s', 't', 's', 't', 's', 't', 's', 't', 'i', 'a', 'a', 'i', 'a', 'a', 'e', 'E');
$str = str_ireplace($search, $replace, strtolower(trim($str)));
$str = preg_replace('/[^\w\d\-\ ]/', '', $str);
$str = str_replace(' ', '-', $str);
return preg_replace('/\-{2,}', '-', $str);
}
@jpalala
jpalala / index.js
Last active October 19, 2015 10:43
Cors simple sample
function createCORSRequest(method, url) {
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr) {
// XHR for Chrome/Firefox/Opera/Safari.
xhr.open(method, url, true);
console.log('withCredentials') } else if (typeof XDomainRequest != "undefined") {
// XDomainRequest for IE.
xhr = new XDomainRequest();
xhr.open(method, url);
@jpalala
jpalala / get-db-details.sh
Created December 19, 2014 02:26
Find DB connection details from wp-config using bash
cat wp-config.php | grep DB
@jpalala
jpalala / mentorsdojo.dev.conf
Created December 24, 2014 01:14
apache vhosts sample for mentorsdojo - located in xampp/apache/conf/extra/httpd-vhosts.conf
#
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "C:/xampp/htdocs/mentorsdojo.com/public"
ServerName mentorsdojo.local
ServerAlias mentorsdojo.dev
ErrorLog "logs/mdojodev-error.log"
CustomLog "logs/mdojodev-access.log" common
</Directory>
@jpalala
jpalala / parse-url.gist.js
Created February 2, 2015 08:55
url-parsing with nodejs
var http = require('http');
var sys = require('sys'),
fs = require('fs'),
http = require('http'),
url = require('url');
http.createServer(function (req, res) {
var url_parts = url.parse(req.url);
sys.puts(url_parts.pathname);
@jpalala
jpalala / tcplistener.js
Created February 3, 2015 09:54
node based tcp listener
var net = require('net');
var client_ctr = 0;
var server = net.createServer(function (socket) {
client_ctr++;
console.log("Client" + client_ctr + "connected");
socket.write("Connected to server");
socket.pipe(socket);
});
@jpalala
jpalala / node-webserver-simple.js
Created February 3, 2015 10:27
simple webserver in nodejs
var http = require('http')
, url = require('url')
, fs = require('fs')
, server;
server = http.createServer(function(req, res) {
var path = url.parse(req.url).pathname;
switch(path) {
@jpalala
jpalala / vimrc
Created March 19, 2015 02:00
dot.backup.vimrc
" bundle that works
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#begin()
Bundle 'gmarik/vundle'
Bundle 'scrooloose/syntastic'
Bundle 'scrooloose/nerdtree'
set tabstop=8
set expandtab
@jpalala
jpalala / eden-php-model.php
Last active August 29, 2015 14:18 — forked from adin234/mode.php
Eden PHP Model how-to
<?php
/* MODEL */
class Some_Model extends Eden_Sql_model {
protected $_table = 'some_table';
public function __construct($database = null) {
$this->_database = $database ? $database : front()->database();
//do some other things here
}
@jpalala
jpalala / index.php.md
Last active August 29, 2015 14:18
How to enable "?debug=1" to debug in Eden PHP framework

For easier debugging, add this to the else block on index.php then in front.php, instead of print front(), put $front = front()

//... else {
    require('front.php'); //$front = front()->withSugar()->addSpice()->andEverythingNice().. 
        if(isset($_GET['debug'])) {
            var_dump($front); 
        } else {
            print $front; 

}