Skip to content

Instantly share code, notes, and snippets.

View ancyrweb's full-sized avatar
🏠
Working from home

Anthony Cyrille ancyrweb

🏠
Working from home
View GitHub Profile
const users = [
{
name: "Jane",
balance: 100,
},
{
name: "John",
balance: 75,
},
{
const users = [
{
name: "Jane",
balance: 100,
},
{
name: "John",
balance: 75,
},
{
const users = [
{
name: "Jane",
balance: 100.00
},
{
name: "John",
balance: 55.25
}
];
const elements = [1, 2, 3, 4, 5];
const indexToRemove = 2; // starts from 0, so it targets the third element
const nextElements = [
...elements.slice(0, indexToRemove),
...elements.slice(indexToRemove + 1)
]; // [1, 2, 4, 5]
const elements = [1, 2, 3, 4, 5];
// remove last element
const lastElementRemoved = elements.slice(0, 4); // [1, 2, 3, 4]
// remove first element
const firstElementRemoved = elements.slice(1); // [2, 3, 4, 5]
// remove first and last element (chaining)
const firstAndLastElementRemoved = elements.slice(0, 4).slice(1) // [2, 3, 4]
const elements = [1, 2, 3, 4];
const appendedElements = [...elements, 5]; // [1, 2, 3, 4, 5]
const prependedElements = [0, ...appendedElements]; // [0, 1, 2, 3, 4, 5]
@ancyrweb
ancyrweb / DeleteModal.js
Created April 2, 2020 08:16
The DeleteModal Context
import React from 'react';
import {
StyleSheet,
View,
Text,
} from 'react-native';
import Modal from "react-native-modal";
const styles = StyleSheet.create({
modal: {
@ancyrweb
ancyrweb / Scene.js
Last active April 2, 2020 08:09
Scene.js using modals, the tutorial way
import React from 'react';
import {
StyleSheet,
TouchableOpacity,
View,
Text,
} from 'react-native';
import { useDeleteModal } from "./DeleteModal";
const styles = StyleSheet.create({
@ancyrweb
ancyrweb / 32.asm
Created June 8, 2019 15:15 — forked from FiloSottile/32.asm
NASM Hello World for x86 and x86_64 Intel Mac OS X (get yourself an updated nasm with brew)
; /usr/local/bin/nasm -f macho 32.asm && ld -macosx_version_min 10.7.0 -o 32 32.o && ./32
global start
section .text
start:
push dword msg.len
push dword msg
push dword 1
mov eax, 4
/**
* Middleware that allow to dispatch an array of actions, resulting in a single render
* @param next
* @returns {Function}
*/
export default function reduxBatchMiddleware(next: any) {
let nextListeners: any = [];
let currentListeners: any;
function ensureCanMutateNextListeners() {