Skip to content

Instantly share code, notes, and snippets.

View joemar-tagpuno's full-sized avatar

Joemar Tagpuno joemar-tagpuno

View GitHub Profile
@joemar-tagpuno
joemar-tagpuno / mysql-rename-db.sh
Created January 24, 2018 06:02 — forked from tadas-s/mysql-rename-db.sh
MySQL database rename script
#!/bin/bash
# Disclaimer - make backups, use at your own risk.
#
# Based on this comment: http://stackoverflow.com/a/13944924/843067
# Views and stored procedures have to be done separately.
OLDDB="old_db_name"
NEWDB="new_db_name"
MYSQL="mysql -u root -pyour_password "
<?php
$db_con = mysqli_connect("localhost", "username", "password", "database");
$result = $db_con->query('SELECT * FROM some_table');
if (!$result) die('Couldn\'t fetch records');
$num_fields = mysqli_num_fields($result);
$headers = array();
while ($fieldinfo = mysqli_fetch_field($result)) {
$headers[] = $fieldinfo->name;
}
$fp = fopen('php://output', 'w');
@joemar-tagpuno
joemar-tagpuno / gist:ed5f79f8a756ac147174e2765c4b6409
Last active October 19, 2017 15:29 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@joemar-tagpuno
joemar-tagpuno / SecureSessionHandler.php
Created September 30, 2016 03:56 — forked from eddmann/SecureSessionHandler.php
Secure session handler implementation.
<?php
class SecureSessionHandler extends SessionHandler {
protected $key, $name, $cookie;
public function __construct($key, $name = 'MY_SESSION', $cookie = [])
{
$this->key = $key;
$this->name = $name;
@joemar-tagpuno
joemar-tagpuno / config.php
Created May 2, 2016 05:44 — forked from HostedPCI/config.php
Php code samples
<?php
$params = new stdClass;
$params->hpci_site_host_name = baseurl();
$params->hpci_site_id = '520900';
$params->hpci_location = 'checkout1';
$params->hpci_query_string = $_SERVER['QUERY_STRING'];
$params->hpci_api_host = 'https://api-wisvis1stg.c1.hostedpci.com/';
$params->hpci_api_uid = 'ObtainTestAccount';
$params->hpci_api_pwd = '*****';
?>
@joemar-tagpuno
joemar-tagpuno / jquery.deparam.js
Created April 19, 2016 03:35 — forked from samny/jquery.deparam.js
jQuery.deparam - The oposite of jQuery param. Creates an object of query string parameters
/**
* jQuery.deparam - The oposite of jQuery param. Creates an object of query string parameters.
*
* Credits for the idea and Regex:
* http://stevenbenner.com/2010/03/javascript-regex-trick-parse-a-query-string-into-an-object/
*/
(function($){
$.deparam = $.deparam || function(uri){
if(uri === undefined){
uri = window.location.search;
@joemar-tagpuno
joemar-tagpuno / backbone-validation-bootstrap.js.coffee
Last active September 14, 2015 09:38 — forked from driehle/backbone-validation-bootstrap.js.coffee
Render error messages of Backbone.Validation for Twitter Bootstrap
# --------------------------------------------
# This code is for Twitter Bootstrap 2!
# --------------------------------------------
#
# The MIT License (MIT)
# Copyright (c) 2012-2015 Dennis Riehle
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
@joemar-tagpuno
joemar-tagpuno / amd-jquery-plugin.js
Last active August 29, 2015 14:27 — forked from simonsmith/amd-jquery-plugin.js
AMD compatible plugin for jQuery
// UMD dance - https://github.com/umdjs/umd
!function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else {
factory(root.jQuery);
}
}(this, function($) {
'use strict';
@joemar-tagpuno
joemar-tagpuno / app.js
Last active August 29, 2015 14:26 — forked from geekdave/app.js
backbone.js sub routing
var MyApp = {};
MyApp.Router = Backbone.Router.extend({
routes: {
// general routes for cross-app functionality
"" : "showGeneralHomepage",
"cart" : "showShoppingCart",
"account" : "showMyAccount",
// module-specific subroutes:
@joemar-tagpuno
joemar-tagpuno / app.js
Last active August 29, 2015 14:26 — forked from tbranyen/app.js
backbone.js sub routing
/* Pretend app setup stuff is here */
/* Kick off app */
jQuery(function($) {
var Gallery = app.module("gallery");
app.Router = Backbone.Router.extend({
initialize: function() {
this.gallery = new Gallery.Router("gallery/");