Skip to content

Instantly share code, notes, and snippets.

// https://projecteuler.net/problem=1
var getSumOfMuliples = function (n1,n2,limit){
var result=0;
for(var i=Math.min(n1,n2);i<limit;i++){
if(i%n1==0||i%n2==0){
result+=i;
}
}
return result;
}
require 'securerandom'
def get_ips ips_file
content=""
File.open(ips_file,"r") {|file| content = file.read }
result=""
content.scan(/(((([0-9]{1,3}\.){3}[0-9])|(([0-9a-f]{1,4}\:){3}\:))\/[0-9]{2})/) { |match| result += "#{match[0]}\n" }
File.open("#{ips_file}-#{SecureRandom.uuid}.txt","w") {|file| file.write(result)}
end
get_ips ARGV[0]
Array.prototype.unShift = function (){
let newArray = [...arguments], i = 0, len = this.length , newArrLength=newArray.length;
for(i; i < len; i++){
newArray[newArrLength+i] = this[i];
}
return newArray;
}
let arr =[1,2];
#!/bin/bash
last_video=$(find ~/Downloads -type f -regex ".*\.\(mp4\|mkv\|rmvb\|vob\|flv\|mov\|avi\)$" -printf "%-.22T+ %M %n %-8u %-8g %8s %Tx %.8TX %p\n" | sort | tail -n1 | grep -o "/home.*$" )
if [ -z "$( pgrep totem )" ]; then
echo "$last_video" | xargs -d "\n" totem &
else
echo "$last_video" | xargs -d "\n" totem
fi
def loop dir , parent = Dir.pwd
Dir.entries(dir).each do |e|
if File.directory?(e) && (e!="." && e!="..")
dir_path=File.absolute_path(e ,parent)
puts dir_path
loop dir_path , e
elsif !File.directory?(e) && (e!="." && e!="..")
puts File.absolute_path(e , parent)
end
end
@AbdallaZaki
AbdallaZaki / fixarbicsubtitle.sh
Created February 3, 2016 08:47
fix arabic subtitles
#!bin/bash
dir_name=$1
current_dir=$(pwd)
if [ ! -d $dir_name ];then
echo "not a directory"
exit 1
fi
function change_encoding ()
{
cd $dir_name
#!/bin/bash
cd ~/Downloads
filetounrar=$(ls ./*.rar -t | head -n1)
function unrarmyfile ()
{
rar e "$filetounrar"
}
function userchoose ()
{
echo "[r]eplace [q]uit"
@AbdallaZaki
AbdallaZaki / gist:ce54ccff95ee1a06236b
Last active August 29, 2015 14:06
Project Euler problem 5
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Algo1
{
internal class Program