Skip to content

Instantly share code, notes, and snippets.

View abrjagad's full-sized avatar

Abraham Jagadeesh abrjagad

View GitHub Profile
@abrjagad
abrjagad / holo snippet.rb
Last active August 29, 2015 14:16
Sublime snippets
<snippet>
<content><![CDATA[
/*doc
---
title: ${1:Title}
name: ${2:name}
category: ${3:Category}
---
${4:Description.}
@abrjagad
abrjagad / &.js
Last active November 16, 2015 15:38
isolated scopes.
//
angular.module("MyApp", [])
.controller("MathCtrl", function($scope) {
$scope.add = function(x, y) {
return x + y;
};
})
.directive("myAddThings", function() {
return {
restrict: "E",
$.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();
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);
(function () {
function log(x) {
console.log('My value: ' + x);
}
var funcs = [];
for (var i = 0; i < 3; i++) {
funcs[i] = log.bind(null, i);
}
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) {
@abrjagad
abrjagad / bash_bubble_sort.sh
Created August 31, 2018 13:31
Bash: Sort Array by value's length
# 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))]}
concatenatedArray=($(ls $Dir) $(ls $AnotherDir))
Array=()
Array+=("value")
Array+=("AnotherValue")
echo ${Array[@]}
echo ${#Array[@]}

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

@abrjagad
abrjagad / strip_html.js
Last active October 6, 2018 04:50
Strip HTML tags and gives array with only valid elements
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>