Skip to content

Instantly share code, notes, and snippets.

View ashaffah's full-sized avatar
🎯
Focusing

Alt ashaffah

🎯
Focusing
  • bedroom
View GitHub Profile
@ghinda
ghinda / object-to-form-data.js
Last active May 13, 2025 05:55
JavaScript Object to FormData, with support for nested objects, arrays and File objects. Includes Angular.js usage.
// takes a {} object and returns a FormData object
var objectToFormData = function(obj, form, namespace) {
var fd = form || new FormData();
var formKey;
for(var property in obj) {
if(obj.hasOwnProperty(property)) {
if(namespace) {
@davestewart
davestewart / broadcast-channel.md
Last active June 6, 2025 16:41
Example of using BroadcastChannel to communicate with pages in the same domain

screenshot

@vcapra1
vcapra1 / hosts.rs
Created May 12, 2019 19:37
Rocket.rs route by subdomain
use rocket::{request::FromRequest, Outcome, Request};
pub struct WWWHost;
pub struct AAAHost;
impl<'a, 'r> FromRequest<'a, 'r> for WWWHost {
type Error = ();
fn from_request(request: &'a Request<'r>) -> rocket::request::Outcome<Self, Self::Error> {
if let Some(hostname) = request.headers().get_one("host") {
@ashaffah
ashaffah / App.tsx
Last active May 29, 2025 14:47
React Provider tree for provider hell
const ProvidersTree = BuildProvidersTree([
[ProviderOne],
[ProviderTwo],
[ProviderThree, {data:data}],
]);
function App(): React.JSX.Element {
// something else..
return (
<ProvidersTree />