Skip to content

Instantly share code, notes, and snippets.

View MaherSaif's full-sized avatar

Maher Saif MaherSaif

View GitHub Profile
@MaherSaif
MaherSaif / url_validator.rb
Created February 16, 2023 09:59 — forked from virolea/url_validator.rb
Rails Custom URL validator
# Use this validator like this
#
# class User < ApplicationRecord
# validates :profile_link, url: true
# end
class UrlValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless valid_url?(value)
record.errors.add(attribute, :invalid_url)
@MaherSaif
MaherSaif / rsync-retry.sh
Created November 20, 2022 17:03 — forked from iangreenleaf/rsync-retry.sh
rsync with retries
#!/bin/bash
### ABOUT
### Runs rsync, retrying on errors up to a maximum number of tries.
### Simply edit the rsync line in the script to whatever parameters you need.
# Trap interrupts and exit instead of continuing the loop
trap "echo Exited!; exit;" SIGINT SIGTERM
MAX_RETRIES=50
@MaherSaif
MaherSaif / tmux-cheatsheet.markdown
Created November 20, 2022 17:02 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@MaherSaif
MaherSaif / timeline.php
Created November 20, 2022 17:02 — forked from codemasher/timeline.php
Fetch your twitter timeline via the unofficial adaptive search API
<?php
/**
* Twitter timeline backup
*
* Required:
* - PHP 8.1+
* - cURL extension enabled
* - Windows:
* - download https://windows.php.net/downloads/releases/php-8.1.12-Win32-vs16-x64.zip (or a newer available version)
* - unzip to a folder of your choice
@MaherSaif
MaherSaif / DNS_TO_LOCALHOST.markdown
Created December 25, 2021 16:33 — forked from tinogomes/DNS_TO_LOCALHOST.markdown
Public DNS Pointing to localhost (127.0.0.1)

Available Public Wildcard DNS Domains pointing to localhost (127.0.0.1)

It turns out that some kind hearted people already set up wildcard domains for you already. You can use any domain below and/or any subdomain of these and they currently resolve to 127.0.0.1 but could switch at any time to resolve somewhere else. Here's the list of ones I know about. Let me know if there are more!

  • localhost - It will always works. Do you know why? I hope so.
  • [*.]fuf.me - Managed by @fidian; it will always point to localhost for IPv4 and IPv6
  • [*.]fbi.com - 👏 👏 👏 👏 👏
  • [*.]localtest.me
  • [*.]127-0-0-1.org.uk
  • [*.]vcap.me
@MaherSaif
MaherSaif / node-xcodebuild.ts
Created October 31, 2021 09:39 — forked from thomasvidas/node-xcodebuild.ts
Typescript wrapper for xcodebuild
import { execSync, spawn, SpawnOptions } from 'child_process'
type XCodebuildOptions = {
/**
* Build the project specified by projectname.
* Required if there are multiple project files in the same directory.
*/
project: string,
/**
@MaherSaif
MaherSaif / spinner.rb
Created October 29, 2021 12:51 — forked from clupprich/spinner.rb
Terminal Spinner
%w(⠾ ⠷ ⠯ ⠟ ⠻ ⠽).cycle { |dot| print "\b#{dot}"; sleep 0.1 }
# proxying through apache to a local rails instance, http & https
# apache *.conf file
<VirtualHost *:80>
ServerName psl.localhost
ServerAlias cms.psl.localhost
ServerAlias *.psl.localhost
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/