Skip to content

Instantly share code, notes, and snippets.

@Balamir
Balamir / fix-bootstrap-column-issue.html
Created June 20, 2016 22:05
Fix Bootstrap column issue
Since the columns are not all equal in height you need to add a clearfix <div> for the large viewports
just as the new row should start, that is between your 3rd and 4th column:
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-6">...</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-6">...</div>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-6">...</div>
<!-- Add the extra clearfix for only the required viewport -->
<div class="clearfix visible-md visible-lg"></div>
@Balamir
Balamir / array_avg.php
Created June 15, 2016 20:25
Computing the percentage of values in an array
<?php
$array = array(3,3,2,3,3,1,3,4,5);
function array_avg($array, $round=1){
$num = count($array);
return array_map(
function($val) use ($num,$round){
return array('count'=>$val,'avg'=>round($val/$num*100, $round));
},
array_count_values($array));
@Balamir
Balamir / wordpress-search-query.php
Created June 15, 2016 10:20
Wordpress - Search Query
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : ((get_query_var('page')) ? get_query_var('page') : 1);
$search = array(
'post_type' => 'properties',
'post_status' => 'publish',
'orderby' => $date_order,
'order' => $order,
'pagination' => true,
'posts_per_page' => 10,
@Balamir
Balamir / wp-query-ref.php
Created June 15, 2016 09:23 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@Balamir
Balamir / example-custom-wrapper.js
Created June 14, 2016 13:48
jQuery-backward-timer - Custom wrappers
/* https://github.com/Balamir/jQuery-backward-timer/tree/balamir */
$('#timer-custom-w-wrapper').backward_timer({
seconds: 45296,
use_wrapper: true,
wrappers: {
hours: '.hours_dash .digit',
minutes: '.minutes_dash .digit',
seconds: '.seconds_dash .digit'
}
@Balamir
Balamir / pluralize.php
Created June 3, 2016 13:15
English word plurization
<?php
/*
original : http://stackoverflow.com/a/34254595
*/
function getPluralPrase( $phrase, $value ) {
$plural='';
if( $value > 1 ) {
for( $i = 0; $i < strlen( $phrase ); $i++ ) {
@Balamir
Balamir / gist:3e7e9f8fe3561e112d1c8f181a3d800f
Created May 25, 2016 15:00
Posting Slack message on Google Docs spreadsheet cell update
/**
* @author Chris Tate-Davies
* @web http://blog.tatedavies.com/2016/05/10/posting-slack-message-on-google-docs-spreadsheet-cell-update/
* @revision 0.0.1
*
* 10th May 2016
* Purpose - send a slack payload to bot-database informing users of database update requirements
**/
function ceta_db_column_edit(event){
@Balamir
Balamir / in_array_case_insensitive.php
Created May 25, 2016 08:51
Case insensitive PHP in_array function
<?php
/**
* PHP'nin in_array fonksiyonunun buyuk-kucuk harf duyarsiz hali
*
* @since 2.0
*
* @param string $needle Array icinde aranacak olan deger (igne)
* @param array $haystack Arama yapilacak array (samanlik)
* @return bool
@Balamir
Balamir / serialize_unserialize.php
Created March 20, 2016 20:34
Prevent PHP serialize & unserialize errors
<?php
//to safely serialize
$safe_string_to_store = base64_encode(serialize($multidimensional_array));
//to unserialize...
$array_restored_from_db = unserialize(base64_decode($encoded_serialized_string));
//That's it!
@Balamir
Balamir / st_preferences.json
Created February 26, 2016 13:38
Sublime Text preferences
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"caret_extra_width": 1,
"caret_style": "phase",
"close_windows_when_empty": false,
"color_scheme": "Packages/User/SublimeLinter/Dark-Material (SL).tmTheme",
"draw_minimap_border": true,
"extract_sublime_package_ask_on_open": true,
"fallback_encoding": "UTF-8",