Skip to content

Instantly share code, notes, and snippets.

View l0gicpath's full-sized avatar

Hady Mahmoud l0gicpath

View GitHub Profile
@l0gicpath
l0gicpath / 01-generate-ed25519-ssh-key.sh
Created May 16, 2021 19:19 — forked from grenade/01-generate-ed25519-ssh-key.sh
generate ed25519 ssh and gpg/pgp keys and set file permissions for ssh keys and config
#!/bin/bash
# generate new personal ed25519 ssh key
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "rob thijssen <rthijssen@gmail.com>"
# generate new host cert authority (host_ca) ed25519 ssh key
# used for signing host keys and creating host certs
ssh-keygen -t ed25519 -f manta_host_ca -C manta.network
eval "$(ssh-agent -s)"
use HTML::FromANSI ();
open (LOG, '>>hnchatlog.html');
select((select(LOG), $|=1)[0]);
print LOG "<body bgcolor=black>\n";
while (<>) {
my $h = HTML::FromANSI->new();
print LOG $h->ansi_to_html($_), "\n";
}

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

defmodule SecureRandom do
@moduledoc """
Ruby-like SecureRandom module.
## Examples
iex> SecureRandom.base64
"xhTcitKZI8YiLGzUNLD+HQ=="
iex> SecureRandom.urlsafe_base64(4)

#HW 1-2: Rock-Paper-Scissors

In a game of rock-paper-scissors (RPS), each player chooses to play Rock (R), Paper (P), or Scissors (S). The rules are: R beats S; S beats P; and P beats R. We will encode a rock-paper-scissors game as a list, where the elements are themselves 2-element lists that encode a player's name and a player's selected move, as shown below:

[ ["Armando", "P"], ["Dave", "S"] ] # Dave would win since S > P 

Part A: Write a method rps_game_winner that takes a two-element list and behaves as follows:

If the number of players is not equal to 2, raise WrongNumberOfPlayersError.

@l0gicpath
l0gicpath / age.rb
Last active August 29, 2015 13:56 — forked from emad-elsaid/age.rb
An age ticker, forked to clean up, more ruby-like and properly styled
#! /usr/bin/env ruby
date_of_birth = Time.new(1988, 8, 31)
# Credit: http://stackoverflow.com/a/4136485
def humanize seconds
[[60, :seconds],
[60, :minutes],
[24, :hours],
[365, :days],
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
# For all responses in this controller, return the CORS access control headers.
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Ates Goral <http://magnetiq.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE