Skip to content

Instantly share code, notes, and snippets.

@yassermzh
yassermzh / function-that-takes-data-from-3-places.ts
Last active October 29, 2020 14:15
a function that takes data from 3 places
// as a note for myself! for me only `public gist` is possible. sorry if you end up here.
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unused-vars */
type JsonMap = Record<string, any>
type State = { a: number };
function getState(): State {
return { a: 1 };
@yassermzh
yassermzh / machine.js
Last active June 2, 2020 19:37
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: 'workflow',
initial: 'idle',
parallel: true,
states: {
jira: {
id: "jira",
initial: "todo",
states: {
todo: {
@yassermzh
yassermzh / download-coursera-videos-shell.md
Last active August 29, 2015 14:19
Download coursera videos from shell

Here is how I manage to download all videos of specific course from http://coursera.org. Even counrsera-downloader Chrome extension sucks. I would rather do it from command-line.

Requirements

  • nodejs
  • shelljs (npm install -g shelljs)

Instructions

  1. The following script to be run in 'all videos' page of http://coursera.org course, would copy all video links with their titles as JSON to clipboard.
@yassermzh
yassermzh / q-promises.md
Last active August 29, 2015 14:10
Q promises

done()

When the error handler in fail throw some errors, it woull be sillently dismissed and there is no way of knowing what's wrong.

var Q = require('q');
function asyncTask() {
    return Q.reject();
}

function errorHandler() {
 // calling log of undefined logger, throws error
@yassermzh
yassermzh / emacs-tips.md
Last active January 13, 2016 08:07
Emacs Tips

To open and edit a file with sudo

/sudo:root@localhost:/etc/hosts

To open and edit a file over ssh (tramp)

C-x C-f /ssh:username@host#2222:/tmp
@yassermzh
yassermzh / restapi.md
Last active August 29, 2015 14:05
Restfull API examples

Introduction

Here, I've gathered best practices and guides with only tweaking their examples to match our specific project.

NOTE: Backend routes are different than front-end routes. The Restful API is about the backend routes, not the routes one sees in the web application.

URL Structure

  • A URL identifies a resource.
@yassermzh
yassermzh / AngularJS Setup
Last active August 29, 2015 14:04
Simple setup to start playing with AngularJS. Used the instructions from https://github.com/startup-class/setup/blob/master/setup.sh
#!/bin/bash
# Install nvm: node-version manager
# https://github.com/creationix/nvm
sudo apt-get install -y git
wget https://raw.github.com/creationix/nvm/master/install.sh
sh install.sh
# TEST: now this should work
nvm