Skip to content

Instantly share code, notes, and snippets.

View calendee's full-sized avatar

Calendee LLC calendee

View GitHub Profile
@mrousavy
mrousavy / MEMOIZE.md
Last active August 30, 2024 23:56
Memoize!!! 💾 - a react (native) performance guide
In computing, memoization or memoisation
is an optimization technique used primarily
to speed up computer programs by storing
the results of expensive function calls and  
returning the cached result when the same
inputs occur again.                                         
                                                     — wikipedia
@tektuitive
tektuitive / validation.js
Created June 26, 2020 23:07
React Native and AWS Amplify Tutorial Docs.
export function validateEmail(email) {
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) {
return 'Enter a valid email address!';
} else return null;
}
export function validatePassword(password) {
if (
!/(?=(.*[0-9]))((?=.*[A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z]))^.{8,}$/i.test(
password,
function Mutilator(data, name, context) {
this.n = name || `mutilation-${+new Date()}`;
this.d = data;
this.c = context || window;
this.isArr = function(p) {
return this.d[p].constructor == Array;
};
this.dispatch = function(p, v, t) {
this.c.dispatchEvent(
new CustomEvent(this.n, {
@calendee
calendee / .bash_profile
Last active May 14, 2021 23:29
NVM Automatic Switching
# NVM version shortcut
# change title name of tab in terminal
function title {
    echo -ne "\033]0;"$*"\007"
}
cd() {
  builtin cd "$@" || return
  #echo $PREV_PWD
  if [ "$PWD" != "$PREV_PWD" ]; then
@calendee
calendee / change-network.js
Created November 3, 2017 15:09
Forcing App to Change Network Status
var app = document.getElementsByTagName('body');
var scope = angular.element(app[0]).scope();
var rootScope = scope.$root
// Make app think you're offline
scope.$apply( function() {
rootScope.$broadcast('$cordovaNetwork:offline');
});
// Make app think you're online
@xxxxlr
xxxxlr / React-Native-WebView-Cookies.js
Created July 27, 2017 01:10 — forked from kanzitelli/React-Native-WebView-Cookies.js
React Native Trick: Get Cookies of WebView without using any native modules such as react-native-cookies. Might be helpful for getting JWT while making OAuth2 👽
// @flow
import React, { Component } from 'react';
import {
WebView,
} from 'react-native';
class LoginScreen extends Component {
state = {
cookies : {},
@calendee
calendee / watchCount.js
Created December 14, 2015 19:21
Count AngularJS Watches
(function countAngularWatchers(angular) {
var i, data, scope,
count = 0,
all = document.all,
len = all.length,
test = {};
var mostWatchers = 0;
function countScopeWatchers(scope, element) {
@calendee
calendee / scope-getting.js
Last active February 15, 2017 17:16
Fire Angular RootScope Event from Console, Get Get An AngularJS service
// Right click an element and select "Inspect Element"
// Courtesy : http://michalostruszka.pl/blog/2013/09/24/angularjs-in-browsers-console/ &
// http://ionicframework.com/blog/angularjs-console/
var scope = angular.element($0).scope();
var rootScope = scope.$root
scope.$apply( function() {
rootScope.$broadcast('showOffline', {msg : 'goes here', duration : 1230});
})
@aleks-mariusz
aleks-mariusz / safari-open-pages.py
Created August 24, 2014 16:35
This script fetches the current open tabs in all Safari windows. Useful to run remotely on your mac when you are at work and want to read a page you have open (remotely) at home but don't remember the url but can log in to your home system on the command line
#!/usr/bin/python
#
# This script fetches the current open tabs in all Safari windows.
# Useful to run remotely on your mac when you are at work and want
# to read a page you have open (remotely) at home but don't remember
# the url but can log in to your home system on the cmmand line
#
import sys
@JoeKeikun
JoeKeikun / input_cursor_color
Last active June 7, 2022 12:08
How to change <input> input cursor color by css (webkit)
When I developed an app for ios by phonegap, I had a trouble in changing the <input> input cursor color.
but now, there is a solution for it:
---------------
<style>
input {
color: rgb(60, 0, 248); /* change [input cursor color] by this*/
text-shadow: 0px 0px 0px #D60B0B; /* change [input font] by this*/
-webkit-text-fill-color: transparent;