Skip to content

Instantly share code, notes, and snippets.

View craiem's full-sized avatar

craiem

View GitHub Profile
Verifying I am +craiem on my passcard. https://onename.com/craiem
@craiem
craiem / gist:5337373
Created April 8, 2013 14:51
php -> db.php snippet
require('db.php');
//$db->select($table,$where=array(),$limit=false,$order=false,$where_mode="AND",$print_query=false)
//$db->update($table, $fields=array(), $where=array())
//$db->insert($table, $fields=array())
$db = new db($database_name, $username, $password, $host); // $host is optional and defaults to 'localhost'
@craiem
craiem / db.php
Created March 26, 2013 19:53
php -> db.php
<?php
// MySQL Database interface class
class DB {
private $sql;
private $mysql;
private $result;
private $db;
public $serialize_bool = true; // Arrays are serialized automatically, booleans too?
@craiem
craiem / gist:5247388
Last active December 15, 2015 10:39
php -> if localhost
if(preg_match('/localhost/', $_SERVER['HTTP_HOST'])){
//DATOS OFFLINE
$dbname = "";
$ipserver = "localhost";
$usuariobase = "root";
$passbase = "root";
} else {
//DATOS ONLINE
$dbname = "";
$ipserver = "localhost";
@craiem
craiem / manually-validate.js
Created March 26, 2013 14:00 — forked from martinnormark/manually-validate.js
Js -> Validate Form
validate: function () {
var form = this.$el.is("form") ? this.$el : this.$el.closest("form");
if (!form.is("form")) {
form = this.$el.find("form");
}
return form.data().unobtrusiveValidation.validate();
}
@craiem
craiem / google-image-search.php
Created March 24, 2013 01:11 — forked from susanBuck/google-image-search.php
php -> Google image Search
<?php
# This grabs the keyword off the url -- index.php?keyword=Clouds
$keyword = $_GET['keyword'];
# Only do this if we've already passed in a keyword (i.e. it's not blank)
if($keyword != "") {
# Load the data from Google via cURL
$curl_handle = curl_init();
curl_setopt($curl_handle,CURLOPT_URL,"http://ajax.googleapis.com/ajax/services/search/images?v=1.0&imgsz=xlarge&q=".urlencode($keyword));
@craiem
craiem / detectMobile.js
Created March 24, 2013 01:06 — forked from keriati/detectMobile.js
js -> DetectMobile
// Bad practice!
function detectMobile() {
return (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
}