Skip to content

Instantly share code, notes, and snippets.

View mariomui's full-sized avatar

Mario Mui mariomui

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div class="renderbox">
<style scoped>
@mariomui
mariomui / example.MD
Last active December 22, 2018 00:16
Example API call
// --------------------------------------------- SERVER CODE --------------------------------------------- //
app.get('/rooms/:id/pictures', function (req, res) {
  console.log('hello');
  findPicturesByRoomId(req.params.id)
    .then(function (images) {
      res.send(images.image_url);
    });
});

#QUERIES (NO PRIMARY KEYS) CASSANDRA (DAY ONE)

READING (SELECT * FROM SIMILARS WHERE ID = 999999);

category_id | clustering_id | bed | cost | description | favorite | picture| premium | rcount | stars | title 1 | 999999 | 6 | 102 | Ut quis mollit est labore reprehenderit. Consequat culpa fugiat aliqua dolore enim exercitation tempor incididunt laborum et laboris amet ad elit. Elit mollit anim culpa sit aute cillum enim magna ut ea consequat id irure. | False | http://d1bah53dmo2q93.cloudfront.net/999.jpg | True | 1396 | 5 | Ullamco irure quis minim enim enim amet fugiat eiusmod anim proident.

(1 rows)

  • Tracing session: 9a986dc0-16c5-11e9-8208-b3a911c7ed43
  • activity | timestamp | source | source_elapsed | client
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
vus: 200,
duration: '600s',
};
const randomRoom = Math.floor(Math.random() * (1000000) + 1000000);
export default function () {
@mariomui
mariomui / M220JS.md
Created July 23, 2019 04:04
M220JS: MongoDB for Javascript Developers

M220JS

Using the Course without Cloud DBs

  • As a user I want to complete this course without using my cloud or using the local version of the db.

Overview

The instructions here will both be imperative and declarative. It wont have any answers to the course. It will just be a collection of thoughts and deep dives into the code.

@mariomui
mariomui / .block
Last active August 29, 2019 20:09
fresh block
license: mit
@mariomui
mariomui / .block
Created August 29, 2019 20:07
fresh block
license: mit
@mariomui
mariomui / MakeCheckboxes.js
Created April 19, 2020 06:50
Paste this code in chrome console or in snippets, then run. There will be an overlay on your webpage where you can add checkboxes. Used in conjunction with HTML/Markdown editors
console.clear();
function DomManipulator() {
this.error = null;
this.active = false;
this.toggleActive = function toggleActive(shouldSetActiveSetInactive) {
// is this a static method?
if (typeof shouldSetActiveSetInactive === 'boolean') {
this.active = shouldSetActiveSetInactive;
} else {
@mariomui
mariomui / checkdiff.sh
Last active June 14, 2020 09:33
compares local branch name to remote origin
# @usage checkiff master
# @param {posix1} branchname
# @desc notifies you whether local master is the same as origin/master
# (only works in zshell, in bash the piping generaes a subshell)
function checkdiff() {
git fetch;
git diff $1 origin/$1 | wc -l | {read wc};
if (test $wc -ne "0")
then
echo $wc
@mariomui
mariomui / gist:344f3af892c6682c0b669302b19f0ff5
Last active November 9, 2022 20:44
Custom Segment to detect poetry shell for p10K prompt
: << 'END_COMMENT'
Place this function in your ~/.p10k.zsh file
1) Detects your poetry env, (whehter or not you've entered the directory of your poetry app)
2) Detects whether or not shell is active. (POETRY_ACTIVE)
3) append my_poetry like so:
typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
...
my_poetry
)