Skip to content

Instantly share code, notes, and snippets.

View ArunHub's full-sized avatar

Arun M ArunHub

View GitHub Profile
@ArunHub
ArunHub / gcd.js
Created August 23, 2018 06:41
find gcd (greatest common divisor) of number
Math.gcd = function () {
var d = Math.min.apply(Math, arguments);
for (let n = arguments.length, i = 0; d > 1 && n > i; arguments[i] % d === 0 ? i++ : (d--, i = 0));
return d;
}
console.log(Math.gcd(20, 30, 15, 70, 40));
@ArunHub
ArunHub / modal.js
Created August 23, 2018 06:23
create modal using javascript
// Create an immediately invoked functional expression to wrap our code
(function() {
// Define our constructor
this.Modal = function() {
// Create global element references
this.closeButton = null;
this.modal = null;
this.overlay = null;
@ArunHub
ArunHub / factorial.js
Created August 23, 2018 06:22
fatorial for given number
var factorial = function(n) {
if(n == 0) {
return 1
} else {
return n * factorial(n - 1);
}
}
@ArunHub
ArunHub / _agents.scss
Created August 11, 2018 15:17
Last time i worked on bootstrap with scss
/*Agents list page */
.agents-listing {
&.grid-property {
p{
margin-top: 5px;
text-align: right;
}
@ArunHub
ArunHub / sass-architecture.txt
Created August 11, 2018 15:05
sass architecture to start for a project
sass/
|
|– abstracts/
| |– _variables.scss # Sass Variables
| |– _functions.scss # Sass Functions
| |– _mixins.scss # Sass Mixins
| |– _placeholders.scss # Sass Placeholders
|
|– base/
| |– _reset.scss # Reset/normalize
@ArunHub
ArunHub / binaryNum.js
Created July 7, 2018 09:41
converts as binary numbers and get 1's count also
function binary(n){
var stac = [];
while(n > 0){
remainder = n%2;
stac.push(remainder);
n = Math.floor(n/2);
}
console.log(stac.reverse())
var count = 0;
stac.forEach((t,i)=>{
@ArunHub
ArunHub / breakStr.js
Created July 7, 2018 09:38
break string into array of strings whose length is given as input
function breakStr(string, count) {
//return [...string.slice(count - 1)].map((_, i) => string.slice(i, i + count));
return [Array.from(string).slice(count - 1)].map((_, i) => string.slice(i, i + count));
}
@ArunHub
ArunHub / routeconfig.js
Created February 12, 2018 16:25
multilevel UI-view routes
.config(function ($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise("/home");
$stateProvider
//------------------------------
// HOME
//------------------------------
@ArunHub
ArunHub / family.scss
Created December 1, 2016 06:08
some unique sass mixins
/// Select all children from the first to `$num`.
/// @group with-arguments
/// @content [Write the style you want to apply to the children, and it will be added within the @content directive]
/// @param {number} $num - id of the child
@mixin first($num) {
&:nth-child(-n + #{$num}) {
@content;
}
}
@ArunHub
ArunHub / navbarTabletMenuCollapse.css
Last active March 29, 2019 07:35
bootstrap navbar header collapse for Tablet >768 < 991 and bootstrap 3 tricks
.navbar-header {
float: none;
}
.navbar-toggle {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}