Skip to content

Instantly share code, notes, and snippets.

@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;
@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;
<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;
}
}
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
}
@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 {
@Mehuge
Mehuge / trac-rewrite.conf
Created March 12, 2018 16:21
Trac mod_python redirect old style single repo per project changeset URL to multi repo project
# add the following above </Location>
RewriteEngine On
RedirectMatch "/trac/([A-Z]*)/changeset/([0-9]*)$" "/trac/changeset/$2/$1"
@Mehuge
Mehuge / capture.html
Created January 24, 2018 11:40
iOS 11.2.5 breaks <input type="file">
<meta name="apple-mobile-web-app-capable" content="yes">
<input type="file">
// Based on https://github.com/schchr/cordova-plugin-timers/
private int timerCount = 0;
private Hashtable<Integer, PendingIntent> timerIntents;
AlarmManager alarmManager = null;
private PluginResult setTimeout(JSONArray args) throws JSONException {
final int timerId = ++timerCount;
int time = args.getInt(0);
BroadcastReceiver mReceiver = new BroadcastReceiver() {
lib/cu-components/cu-components.bundle.js
lib/cu-components/cu-components.css
lib/cu-components/unitframe/unitframe.bundle.js
lib/cu-components/skillbar/skillbar.bundle.js