Skip to content

Instantly share code, notes, and snippets.

@jgarciaruiz
jgarciaruiz / all-iphones-mediaqueries.css
Created April 6, 2021 15:17
All iPhone CSS media queries
/* iphone 3 */
@media only screen and (min-device-width: 320px) and (max-device-height: 480px) and (-webkit-device-pixel-ratio: 1) {
// whatever
}
/* iphone 4 */
@media only screen and (min-device-width: 320px) and (max-device-height: 480px) and (-webkit-device-pixel-ratio: 2) {
// whatever
}
@jgarciaruiz
jgarciaruiz / geolocateUser.js
Created June 27, 2019 11:01
geolocation promise
geolocateUser() {
return new Promise((resolve, reject) => {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(position => {
let coordinates = {};
coordinates.lat = position.coords.latitude;
coordinates.long = position.coords.longitude
<select name="month" id="month" class="select_month">
<?php
for ($i = 1; $i <= 12; $i++){
$monthNumber = ($i < 10) ? '0'.$i : $i;
$monthStr = date('F', strtotime("$currentYear-$monthNumber"));
echo '<option value="'.$monthNumber.'"';
if ($i == $currentMonth){
echo ' selected="selected"';
}
echo '>'.$monthStr.'</option>';
@jgarciaruiz
jgarciaruiz / boldtext.php
Created March 15, 2019 11:20
php: bold text between pipes
<?php
function boldText($text){
$regxpattern = '#\|(.*?)\|#';
$html = preg_replace($regxpattern, '<strong>$1</strong>', $text);
return $html;
}
$str = 'lorem ipsum |dolor| sit amet';
echo boldText($str);
@jgarciaruiz
jgarciaruiz / boldtext.js
Created March 15, 2019 09:04
js: bold text between pipes
function boldText(text){
var regxpattern = /\|(\S(.*?\S)?)\|/gm;
var html = text.replace(regxpattern, '<strong>$1</strong>');
return html;
}
document.body.innerHTML = boldText('testing |bold| via regex');
@jgarciaruiz
jgarciaruiz / index.html
Created January 29, 2018 09:03
Treeview / Древовидная структура
<div id="collapseDVR3" class="panel-collapse collapse in">
<div class="tree ">
<ul>
<li> <span><i class="fa fa-folder-open"></i> Менюшка</span>
<ul>
<li> <span><i class="fa fa-minus-square"></i> другая Менюшка</span>
<ul>
<li> <span> ещё одна Менюшка </span> </li>
</ul>
@jgarciaruiz
jgarciaruiz / test.js
Created January 25, 2018 11:32
fetch value between hashes
// fetch value between #
var string = "Chapter #1.0# and \r\n";
var regexChapter = new RegExp(/\#(.*?)\#/g);
var regexResult = regexChapter.exec(string)
console.log( regexResult );
if( regexResult != null ){
var chapterNumber = regexResult[1];
console.log("Chapter: "+chapterNumber);
https://github.com/purifycss/purifycss
//used on mobile response project
purifycss app/css/merged.css app/js/*.js app/index.html express-server.js --min --info --out app/css/merged-optim.min.css
@jgarciaruiz
jgarciaruiz / index.html
Created January 13, 2018 20:32
hmtl amp basic template
<!DOCTYPE html>
<html amp lang="en">
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<link rel="canonical" href="http://example.ampproject.org/article-metadata.html">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
@jgarciaruiz
jgarciaruiz / index.html
Created August 6, 2017 10:44
Followbox - jQuery
<div class="follow-scroll">
Let me follow you.
</div>