Skip to content

Instantly share code, notes, and snippets.

Avatar

Abraham Jagadeesh abrjagad

View GitHub Profile
@abrjagad
abrjagad / gist:cb829b7df3a4768823bf88208e11499a
Created Oct 18, 2018 — forked from andphe/gist:3232343
Export your links from Safari reading list
View gist:cb829b7df3a4768823bf88208e11499a
/usr/bin/plutil -convert xml1 -o - ~/Library/Safari/Bookmarks.plist | grep -E -o '<string>http[s]{0,1}://.*</string>' | grep -v icloud | sed -E 's/<\/{0,1}string>//g'
@abrjagad
abrjagad / strip_html.js
Last active Oct 6, 2018
Strip HTML tags and gives array with only valid elements
View strip_html.js
var a = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<a href="1.html">Hello World</a>
View Command-line.md

Command Line Shortcuts

Move all files from Subfolder to this folder

find . -mindepth 2 -type f -print -exec mv {} . ;

Delete folders recursively

find . -name "node_modules" -type d -print -exec rm -rf '{}' +

find . -name "imagewithcta" -type d -print

View handy_bash_scripts.sh
concatenatedArray=($(ls $Dir) $(ls $AnotherDir))
Array=()
Array+=("value")
Array+=("AnotherValue")
echo ${Array[@]}
echo ${#Array[@]}
@abrjagad
abrjagad / bash_bubble_sort.sh
Created Aug 31, 2018
Bash: Sort Array by value's length
View bash_bubble_sort.sh
# Performing Bubble sort
for ((i = 0; i<${#array[@]}-1; i++))
do
# echo $i
for((j = 0; j<${#array[@]}-1; j++))
do
if ((${#array[j]} < ${#array[$((j+1))]}))
then
temp=${array[$j]}
array[$j]=${array[$((j+1))]}
View sortbasedonanotherarray.js
var f = ['women','men'];
var context = require.context('./', true, /.scss$/);
var module = context.keys();
module.sort(function(a,b){
return (f.indexOf(a.split('/')[1])>f.indexOf(b.split('/')[1]))
});
console.log(module);
//module.forEach(context)
//// execute them
module.forEach(function(key) {
View bind example.js
(function () {
function log(x) {
console.log('My value: ' + x);
}
var funcs = [];
for (var i = 0; i < 3; i++) {
funcs[i] = log.bind(null, i);
}
View detectie.js
var BrowserDetectMixin = {
// Lifted from:
// http://stackoverflow.com/questions/19999388/jquery-check-if-user-is-using-ie/21712356#21712356
detectIE: function() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE ');
if (msie > 0) {
// IE 10 or older => return version number
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
View doubletapnotworking.js
$.event.special.abetap = {
delegateType: "tap",
bindType: "tap",
handle: function (event) {
var handleObj = event.handleObj;
var targetData = jQuery.data(event.target);
var ret = null;
event.preventDefault();
@abrjagad
abrjagad / &.js
Last active Nov 16, 2015
isolated scopes.
View &.js
//
angular.module("MyApp", [])
.controller("MathCtrl", function($scope) {
$scope.add = function(x, y) {
return x + y;
};
})
.directive("myAddThings", function() {
return {
restrict: "E",