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 <[email protected]>"
# 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";
}
@l0gicpath
l0gicpath / importer.v2.rb
Created May 10, 2016 20:26
Importing from CSV into an array of hashed values mapped to csv fields
require 'CSV'
class ImportCSV
class << self
def parse csv_file
CSV::Converters[:blank_nil] = lambda do |field|
field && field.empty? ? nil : field
end
csv_data = CSV.read(csv_file, :headers => true,
:header_converters => :symbol,
:converters => [:all, :blank_nil])

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 / .gitconfig
Created June 19, 2014 10:47
My git lg configuration
[alias]
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
@l0gicpath
l0gicpath / kill_braincells.exs
Last active August 29, 2015 13:59
Consuming arabic tech content workflow
# Fun exercise with Elixir.
# The joke's on arabic tech news and yes it's that bad I had to write this.
# That's an elixir script hence .exs so run it with
# > elixir kill_braincells.exs
defmodule Content do
@moduledoc """
Content is responsible for consuming different types of content
"""
@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],