Skip to content

Instantly share code, notes, and snippets.

View slav123's full-sized avatar

Slawomir Jasinski slav123

View GitHub Profile
@slav123
slav123 / twitter.js
Created April 2, 2012 02:15
Reload twitter share button without calling script
twttr.widgets.load();
@slav123
slav123 / urlize.js
Created April 2, 2012 02:16
make active url's from javascript
jQuery('#last_tweet').urlize();
jQuery.fn.urlize = function() {
if (this.length > 0) {
this.each(function(i, obj){
// making links active
var x = jQuery(obj).html();
var list = x.match( /\b(http:\/\/|www\.|http:\/\/www\.|https:\/\/www\.|https:\/\/)[^ <]{2,200}\b/g );
if (list) {
for ( i = 0; i < list.length; i++ ) {
@slav123
slav123 / gplus
Created April 2, 2012 04:43
googleplus async buttons
<!-- Place this tag in your head or just before your close body tag -->
<script type="text/javascript" src="https://apis.google.com/js/plusone.js">
{parsetags: 'explicit'}
</script>
<!-- Place this tag where you want the +1 button to render -->
<g:plusone></g:plusone>
<!-- Place this render call where appropriate -->
<script type="text/javascript">gapi.plusone.go();</script>
@slav123
slav123 / .htaccess
Created April 22, 2012 01:17
htaccess opt
# Apache configuration file
# httpd.apache.org/docs/2.2/mod/quickreference.html
# Note .htaccess files are an overhead, this logic should be in your Apache config if possible
# httpd.apache.org/docs/2.2/howto/htaccess.html
# Techniques in here adapted from all over, including:
# Kroc Camen: camendesign.com/.htaccess
# perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
# Sample .htaccess file of CMS MODx: modxcms.com
@slav123
slav123 / gist:3616736
Created September 4, 2012 04:55
RTF to plaintext
<?php
// Function that checks whether the data are the on-screen text.
// It works in the following way:
// an array arrfailAt stores the control words for the current state of the stack, which show that
// input data are something else than plain text.
// For example, there may be a description of font or color palette etc.
function rtf_isPlainText($s) {
$arrfailAt = array("*", "fonttbl", "colortbl", "datastore", "themedata");
for ($i = 0; $i < count($arrfailAt); $i++)
@slav123
slav123 / gist:3616737
Created September 4, 2012 04:56
calc age from date
/**
* age calculations based on date
*
* @param date $birth_date date in format Y-m-d
*
* @return bool|int
*/
function age($birth_date)
{
if (! preg_match('/\d{4}-\d{2}-\d{2}/', $birth_date)) {
@slav123
slav123 / gist:3627945
Created September 4, 2012 23:19
pagination
/**
* pobieramy liste produktow
*
* @param integer $start od rekordu
* @param integer $limit ilość wyników
* @param integer $category_id id kategorii
*
* @return void
*/
public function products($start = 0, $limit = NULL, $category_id = NULL)
@slav123
slav123 / gist:3684106
Created September 9, 2012 12:39
mount freebsd
mount_msdosfs -o large -L pl_PL.UTF-8 /dev/da0s1 /mnt/usb2/
@slav123
slav123 / gist:3695925
Created September 11, 2012 04:20
twitter bootstrap typeahead workign example
$('.typeahead').typeahead({
source: function (query, process) {
return $.get('/typeahead', { query: query }, function (data) {
return process(data);
});
}
});
@slav123
slav123 / gist:3742268
Last active October 10, 2015 19:48
make assoc
<?php
/**
* @param $arr
* @param string $key
*
* @return void
*/
function make_assoc(&$arr, $key = 'id')
{
$tmp = $arr;