Skip to content

Instantly share code, notes, and snippets.

View mutafaf's full-sized avatar
🏠
Works Remotely

Mutafaf Wahhaj mutafaf

🏠
Works Remotely
View GitHub Profile
@mutafaf
mutafaf / max_consecutive_integers_from_an_array.rb
Last active April 27, 2023 13:28
Solution ( Ruby ): Choose as many integers from A as possible so that, when they are put in ascending order, all of the differences between all pairs of consecutive integers are equal. For example, for A = [4, 3, 5, 1, 4, 4], you could choose 1, 3 and 5 (with differences equal to 2) or 4, 4 and 4 (with differences equal to 0). w What is the maxi…
# Solution(ruby): Choose as many integers from A as possible so that, when they are put in ascending order,
# all of the differences between all pairs of consecutive integers are equal. For example,
# for A = [4, 3, 5, 1, 4, 4], you could choose 1, 3 and 5 (with differences equal to 2) or
# 4, 4 and 4 (with differences equal to 0). w What is the maximum number of integers that can be chosen?
def two_consecutive_integers_differences(ar)
diff = []
ar.each do |x|
diff << x.sort.each_cons(2).collect{|a,b| b-a}.tally.values.max+1
end
@mutafaf
mutafaf / Move files to parent directory
Created January 7, 2020 09:50
Move all files from subfolder to parent folder
find . -type f -print -exec mv {} . \;
@mutafaf
mutafaf / mp4toMp3
Last active December 27, 2019 18:46
Convert all paticular extension video files to mp3
for f in *.mp4;
do ffmpeg -i "$f" "${f%mp4}.mp3";
done
@font-face {
font-family: 'FuturaBold';
src: url(https://www.if-so.com/wp-content/themes/if-so/fonts/AG_Futura_Bold.woff);
}
.cw{color: #fff;}
.dfx {display: flex;justify-content:center;align-items:center;}
.wrapper{background:#fff;}
.hdr-content{padding-top:80px;}
.hdr-container,.hdr-left-cloud,.hdr-object{-webkit-transform:skew(0,-4.8deg) translateZ(0);transform:skew(0,-4.8deg) translateZ(0);-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-font-smoothing:subpixel-antialiased;}
@mutafaf
mutafaf / optimized_bootstrap.css
Created October 6, 2019 07:34
An optimized and reduced version of bootstrap
.container{width:100%;padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}@media (min-width:576px){.container{max-width:540px}}@media (min-width:768px){.container{max-width:720px}}@media (min-width:992px){.container{max-width:960px}}@media (min-width:1200px){.container{max-width:1140px}}.container-fluid{width:100%;padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}.row{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;margin-right:-15px;margin-left:-15px}.no-gutters{margin-right:0;margin-left:0}.no-gutters>.col,.no-gutters>[class*=col-]{padding-right:0;padding-left:0}[class*=lg-],[class*=md-],[class*=sm-],[class*=xl-]{position:relative;width:100%;padding-right:1%;padding-left:1%}@media (min-width:576px){.sm-1{max-width:8.33%}.sm-2{max-width:16.66%}.sm-3{max-width:25%}.sm-4{max-width:33.33%}.sm-5{max-width:41.66%}.sm-6{max-width:50%}.sm-7{max-width:58.33%}.sm-8{max-width:66.66%}.sm-9{max-width:75%}.sm-10{max-width:83.33%}.sm-11{max-width:91.66%}.sm-12{m
@mutafaf
mutafaf / functions.php
Created August 20, 2019 12:59
Get a Wordpress page/post details at anypage. Include it in header.php to see magic. :D
function check_page_details() {
echo "is_search() : ".is_search();
echo "<br>is_404() : ".is_404();
echo "<br>is_archive() : ".is_archive();
echo "<br>is_category() : ".is_category();
echo "<br>is_tag() : ".is_tag();
echo "<br>is_tax() : ".is_tax();
echo "<br> is_single()".is_single();
echo "<br>get_page_template_slug() : ".get_page_template_slug();
@mutafaf
mutafaf / NoScrollbar.css
Last active July 9, 2019 16:38
Hide Scrollbar for specific div or a div inside container
.noscrollbar::-webkit-scrollbar {
width: 0px;
background: transparent;
}
.noscrollbar::-webkit-scrollbar-thumb {
background: transparent;
}
.noscrollbar {
-ms-overflow-style: none;
scrollbar-width: none;
@mutafaf
mutafaf / fixCourseNames.js
Last active December 26, 2018 19:22
Fix help course names
els=document.getElementsByClassName("type_course depth_3");for(i in els)code=els[i].childNodes[0].childNodes[0].innerHTML.split("_")[0],els[i].childNodes[0].childNodes[0].innerHTML=els[i].childNodes[0].childNodes[0].getAttribute("title")+" "+code;
@mutafaf
mutafaf / Audio Video Download and Merge From youtube
Last active November 12, 2018 09:17
Audio Video Download and Merge From youtube using youtube-dl
video_url="$1"
exe() { echo "\$ @" ; "$@" ; }
title=`youtube-dl --get-filename -o "%(title)s.%(ext)s" $video_url`
exe youtube-dl -f 136 $video_url -o tvideo.mp4
exe youtube-dl -f 140 $video_url -o taudio.m4a
exe ffmpeg -i tvideo.mp4 -i taudio.m4a -c copy "$title"
exe rm tvideo.mp4
exe rm taudio.m4a
@mutafaf
mutafaf / custom_category_wp
Last active October 13, 2019 22:00
Customizing Wordpress
<?php
$custom_types = array(
array(
'name' => 'test_winner',
'icon' => 'dashicons-awards',
),
array(
'name' => 'product',
'icon' => 'dashicons-smartphone',