Skip to content

Instantly share code, notes, and snippets.

View UltiRequiem's full-sized avatar

Eliaz Bobadilla UltiRequiem

View GitHub Profile
@sigmaSd
sigmaSd / installFn.ts
Last active September 6, 2022 01:25
Install a javascript function as an executable
import cache_dir from "https://deno.land/x/dir@1.5.1/cache_dir/mod.ts";
import { ensureDirSync } from "https://deno.land/std@0.152.0/fs/ensure_dir.ts";
export interface Options {
prelude?: string;
permissions?: string[];
}
// deno-lint-ignore no-explicit-any
export default function installFn(fn: any, options?: Options) {
@alii
alii / is-instance.ts
Created January 19, 2022 14:00
Useful error checking for promise chaining
type Constructor<T> = new (...args: any[]) => T;
type Then<T, R> = (value: T) => R;
export function ifInstance<T, R>(instance: Constructor<T>, then: Then<T, R>) {
return (value: unknown) => {
if (value instanceof instance) {
return then(value);
}
throw value;
@kelsny
kelsny / README.md
Last active February 13, 2022 16:31
CodeWars RoboScript Kata Solutions

These are my solutions to the RoboScript series of katas on CodeWars.

This Kata Series is based on a fictional story about a computer scientist and engineer who owns a firm that sells a toy robot called MyRobot which can interpret its own (esoteric) programming language called RoboScript. Naturally, this Kata Series deals with the software side of things (I'm afraid Codewars cannot test your ability to build a physical robot!).

@kawarimidoll
kawarimidoll / README.md
Last active November 26, 2021 16:28
get DENO_DIR
@sindresorhus
sindresorhus / esm-package.md
Last active April 25, 2024 08:14
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@SiddharthShyniben
SiddharthShyniben / ninja-code.md
Last active October 25, 2022 09:35
Ninja Code from javascript.info. For my self reference.

Ninja code

Learning without thought is labor lost; thought without learning is perilous.

Confucius

Programmer ninjas of the past used these tricks to sharpen the mind of code maintainers.
Code review gurus look for them in test tasks.
Novice developers sometimes use them even better than programmer ninjas.
Read them carefully and find out who you are – a ninja, a novice, or maybe a code reviewer?

@VadimBrodsky
VadimBrodsky / App.js
Created August 7, 2020 02:40
RecordRTC React Example
import React, { useState, useRef, useEffect } from 'react';
import './App.css';
import RecordRTC, { invokeSaveAsDialog } from 'recordrtc';
function App() {
const [stream, setStream] = useState(null);
const [blob, setBlob] = useState(null);
const refVideo = useRef(null);
const recorderRef = useRef(null);
@yegappan
yegappan / VimScriptForPythonDevelopers.MD
Last active January 12, 2024 10:51
Vim script for Python Developers

Vim Script for Python Developers

This is a guide to Vim Script development for Python developers. Sample code for the various expressions, statements, functions and programming constructs is shown in both Python and Vim Script. This is not intended to be a tutorial for developing Vim scripts. It is assumed that the reader is familiar with Python programming.

For an introduction to Vim Script development, refer to usr_41.txt, eval.txt and Learn Vimscript the Hard Way

For a guide similar to this one for JavaScript developers, refer to Vim Script for the JavaScripter

This guide only describes the programming constructs that are present in both Python and Vim. The constructs that are unique to Vim (e.g. autocommands, [key-mapping](https://vimhelp.org/map.txt.html#key-m

Pip is a package manager of python. You can download Python libraries from some Python repositories like PyPI. You can also download libraries from a git repository. This is gonna be the issue to be explained in this article.

I don't like to memorize things all the time. So, I guess, I couldn't be working without internet :). Whenever I need to install some python libraries from a git repositories, I see a lot of way to do it. It is really confusing. This should be the reason why I can't memorize it. I can see how a very simple requirement is handled with to many confusing way. There shouldn't be to many way. Some of them is not working neither. At last, I decided to blog it.

As you may know, you can use two protocols which are http and ssh to do something on git repositories. Using protocol ssh instead of http may provide some ease of use. Because of nature of ssh, you can do something with your primary/public keys. So, you don't have to input your credentials all the time. But I'll be

@chemzqm
chemzqm / repl.js
Last active May 29, 2021 00:05
repl with coc.nvim
// Save the file to ~/.vim/coc-extensions
// Usage: xmap <silent> <TAB> <Plug>(coc-repl-sendtext)
const {commands, workspace} = require('coc.nvim')
exports.activate = context => {
let {nvim} = workspace
let terminal
context.subscriptions.push(commands.registerCommand('repl.openTerminal', async () => {
let filetype = await nvim.eval('&filetype')
let prog = ''