Skip to content

Instantly share code, notes, and snippets.

View shiv19's full-sized avatar
🎯
Focusing

Shiva Prasad shiv19

🎯
Focusing
View GitHub Profile
class MaxHeap{
constructor(){
this.data = [];
this.position = 1;
}
insert(value){
this.data[this.position] = value;
@shiv19
shiv19 / toLower.sh
Created November 30, 2017 08:14
Rename all files in a directory to lowercase
for i in *; do mv "$i" "$(echo $i|tr A-Z a-z)"; done
@shiv19
shiv19 / ChromeClient.js
Last active April 13, 2020 14:00
NativeScript Disable Zoom on Webview, and load hyperlinks on default browser
// Lets you use webcam and other mobile hardware inside NativeScript WebView
exports.webViewLoaded = function (args) {
var webview = args.object;
var TNSWebViewClient =
android.webkit.WebViewClient.extend({
shouldOverrideUrlLoading: function (view, url) {
if (url != null && url.startsWith("http://")) {
console.log(url);
// use openUrl form utils module to open the page in a browser
@shiv19
shiv19 / commands.sh
Created December 16, 2017 15:23
ENFILE file table overflow error mac os
echo kern.maxfiles=65536 | sudo tee -a /etc/sysctl.conf
echo kern.maxfilesperproc=65536 | sudo tee -a /etc/sysctl.conf
sudo sysctl -w kern.maxfiles=65536
sudo sysctl -w kern.maxfilesperproc=65536
ulimit -n 65536
@shiv19
shiv19 / gist:f6332ba1f9ceb9db8642cb682d59cefc
Created December 26, 2017 19:01 — forked from burkeholland/gist:7475bb40a305d9f35494
Customizing The Navigation Bar / Status Bar

As I've been learning more and more about NativeScript, one of the first tasks I really dove into was learning how to customize the Navigation Bar for an iOS app. NativeScript has a Navbar component on the roadmap, but for now, it requires some knowledge about the underlying iOS implementation of UINavigationControllers, UIViewControllers and the like.  But fear not!  I have braved the treacherous waters of StackOverflow and the Objective-C docs and emerged, victorious and unscathed.

1

In this article, I’ll go over a few of the more common tweaks that you might be needing to make to the Navigation Bar or Status Bar. While NativeScript is a cross-platform framework, these tweaks apply specifically to iOS. However, most of the items that I will

@shiv19
shiv19 / gist:50ea515932d8cdee9e1eb04809e4fa8a
Last active July 24, 2018 23:00
Event emitter one liner
M=(o={})=>({on:(e,f)=>(o[e]=o[e]||[]).push(f),trigger:(e,d)=>(o[e]||[]).map(x=>x(d))});
m = M();
m.on("foo", (c) => console.log(c)); //register
m.trigger("foo",4) //invoke
@shiv19
shiv19 / numberToChunks.js
Created January 7, 2018 11:22
Split numbers into chunks
var s="4581458245834584";
var t=s.split(/(?!^)(?=(?:....)+$)/); // dots as groups of split
console.log(t);
@shiv19
shiv19 / collapse.directive.ts
Created January 18, 2018 13:37
Collapse directive for NativeScript Angular
import { Directive, ElementRef, Input, AfterViewInit } from '@angular/core';
import { View } from 'tns-core-modules/ui/core/view';
import { PanGestureEventData } from 'tns-core-modules/ui/gestures';
import { fromEvent } from 'rxjs/observable/fromEvent';
import { Subscription } from 'rxjs/Subscription';
import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/distinctUntilChanged';
import { fromPromise } from 'rxjs/observable/fromPromise';
@shiv19
shiv19 / remCycDep.js
Created March 19, 2018 16:42
remove cyclic dependency and log the object
console.log = (function(log, inspect) {
return function() {
return log.apply(
this,
Array.prototype.map.call(arguments, function(arg) {
return inspect(arg, {
depth: 2
showHidden: true
}).replace(/\\n/g, '\n')
})

Keybase proof

I hereby claim:

  • I am shiv19 on github.
  • I am multishiv19 (https://keybase.io/multishiv19) on keybase.
  • I have a public key ASDDw6EutXpaGLrQsPo00gE2M4UtT6BIcGAKnXBso_vB1Qo

To claim this, I am signing this object: