Skip to content

Instantly share code, notes, and snippets.

@lakinmohapatra
lakinmohapatra / custom_helper.php
Created February 18, 2016 07:29
Automated js/css files versioning in 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 = '')
{
@lakinmohapatra
lakinmohapatra / touch.js
Created March 11, 2016 11:39
Check for touchscreen devices using javascript
function is_touch_device() {
return (('ontouchstart' in window)
|| (navigator.MaxTouchPoints > 0)
|| (navigator.msMaxTouchPoints > 0));
}
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 / utf8.php
Created July 5, 2019 08:05
Utf encode deep nested array
/**
* 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)) {
@lakinmohapatra
lakinmohapatra / PrintGrid.css
Created July 24, 2019 07:52
Css useful in printing for showing elements in 12 row grid
.row {
width:100%;
}
.column,
.columns {
width: 100%;
float: left;
margin-bottom: 2px;
}
@lakinmohapatra
lakinmohapatra / package.json
Created January 9, 2022 15:18
Create package.json
{
"name": "test",
"scripts": {
"start": "node ./app.js"
}
}
@lakinmohapatra
lakinmohapatra / app.js
Last active January 9, 2022 15:39
Create app.js
process.on('SIGINT', function(){ console.log("SIGINT"); terminate() });
process.on('SIGTERM', function(){ console.log("SIGTERM"); terminate() });
var string = "a";
var terminate = function(){
console.log("shuting down...");
string = "b";
setTimeout(function(){
@lakinmohapatra
lakinmohapatra / web3.txt
Created January 22, 2022 17:27
Roadmap to learn web3
Frontend:
- HTML
- CSS
- JavaScript
- React.js
Backend:
- Solidity (smart contracts)
Tools & Libraries: