Skip to content

Instantly share code, notes, and snippets.

View kidroca's full-sized avatar

Peter Velkov kidroca

  • Inceptdevelopment
  • Bulgaria
View GitHub Profile
@jonlabelle
jonlabelle / string-utils.js
Last active December 15, 2024 21:36
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str) {
return str.toLowerCase();
@davidtheclark
davidtheclark / isElementInViewport.js
Created May 4, 2013 02:00
JavaScript: Is element in viewport?
/*
No jQuery necessary.
Thanks to Dan's StackOverflow answer for this:
http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport
*/
function isElementInViewport(el) {
var rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
@Turbo87
Turbo87 / app.js
Created February 15, 2015 04:05
webpack + font-awesome test
require('font-awesome/css/font-awesome.css');
document.body.innerHTML = '<i class="fa fa-fw fa-question"></i>';
@sphvn
sphvn / traverse.js
Last active October 26, 2023 21:49
Recursively traverse object javascript, recurse json js, loop and get key/value pair for JSON
var traverse = function(o, fn) {
for (var i in o) {
fn.apply(this,[i,o[i]]);
if (o[i] !== null && typeof(o[i])=="object") {
traverse(o[i], fn);
}
}
}
// usage
@poberwong
poberwong / LoopAnimation.js
Last active February 28, 2023 12:24
a demo for loop animation in react-native
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
@scriptex
scriptex / firebase.js
Last active March 1, 2025 02:50
Expo and Firebase integration in React Native
/**
* External dependencies
*/
import { auth } from 'react-native-twitter';
import * as firebase from 'firebase';
import Expo, { AuthSession } from 'expo';
/**
* Internal dependencies
*/
@jevakallio
jevakallio / readme.md
Last active April 8, 2025 09:33
`adb pull` from app data directory without root access

TL;DR;

com.package.name is your app identifier, and the file path is relative to the app user's home directory, e.g. '/data/user/0/com.package.name.

adb shell run-as com.package.name cp relative/path/file.ext /sdcard
adb pull /sdcard/file.ext

See long explanation below.

@kiding
kiding / NoScrollOnInputFocusiOSSafari.html
Last active March 12, 2025 19:09
Preventing iOS Safari scrolling when focusing on input elements
<!--
When an input element gets focused, iOS Safari tries to put it in the center by scrolling (and zooming.)
Zooming can be easily disabled using a meta tag, but the scrolling hasn't been quite easy.
The main quirk (I think) is that iOS Safari changes viewport when scrolling; i.e., toolbars shrink.
Since the viewport _should_ change, it thinks the input _will_ move, so it _should_ scroll, always.
Even times when it doesn't need to scroll—the input is fixed, all we need is the keyboard—
the window always scrolls _up and down_ resulting in some janky animation.
However, iOS Safari doesn't scroll when the input **has opacity of 0 or is completely clipped.**
export function encodeSvgString(svg: string) {
const decoded = unescape(encodeURIComponent(svg));
const b64String = btoa(decoded);
const imgSource = `data:image/svg+xml;base64,${b64String}`;
return imgSource;
}
export function svgToDataURI(svgData: string, renderWidth: number, renderHeight: number) {
const id = genUUID();