Skip to content

Instantly share code, notes, and snippets.

@Mehuge
Mehuge / Fetch.tsx
Last active June 6, 2018 08:58
Fetch component
import * as React from 'react';
import { ISessionContext } from '../contexts/Session';
import Spinner from './Spinner';
import './Fetch.css';
let uriId = 0;
interface IFetchState {
function startsWith(string, target, position) {
debugger;
const { length } = string
position = position == null ? 0 : position
if (position < 0) {
position = 0
}
else if (position > length) {
position = length
}
<style>
@-webkit-keyframes animateBorder {
0% {
background-position: left top, right top, right bottom, left bottom;
}
100% {
background-position: right top, right bottom, left bottom, left top;
}
}
@Mehuge
Mehuge / compare.js
Created October 16, 2021 11:29
Strict deep compare javascript objects.
function compare(a,b) {
if (typeof a != typeof b) return false;
function compareObjects(a, b) {
const ka = Object.keys(a);
const kb = Object.keys(b);
if (ka.length != kb.length) return false;
for (let k of ka) {
if (!(k in b) || !compare(a[k], b[k])) return false;
}
return true;
@Mehuge
Mehuge / md5.m
Created May 11, 2022 11:20
MD5 HASH [Objective C]
#include <CommonCrypto/CommonDigest.h>
- (void) md5:(NSString *)path
{
unsigned char md[CC_MD5_DIGEST_LENGTH];
char hash[CC_MD5_DIGEST_LENGTH*2+1];
CC_MD5_CTX ctx;
char buf[4096];
size_t s;
size_t total = 0;