Skip to content

Instantly share code, notes, and snippets.


Аневризма aneurysmjs

View GitHub Profile
View vue-3-render-optimization.js
<div id="foo" @click="handleClick">Yo!</div>
import {
createElementVNode as _createElementVNode,
openBlock as _openBlock,
createElementBlock as _createElementBlock,
aneurysmjs / jscodeshift-scope-methods.js
Last active December 18, 2022 22:07
Jscodeshift's scope methods
View jscodeshift-scope-methods.js
// getScope() is a method provided by jscodeshift that can be used to get the Scope object for a given Node.
// A Scope object represents the lexical scope of a node in the abstract syntax tree (AST).
// It contains information about the variables, functions, and other declarations that are in scope at a given point in the code.
// Here's an example of how getScope() can be used:
import { getScope } from 'jscodeshift';
const source = `
function foo() {
aneurysmjs /
Last active November 10, 2022 00:12
Generics in Rust
struct Point<T, U> {
x: T,
y: U,
impl<T, U> Point<T, U> {
// Methods that use different generic types than their struct’s definition
fn mixup<V, W>(self, other: Point<V, W>) -> Point<T, W> {
Point {
x: self.x,
aneurysmjs /
Created November 9, 2022 15:49
Rust cheatsheet
// represents the `possible` absence of a value
enum Option<T> {
let email: Option<String> = Some(email_str);
let email: Option<String> = None;
// representsan operation that could have failed
aneurysmjs / noUncheckedIndexAccess.ts
Created August 7, 2022 16:30
'noUncheckedIndexAccess' Typescript compiler option
View noUncheckedIndexAccess.ts
function upper(arr: string[]) {
for (let i = 0; i < arr.length; i += 1) {
let str = arr[i];
upper(['foo', 'bar', 'baz']);
// In Typescript when index into an array you get the element type of the array.
aneurysmjs /
Created January 11, 2020 09:55 — forked from katychuang/
remove mongodb that was installed via brew
#!/usr/bin/env sh
# checks to see if running
launchctl list | grep mongo
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
launchctl remove homebrew.mxcl.mongodb
pkill -f mongod
View replaceAtRange.ts
function replaceRange(str: string, start: number, end: number, substitute: string): string {
const chunk = substitute.repeat(end - start);
return `${str.substring(0, start)${chunk}${str.substring(end)}`;
aneurysmjs / regexes.ts
Last active November 8, 2019 14:39
regexes tricks
View regexes.ts
* match first character after white space
const firstAtWhiteSpace = /(^|\s)[a-z]/g;
aneurysmjs / store.js
Last active November 5, 2019 13:39
redux stuff
View store.js
// in this case the state is each individual product
const product = (state, action) => {
switch (action.type) {
return {
price: action.price,
aneurysmjs / index.html
Last active October 29, 2019 08:58
CSS stuff
View index.html
even though the "blue" comes later in the list of classes,
but CSS rules of precedence actually depends of the order of
classes in the stylesheet
<span class="red blue">
so I'm red