Skip to content

Instantly share code, notes, and snippets.

@roc-ld
roc-ld / iptables-multicast.sh
Created October 15, 2024 13:12 — forked from juliojsb/iptables-multicast.sh
Allow multicast communications in iptables
Run the following:
iptables -A INPUT -m pkttype --pkt-type multicast -j ACCEPT
iptables -A FORWARD -m pkttype --pkt-type multicast -j ACCEPT
iptables -A OUTPUT -m pkttype --pkt-type multicast -j ACCEPT
Or:
iptables -A INPUT -s 224.0.0.0/4 -j ACCEPT
iptables -A FORWARD -s 224.0.0.0/4 -d 224.0.0.0/4 -j ACCEPT
@roc-ld
roc-ld / base64ArrayBuffer.js
Created August 29, 2024 00:39 — forked from jonleighton/base64ArrayBuffer.js
Encode an ArrayBuffer as a base64 string
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then
// use window.btoa' step. According to my tests, this appears to be a faster approach:
// http://jsperf.com/encoding-xhr-image-data/5
/*
MIT LICENSE
Copyright 2011 Jon Leighton
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@roc-ld
roc-ld / App.tsx
Created June 6, 2024 13:50 — forked from Glazzes/App.tsx
React Native pinch to zoom advanced
/**
* After some thoughts on this topic, I've decided to turn this gist along with other features into a library so you can zoom
* whatever you want, library you can find here https://github.com/Glazzes/react-native-zoom-toolkit.
*
* @author Santiago Zapata, Glazzes at Github <3
* @description This gist makes part of an article I'm writing about this topic (in spanish). This solution takes into account
* the linear algebra concepts and geometrical interpretation of the transform-origin property specification, this solution
* takes heavy inspiration from William's Candillon +3 year old video in this topic, however this solution brings it to the
* modern day along with a huge fix that prevents the origin from being displaced by an incorrect offset calculation after
* the first zoom interaction.
@roc-ld
roc-ld / highlight.ts
Created April 20, 2024 16:37 — forked from evenfrost/highlight.ts
Fuse.js with highlight
const highlight = (fuseSearchResult: any, highlightClassName: string = 'highlight') => {
const set = (obj: object, path: string, value: any) => {
const pathValue = path.split('.');
let i;
for (i = 0; i < pathValue.length - 1; i++) {
obj = obj[pathValue[i]];
}
obj[pathValue[i]] = value;
@roc-ld
roc-ld / App.js
Created March 31, 2024 12:59 — forked from dabit3/App.js
Expo + Amplify DataStore App
import Amplify from '@aws-amplify/core'
import config from './aws-exports'
Amplify.configure(config)
import React, { useState, useEffect } from 'react'
import { Text, View, TextInput, Button } from 'react-native'
import { DataStore } from '@aws-amplify/datastore'
import { Message} from './src/models'
const initialState = { color: 'black', title: '' }
Short-circuit? Short-circuits on? Fulfilled on? Rejected on?
Promise.all Yes First rejected promise All promise fulfilled First rejected promise
Promise.allSettled No N/A Always N/A
Promise.race Yes First settled First promise fulfilled First rejected promise
Promise.any Yes First fulfilled First promise fulfilled All rejected promises
@roc-ld
roc-ld / datastore.md
Created December 10, 2023 03:52 — forked from dabit3/datastore.md
Building offline apps with Amplify DataStore

Building offline apps with Amplify DataStore

To view and deploy the app covered in this chapter, check out this repo.

So far in this book we've worked with both REST APIs and GraphQL APIs. When working with the GraphQL APIs so far, we've used the API class to directly call mutations and queries against the API.

Amplify also supports another type of API for interacting with AppSync, Amplify DataStore. DataStore has a different approach than a traditional GraphQL API.

Instead of interacting with the GraphQL API itself using queries and mutations, DataStore introduces a client-side SDK that persists the data locally using the local storage engine of the platform you are working with (i.e. IndexDB for web, SQLLite for native iOS and Android). DataStore then automatically syncs the local data to the GraphQL backend for you as updates are made both locally and remotely.

@roc-ld
roc-ld / App.js
Created December 10, 2023 02:51 — forked from dabit3/App.js
Using AWS AppSync GraphQL with Expo
import React from 'react';
import { StyleSheet, Text, View, TextInput, Button } from 'react-native';
import Amplify from '@aws-amplify/core'
import config from './aws-exports'
Amplify.configure(config)
import API, { graphqlOperation } from '@aws-amplify/api'
const listPets = `
@roc-ld
roc-ld / waitForKeyElements.js
Created June 22, 2022 01:23 — forked from BrockA/waitForKeyElements.js
A utility function, for Greasemonkey scripts, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
/*{
"name": "Local see Package",
"id": "self.private.me.local.see",
"version": 1,
"classPath": "localSee.LocalSeeProviderPackage"
}
*/
/**
* Your package js file must contain a manifest declaration at the very beginning of the file.