Skip to content

Instantly share code, notes, and snippets.

View DimitryDushkin's full-sized avatar
😀
RxJS!

Dimitry DimitryDushkin

😀
RxJS!
View GitHub Profile
@novemberfiveco-gists
novemberfiveco-gists / WKCookieWebView.swift
Last active June 26, 2023 10:02
A WKWebView subclass that passes cookies after a 302 redirect response.
//
// WKCookieWebView.swift
//
// Created by Jens Reynders on 30/03/2018.
// Copyright (c) 2018 November Five
//
// 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
@lilactown
lilactown / promises.re
Last active August 20, 2022 07:56
Notes on using JavaScript Promises in ReasonML/BuckleScript
/**
* Making promises
*/
let okPromise = Js.Promise.make((~resolve, ~reject as _) => [@bs] resolve("ok"));
/* Simpler promise creation for static values */
Js.Promise.resolve("easy");
Js.Promise.reject(Invalid_argument("too easy"));
@blankg
blankg / WebViewBridge.js
Last active July 12, 2022 06:53
For RN >= 0.57 please look at https://github.com/blankg/rn-webview-bridge-sample-new/blob/master/resources/index.html. Provides a sample implementation for sending and receiving messages to and from the React-Native WebView (using postMessage/onMessage WebView API).
/**
* Created by Guy Blank on 3/9/17.
*
* This is a sample provides an API to send & receive messages to and from the React-Native WebView (using postMessage/onMessage WebView API).
* A sample project that uses the bridge is available here https://github.com/blankg/rn-webview-bridge-sample
*
* webViewBridge.send('functionToInvoke', {mydata: 'test'}, function(){console.log('success')},function(){console.log('error')});
*
* The API is designed to be similar to the Cordova exec API so migration to it should be almost seamless.
* The API also provides solution to a React-Native WebView bug in iOS which causes sending consecutive postMessage calls to override each other.
@brennanMKE
brennanMKE / EventEmitter.swift
Last active March 7, 2024 04:04
React Native Event Emitter for RCTEventEmitter in Objective-C and Swift
class EventEmitter
/// Shared Instance.
public static var sharedInstance = EventEmitter()
// ReactNativeEventEmitter is instantiated by React Native with the bridge.
private static var eventEmitter: ReactNativeEventEmitter!
private init() {}
@chourobin
chourobin / 0-bridging-react-native-cheatsheet.md
Last active April 11, 2024 15:02
React Native Bridging Cheatsheet
@bradoyler
bradoyler / child.html
Last active April 14, 2020 19:10
adaptive iframe using postMessage()
<h2> Hello World! </h2>
<script>
function iframeResize() {
var body = document.body, html = document.documentElement;
var height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
var location = document.location.href;
window.parent.postMessage(["setHeight", height, location], "*");
}
iframeResize();
$(window).resize(iframeResize);
@monochromer
monochromer / ui-bits.js
Last active April 26, 2019 23:47
Битовые маски в UI
/**
* Битовые маски в UI
* Автор: Игорь Алексеенко
*/
// состояния компонентов
class Button {
constructor() {
this.state =
// @flow
/* eslint-disable */
declare module 'redux-form' {
declare export type InputProps = {
checked?: boolean,
name: string,
value: any,
onBlur: Function,
onChange: Function,
@ammulder
ammulder / camera.html
Created March 8, 2013 21:39
Web page with JS camera and image manipulations
<!DOCTYPE html>
<head>
<title>HTML5 Camera Fun</title>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="http://www.nihilogic.dk/labs/exif/exif.js" type="text/javascript"></script>
<script src="http://www.nihilogic.dk/labs/binaryajax/binaryajax.js" type="text/javascript"></script>
<script type="text/javascript">
// Wrapper around MPL-licensed http://www.nihilogic.dk/labs/binaryajax/binaryajax.js
// to support JavaScript typed arrays since binary strings are not supported in IE 10
var createBinaryFile = function(uintArray) {
@Yaffle
Yaffle / gist:1287361
Last active November 24, 2021 13:24
crc 32 in javascript
function crc32(s/*, polynomial = 0x04C11DB7, initialValue = 0xFFFFFFFF, finalXORValue = 0xFFFFFFFF*/) {
s = String(s);
var polynomial = arguments.length < 2 ? 0x04C11DB7 : (arguments[1] >>> 0);
var initialValue = arguments.length < 3 ? 0xFFFFFFFF : (arguments[2] >>> 0);
var finalXORValue = arguments.length < 4 ? 0xFFFFFFFF : (arguments[3] >>> 0);
var table = new Array(256);
var reverse = function (x, n) {
var b = 0;