Skip to content

Instantly share code, notes, and snippets.

Avatar

lakinmohapatra

View GitHub Profile
@lakinmohapatra
lakinmohapatra / PrintGrid.css
Created Jul 24, 2019
Css useful in printing for showing elements in 12 row grid
View PrintGrid.css
.row {
width:100%;
}
.column,
.columns {
width: 100%;
float: left;
margin-bottom: 2px;
}
@lakinmohapatra
lakinmohapatra / utf8.php
Created Jul 5, 2019
Utf encode deep nested array
View utf8.php
/**
* Converts array into utf8
*
* @param Array $array
* @return Array
*/
function utf8_converter($array)
{
array_walk_recursive($array, function (&$item, $key) {
if (!mb_detect_encoding($item, 'utf-8', true)) {
View gist:c0a09df37b3647b0930d99cbddce5615
function wrapText(context, text, x, y, maxWidth, lineHeight) {
var words = text.split(" ");
var line = "";
for(var n = 0; n < words.length; n++) {
var testLine = line + words[n] + " ";
var metrics = context.measureText(testLine);
var testWidth = metrics.width;
if(testWidth > maxWidth) {
context.fillText(line, x, y);
line = words[n] + " ";
@lakinmohapatra
lakinmohapatra / touch.js
Created Mar 11, 2016
Check for touchscreen devices using javascript
View touch.js
function is_touch_device() {
return (('ontouchstart' in window)
|| (navigator.MaxTouchPoints > 0)
|| (navigator.msMaxTouchPoints > 0));
}
@lakinmohapatra
lakinmohapatra / custom_helper.php
Created Feb 18, 2016
Automated js/css files versioning in php
View custom_helper.php
<?php
if (! function_exists('version')) {
/**
* Used to add file modified time for versioning css/js files.
*
* @param String $filePath - physical path of file.
* @return String FilePath
*/
function version($filePath = '')
{
You can’t perform that action at this time.