Skip to content

Instantly share code, notes, and snippets.

View slav123's full-sized avatar

Slawomir Jasinski slav123

View GitHub Profile
@slav123
slav123 / gist:3742515
Created September 18, 2012 10:38
createFromFormat
$data_invoice['date'] = DateTime::createFromFormat('d/m/Y', $data_invoice['date'])->format("Y-m-d");
@slav123
slav123 / walk_recursive.php
Created October 2, 2012 10:19
grab id's from table
array_walk_recursive($this->data['invoices'], array($this, '_grab_ids'));
private function _grab_ids($item, $arr_key) {
if ($arr_key == 'id') {
$this->data['ids'][] = $item;
}
}
@slav123
slav123 / gist:3833083
Created October 4, 2012 11:37 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@slav123
slav123 / gist:3838471
Created October 5, 2012 07:00
AmazonS3 PHP create object
include_once('application/libraries/aws/sdk.class.php');
// Instantiate the AmazonS3 class
$this->s3 = new AmazonS3();
$bucket = '';
$body = 'aaa';
$response = $this->s3->create_object($bucket, $this->_feed, array(
@slav123
slav123 / gist:3890760
Created October 15, 2012 04:05
console.log IE
var console=console||{"log":function(){}};
@slav123
slav123 / gist:3897186
Created October 16, 2012 04:06
timezone convert in MySQL
insert into my_table (created_date) values (convert_tz(now(), 'GMT', 'US/Pacific'));
@slav123
slav123 / gist:3897386
Created October 16, 2012 05:42
twitter bootstrap modal remote fix
$('body').on('hidden', '.modal', function () {
$(this).removeData('modal');
});
@slav123
slav123 / pagination.php
Created October 17, 2012 23:29
CodeIgniter pagination file for Twitter Bootstrap pagination styles
<?php
$config['display_pages'] = TRUE;
$config['per_page'] = 18;
$config['full_tag_open'] = '<div class="pagination pagination-small pagination-centered"><ul>';
$config['full_tag_close'] = '</ul></div>';
$config['next_link'] = '&raquo;';
$config['next_tag_open'] = '<li class="next">';
$config['next_tag_close'] = '</li>';
@slav123
slav123 / gist:4274088
Created December 13, 2012 04:49
Extract Number From String MySQL
select uExtractNumberFromString(mobile) from customer_masterCREATE FUNCTION `uExtractNumberFromString`(in_string varchar(50)) RETURNS INT
NO SQL
BEGIN
DECLARE ctrNumber varchar(50);
DECLARE finNumber varchar(50) default ' ';
DECLARE sChar varchar(2);
@slav123
slav123 / gist:4324834
Created December 18, 2012 03:49
get extended access token
/**
* get extended access token
*
* @param string $token token
*
* @return mixed
*/
public function get_extended_access_token($token)
{