Skip to content

Instantly share code, notes, and snippets.

@shadiakiki1986
shadiakiki1986 / README.md
Last active June 21, 2018 05:11
steps for installing jupyterhub

These are my notes while installing jupyterhub on an AWS EC2 instance running Ubuntu 16.04

Prerequisites

  • install python3, pip3
    • sudo apt-get update && sudo apt-get install python3 python3-pip
  • - ~~~`pip3 install pew`~~~
    
@shadiakiki1986
shadiakiki1986 / .block
Created September 28, 2018 08:02 — forked from mbostock/.block
Force-Directed Graph
license: gpl-3.0
height: 600
@shadiakiki1986
shadiakiki1986 / so-51469446-bounty.ipynb
Created March 19, 2019 04:07
SO 51469446 bounty.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shadiakiki1986
shadiakiki1986 / README.md
Last active April 17, 2019 10:02
chemlambda pred(3): graphviz dot file equivalent to mol file

Generating a graphviz dot file equivalent to the mol file of pred(3) in chemlambda v2: pred_3.mol (original name was erroneous)

The lambda calculus expression for pred(3) (predecessor(3) == 2) is PRED := λn.λf.λx.n (λg.λh.h (g f)) (λu.x) (λu.u) (ref wikipedia)

Writing the above expression as nodes in a graph leads to the below graph. The corresponding dot file was written manually and available further below in this gist. An annotated version of pred_3.mol to help compare it to pred_3.dot is available further below in this gist.

To generate the dot file automatically from lambda terms, check http://www.teamshadi.net/chemlambda-js/ (a fork from this jsfiddle ). Its current output for pred(3) matches with the manually specified graph below.

Version 4 (2019-04-11): shifted indeces back by 1 (e.g. L1 to L0) t

@shadiakiki1986
shadiakiki1986 / README.md
Last active April 26, 2019 19:28
Ackermann function illustrated

The below is an ackermann function implementation in awk based on the one on rosettacode.org and modified for higher verbosity to illustrate the details of calculations behind the ackermann function's recursion.

For example, the following shows Ackermann(2,2)

> awk -v m=2 -v n=2 -f ackermann_illustrated.awk
@shadiakiki1986
shadiakiki1986 / steps.md
Last active May 6, 2019 12:13
Restoring an elasticsearch snapshot

General

These are steps to restore an elasticsearch snapshot from one machine to another

Steps

Copy zip of snapshot from s3

sudo mkdir /data
@shadiakiki1986
shadiakiki1986 / widgets.py
Created July 4, 2017 14:28
Django simplest read-only widget
# Based on the below answer on the SO question:
# In a Django form, how do I make a field readonly (or disabled) so that it cannot be edited?
# https://stackoverflow.com/a/15134622/4126114
#
# Usage of either widget classes below:
# class MyForm(forms.ModelForm):
# class Meta:
# widgets = {
# 'field': ReadOnlyWidgetSimple(),
# 'foreign_key': ReadOnlyWidgetMyModel()
@shadiakiki1986
shadiakiki1986 / spinner.sh
Created January 3, 2020 09:10
Display spinner in bash
#!/bin/bash
# from https://raw.githubusercontent.com/golemfactory/golem/develop/Installer/Installer_Linux/install.sh
# Usage: bash spinner.sh
spin='⡄⡆⡇⠇⠃⠋⠉⠙⠘⠚⠒⠖⠆⠦⠤⢤⢠⣠⣀⣄'
printf "hey there .. working "
while true
do
@shadiakiki1986
shadiakiki1986 / README.md
Last active January 13, 2020 07:51
Trying out string longest common prefix https://beta.rustgym.com/longest-common-prefix/

Instructions

  • cargo new test-rustgym-longestcommonprefix
  • cd test-rustgym-longestcommonprefix
  • copy src/main.rs from below file
  • cargo test
@shadiakiki1986
shadiakiki1986 / summarize.rs
Last active February 14, 2020 07:29
orbtk example with trait
// Based on https://github.com/redox-os/orbtk/blob/a9653954fed7275328bc8e893c3465506154571e/examples/clear.rs
// Modified to add a trait member called "summary" which is either implemented as a Book or a NewsArticle
// The summarize button would call the trait function "summarize" (be it from Book or NewsArticle).
// I couldn't get this to work yet, with the troubling sections marked with FIXME
use orbtk::prelude::*;
//---------------------------------------
// https://doc.rust-lang.org/1.30.0/book/second-edition/ch10-02-traits.html
pub trait Summary {