Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@diogocapela
diogocapela / moment-js-timezones.txt
Created September 7, 2018 00:10
List of All Moment.js Timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
@aweher
aweher / python3_ping.py
Created March 19, 2018 12:38
Ping in python 3 without output or using subprocess
def is_alive(host):
ret = os.system('ping -c 3 -t 3 -n -q {} > /dev/null'.format(host))
if ret == 0:
return True
return False
@mihow
mihow / load_dotenv.sh
Last active April 21, 2024 17:49
Load environment variables from dotenv / .env file in Bash
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
@amirasaran
amirasaran / Arabic character to Persian (Farsi) - PHP
Last active April 6, 2024 23:37
convert Arabic character to Persian (Farsi) - PHP
<?php
public static function arabicToPersian($string)
{
$characters = [
'ك' => 'ک',
'دِ' => 'د',
'بِ' => 'ب',
'زِ' => 'ز',
'ذِ' => 'ذ',
'شِ' => 'ش',
@Enegnei
Enegnei / HTTPShame.md
Last active November 22, 2023 17:05
A shame-list of popular websites which have not yet deployed HTTPS certificates

HTTPS vs HTTP

HTTPShame

A shame-list of popular or important websites which have not yet deployed HTTPS certificates by default.

Sites which may involve the transmission of very sensitive data, such as health or banking information, are marked with an ❗ to signal they should deploy HTTPS-by-default as soon as possible. If you are a popular website (such as those on the Alexa Top 500 Global Sites) which finds itself on this list - and you want to be removed - you can visit Let's Encrypt about transitioning to HTTPS. It's easy, free, and will help you learn how to protect your customers/ readers!

List now outdated, removed until further notice.

Q: What is HTTPS?

@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active April 22, 2024 17:14
Using multiple github accounts with ssh keys

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@tasdikrahman
tasdikrahman / python_tests_dir_structure.md
Last active February 21, 2024 02:16
Typical Directory structure for python tests

A Typical directory structure for running tests using unittest

Ref : stackoverflow

The best solution in my opinion is to use the unittest [command line interface][1] which will add the directory to the sys.path so you don't have to (done in the TestLoader class).

For example for a directory structure like this:

new_project

├── antigravity.py

@jnovack
jnovack / README.md
Last active April 3, 2024 03:24
Opening up mosh in firewalld using firewall-cmd

Mosh (mobile shell) is a gift from the Gods(tm). Anyone with spotty internet or wireless connection has suffered the pain of a lost SSH session. Sure, one can fire up screen (or tmux as the kids are using these days), but that's an extra step and you are still using the SSH protocol.

I'm not here to tout the benefits of Mosh, you came here to open it up in your firewall.

  1. Create the following file as /etc/firewalld/services/mosh.xml
  2. firewall-cmd --add-service=mosh --permanent
  3. firewall-cmd --reload

If you tend to have a lot of sessions (not recommended), you can increase the ports, but the default should be fine for most applications.

@jbgo
jbgo / git-recover-branch.md
Last active March 29, 2024 05:04
How to recover a git branch you accidentally deleted

UPDATE: A better way! (August 2015)

As pointed out by @johntyree in the comments, using git reflog is easier and more reliable. Thanks for the suggestion!

 $ git reflog
1ed7510 HEAD@{1}: checkout: moving from develop to 1ed7510
3970d09 HEAD@{2}: checkout: moving from b-fix-build to develop
1ed7510 HEAD@{3}: commit: got everything working the way I want
70b3696 HEAD@{4}: commit: upgrade rails, do some refactoring